Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | /** |
| 2 | * CLI `composio dev toolkits list` e2e test |
| 3 | * |
| 4 | * Verifies that the list subcommand returns toolkits as JSON in piped mode, |
| 5 | * supports deterministic `--query` filtering, and respects `--limit`. |
| 6 | */ |
| 7 | |
| 8 | import { e2e, sanitizeOutput, parseJsonStdout, type E2ETestResult } from '@e2e-tests/utils'; |
| 9 | import { TIMEOUTS } from '@e2e-tests/utils/const'; |
| 10 | import { afterAll, beforeAll, describe, expect, it } from 'bun:test'; |
| 11 | import { |
| 12 | startMockToolkitsListServer, |
| 13 | type MockToolkitsServer, |
| 14 | } from '../../../../packages/cli/scripts/mock-toolkits-server'; |
| 15 | |
| 16 | e2e(import.meta.url, { |
| 17 | versions: { |
| 18 | cli: ['current'], |
| 19 | }, |
| 20 | defineTests: ({ runCmd }) => { |
| 21 | let server: MockToolkitsServer; |
| 22 | let exactResult: E2ETestResult; |
| 23 | let prefixResult: E2ETestResult; |
| 24 | let noFuzzyResult: E2ETestResult; |
| 25 | |
| 26 | beforeAll(async () => { |
| 27 | server = await startMockToolkitsListServer(); |
| 28 | |
| 29 | const envPrefix = [ |
| 30 | `COMPOSIO_BASE_URL=${server.dockerBaseUrl}`, |
| 31 | 'COMPOSIO_CACHE_DIR=/tmp/composio-toolkits-list', |
| 32 | 'COMPOSIO_USER_API_KEY=uak_mock_toolkits_list', |
| 33 | ].join(' '); |
| 34 | |
| 35 | exactResult = await runCmd(`${envPrefix} composio dev toolkits list --query gmail --limit 1`); |
| 36 | prefixResult = await runCmd(`${envPrefix} composio dev toolkits list --query gmai --limit 1`); |
| 37 | noFuzzyResult = await runCmd( |
| 38 | `${envPrefix} composio dev toolkits list --query gmal --limit 1` |
| 39 | ); |
| 40 | }, TIMEOUTS.FIXTURE); |
| 41 | |
| 42 | afterAll(async () => { |
| 43 | await server.close(); |
| 44 | }); |
| 45 | |
| 46 | describe('composio dev toolkits list --query gmail --limit 1 (exact slug)', () => { |
| 47 | it('exits successfully', () => { |
| 48 | expect(exactResult.exitCode).toBe(0); |
| 49 | }); |
| 50 | |
| 51 | it('stderr is empty', () => { |
| 52 | expect(exactResult.stderr).toBe(''); |
| 53 | }); |
| 54 | |
| 55 | it('stdout is a JSON array with 1 element', () => { |
| 56 | const items = parseJsonStdout(exactResult); |
| 57 | expect(Array.isArray(items)).toBe(true); |
| 58 | expect(items).toHaveLength(1); |
| 59 | }); |
| 60 | |
| 61 | it('the element has slug "gmail"', () => { |
| 62 | const items = parseJsonStdout(exactResult) as Array<{ slug: string }>; |
| 63 | expect(items[0].slug).toBe('gmail'); |
| 64 | }); |
| 65 | |
| 66 | it('the element has the expected shape', () => { |
| 67 | const item = (parseJsonStdout(exactResult) as Array<Record<string, unknown>>)[0]; |
| 68 | expect(item).toHaveProperty('name'); |
| 69 | expect(item).toHaveProperty('slug'); |
| 70 | expect(item).toHaveProperty('description'); |
| 71 | expect(item).toHaveProperty('latest_version'); |
| 72 | expect(item).toHaveProperty('tools_count'); |
| 73 | expect(item).toHaveProperty('triggers_count'); |
| 74 | expect(item).toHaveProperty('is_no_auth'); |
| 75 | expect(item).toHaveProperty('enabled'); |
| 76 | expect(item).toHaveProperty('connected'); |
| 77 | }); |
| 78 | }); |
| 79 | |
| 80 | describe('composio dev toolkits list --query gmai --limit 1 (prefix search)', () => { |
| 81 | it('exits successfully', () => { |
| 82 | expect(prefixResult.exitCode).toBe(0); |
| 83 | }); |
| 84 | |
| 85 | it('stderr is empty', () => { |
| 86 | expect(prefixResult.stderr).toBe(''); |
| 87 | }); |
| 88 | |
| 89 | it('stdout is a JSON array with 1 element', () => { |
| 90 | const items = parseJsonStdout(prefixResult); |
| 91 | expect(Array.isArray(items)).toBe(true); |
| 92 | expect(items).toHaveLength(1); |
| 93 | }); |
| 94 | |
| 95 | it('the element has slug "gmail"', () => { |
| 96 | const items = parseJsonStdout(prefixResult) as Array<{ slug: string }>; |
| 97 | expect(items[0].slug).toBe('gmail'); |
| 98 | }); |
| 99 | }); |
| 100 | |
| 101 | describe('composio dev toolkits list --query gmal --limit 1 (no fuzzy search)', () => { |
| 102 | it('exits successfully', () => { |
| 103 | expect(noFuzzyResult.exitCode).toBe(0); |
| 104 | }); |
| 105 | |
| 106 | it('stderr is empty', () => { |
| 107 | expect(noFuzzyResult.stderr).toBe(''); |
| 108 | }); |
| 109 | |
| 110 | it('stdout is an empty JSON array (no results)', () => { |
| 111 | expect(sanitizeOutput(noFuzzyResult.stdout)).toBe('[]'); |
| 112 | }); |
| 113 | }); |
| 114 | |
| 115 | describe('mock API usage', () => { |
| 116 | it('requests the toolkit catalog for each search term', () => { |
| 117 | expect(server.requests).toContain('GET /api/v3.1/toolkits?search=gmail&limit=1'); |
| 118 | expect(server.requests).toContain('GET /api/v3.1/toolkits?search=gmai&limit=1'); |
| 119 | expect(server.requests).toContain('GET /api/v3.1/toolkits?search=gmal&limit=1'); |
| 120 | }); |
| 121 | }); |
| 122 | }, |
| 123 | }); |