Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 72 lines 2.62 KB
Raw
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4 import { exitCodeOf } from 'test/__utils__/exit-code';
5 import { stubClientResources } from 'test/__utils__/services/stub-composio-client';
6
7 const testLayer = TestLive({
8 baseConfigProvider: ConfigProvider.fromEnv({ env: { COMPOSIO_USER_API_KEY: 'test_api_key' } }),
9 });
10
11 describe('CLI: composio dev toolkits version over the API client', () => {
12 layer(testLayer)('[Given] a toolkit the API does not know', it => {
13 it.effect('[Then] the API message and the browse hint are printed', () =>
14 Effect.gen(function* () {
15 const stub = stubClientResources(['toolkits'], () =>
16 Response.json(
17 {
18 error: {
19 message: 'Toolkit unknown not found',
20 code: 1803,
21 slug: 'Toolkit_NotFound',
22 status: 404,
23 },
24 },
25 { status: 404 }
26 )
27 );
28 const exit = yield* Effect.exit(
29 cli(['dev', 'toolkits', 'version', 'unknown']).pipe(Effect.provide(stub.layer))
30 );
31 const lines = yield* MockConsole.getLines({ stripAnsi: true });
32
33 expect(lines).toEqual([
34 'Toolkit unknown not found',
35 'Browse available toolkits:\n> composio dev toolkits list',
36 ]);
37 expect(exitCodeOf(exit)).toBe(1);
38 expect(stub.requests).toEqual([{ method: 'GET', path: '/api/v3.1/toolkits/unknown' }]);
39 })
40 );
41 });
42
43 layer(testLayer)('[Given] a toolkit response without the fields the catalog requires', it => {
44 it.effect('[Then] the versions it does carry are printed', () =>
45 Effect.gen(function* () {
46 const stub = stubClientResources(['toolkits'], () =>
47 Response.json({
48 slug: 'gmail',
49 name: 'Gmail',
50 meta: { available_versions: ['20260101_00', '20260201_00'] },
51 })
52 );
53 yield* cli(['dev', 'toolkits', 'version', 'gmail']).pipe(Effect.provide(stub.layer));
54 const lines = yield* MockConsole.getLines({ stripAnsi: true });
55
56 expect(lines).toEqual([
57 'Fetching versions for toolkit "gmail"...',
58 'Toolkit: Gmail (gmail)\nLatest Version: 20260201_00\nLast 2 Available Versions:\n- 20260101_00\n- 20260201_00',
59 JSON.stringify(
60 {
61 slug: 'gmail',
62 latest_version: '20260201_00',
63 available_versions_last_20: ['20260101_00', '20260201_00'],
64 },
65 null,
66 2
67 ),
68 ]);
69 })
70 );
71 });
72 });