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 164 lines 6.47 KB
Raw
1 import { describe, expect, test } from 'bun:test';
2
3 import { HOME_INTENTS } from '../../lib/home-navigation';
4
5 const read = (path: string) => Bun.file(new URL(`../../${path}`, import.meta.url)).text();
6
7 /**
8 * Auth guides retain their URLs; managed vs custom auth is listed under
9 * Production readiness. Shared connections lives under Extend sessions.
10 */
11 const AUTH_GUIDES = [
12 'manually-authenticating',
13 'managing-multiple-connected-accounts',
14 'importing-existing-connections',
15 'custom-app-vs-managed-app',
16 'programmatic-auth-configs',
17 'controlling-scopes',
18 'white-labeling-authentication',
19 ];
20
21 const GUIDE_URLS = [
22 ...AUTH_GUIDES.map(guide => `/docs/authentication/${guide}`),
23 '/docs/extending-sessions/shared-connections',
24 ];
25
26 describe('getting-started routing policy', () => {
27 test('publishes native plugins for both supported agent hosts', async () => {
28 const plugins = await read('content/docs/agent-plugins.mdx');
29
30 expect(plugins).toContain('Agent plugins let Codex and Claude Code use Composio');
31 expect(plugins).toContain('composio setup --target codex');
32 expect(plugins).toContain('composio setup --target claude');
33 expect(plugins).toContain('codex plugin marketplace add');
34 expect(plugins).toContain('/plugin marketplace add');
35 expect(plugins).toContain('composio search');
36 expect(plugins).toContain('composio link');
37 expect(plugins).toContain('composio execute');
38 expect(plugins).toContain('composio setup skill claude');
39 expect(plugins).toContain('composio setup skill codex');
40 expect(plugins).toContain('composio setup --target auto --yes');
41 expect(plugins).toContain('### Codex');
42 expect(plugins).toContain('### Claude Code');
43 expect(plugins).not.toContain('<Tabs');
44 });
45
46 test('keeps native plugins ahead of CLI and explicit MCP on Welcome', () => {
47 expect(HOME_INTENTS[1].links.map(link => link.href)).toEqual([
48 '/docs/agent-plugins',
49 '/docs/cli',
50 '/docs/composio-connect',
51 ]);
52 });
53
54 test('keeps progressive authentication guides in the human hub and the sidebar', async () => {
55 const [authentication, authMeta, sessionsMeta, readinessMeta] = await Promise.all([
56 read('content/docs/authentication/index.mdx'),
57 read('content/docs/authentication/meta.json'),
58 read('content/docs/extending-sessions/meta.json'),
59 read('content/docs/poc-to-prod/meta.json'),
60 ]);
61 const authPages = JSON.parse(authMeta).pages as string[];
62 const sessionPages = JSON.parse(sessionsMeta).pages as string[];
63
64 for (const guide of AUTH_GUIDES) {
65 expect(authentication).toContain(`href="/docs/authentication/${guide}"`);
66 if (guide === 'custom-app-vs-managed-app') {
67 expect(authPages).not.toContain(guide);
68 expect(JSON.parse(readinessMeta).pages).toContain(`../authentication/${guide}`);
69 } else {
70 expect(authPages).toContain(guide);
71 }
72 }
73
74 expect(authentication).toContain('href="/docs/extending-sessions/shared-connections"');
75 expect(sessionPages).toContain('shared-connections');
76 });
77
78 /**
79 * Asserts the generated bytes, not the meta.json inputs. These guides used to
80 * be listed in llms.txt by a hardcoded `AUTHENTICATION_GUIDE_URLS` constant
81 * because they had been dropped from the page tree; they are emitted by the
82 * page-tree walk now, so a regression in that walk — not just in the meta
83 * files — has to fail something.
84 */
85 test('emits every authentication guide into llms.txt exactly once', async () => {
86 const { GET } = await import('../../app/llms-index.txt/route');
87 const llms = await (await GET()).text();
88
89 for (const url of ['/docs/authentication', ...GUIDE_URLS]) {
90 const occurrences = llms.split(`https://docs.composio.dev${url}.md`).length - 1;
91 expect(occurrences, `${url} appears ${occurrences}x in llms.txt`).toBe(1);
92 }
93 });
94
95 test('does not turn external sidebar links into documentation URLs', async () => {
96 const { GET } = await import('../../app/llms-index.txt/route');
97 const llms = await (await GET()).text();
98
99 expect(llms).not.toContain('- https://docs.composio.dev/llms.txt.md');
100 });
101
102 /**
103 * `nearest` is the closest preceding heading of any level. Markdown headings
104 * do not close, so it is what an agent reads a URL as belonging to: a page
105 * emitted after a folder reads as one of that folder's children even though
106 * the sidebar shows it as a sibling.
107 */
108 test('files each page under the section it belongs to', async () => {
109 const { GET } = await import('../../app/llms-index.txt/route');
110 const lines = (await (await GET()).text()).split('\n');
111
112 const sectionOf = (url: string) => {
113 const index = lines.findIndex(line => line.includes(`${url}.md)`));
114 expect(index, `${url} missing from llms.txt`).toBeGreaterThan(-1);
115 const preceding = lines.slice(0, index);
116 return {
117 section: preceding.findLast(line => line.startsWith('## ')),
118 nearest: preceding.findLast(line => line.startsWith('#')),
119 };
120 };
121
122 for (const guide of AUTH_GUIDES) {
123 expect(sectionOf(`/docs/authentication/${guide}`)).toEqual({
124 section: guide === 'custom-app-vs-managed-app' ? '## Guides' : '## Core concepts',
125 nearest: guide === 'custom-app-vs-managed-app' ? '### Production readiness' : '### Authentication',
126 });
127 }
128
129 expect(sectionOf('/docs/authentication')).toEqual({
130 section: '## Core concepts',
131 nearest: '### Authentication',
132 });
133
134 expect(sectionOf('/docs/extending-sessions/shared-connections')).toEqual({
135 section: '## Guides',
136 nearest: '### Extend sessions',
137 });
138
139 // Siblings that follow the Authentication folder in meta.json. These fell
140 // under `### Authentication` when folders were emitted in meta.json order.
141 for (const sibling of ['/docs/triggers', '/docs/skills']) {
142 expect(sectionOf(sibling)).toEqual({
143 section: '## Core concepts',
144 nearest: '## Core concepts',
145 });
146 }
147
148 // Same failure mode, pre-dating this folder: Get Started's pages sit after
149 // the `providers` folder and used to read as SDKs-and-frameworks children.
150 for (const sibling of ['/docs/agent-plugins', '/docs/cli', '/docs/composio-connect']) {
151 expect(sectionOf(sibling)).toEqual({
152 section: '## Get Started',
153 nearest: '## Get Started',
154 });
155 }
156
157 expect(sectionOf('/docs/agent-setup')).toEqual({
158 section: '## Get Started',
159 nearest: '### Agent setup',
160 });
161
162 expect(lines).not.toContain('## Authentication guides');
163 });
164 });