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 256 lines 10.5 KB
Raw
1 import { SETUP_PROMPT } from '../../lib/agent-prompts';
2 import { describe, expect, test } from 'bun:test';
3
4 import {
5 HOME_INTENTS,
6 homeIntentAnchor,
7 homeIntentsToMarkdown,
8 replaceHomeNavigationMarkdown,
9 } from '../../lib/home-navigation';
10 import { mdxToCleanMarkdown } from '../../lib/source';
11
12 describe('Welcome navigation', () => {
13 test('separates build paths from use paths', () => {
14 expect(HOME_INTENTS.map(intent => intent.title)).toEqual([
15 'Build with Composio',
16 'Use Composio',
17 ]);
18 expect(HOME_INTENTS[0].links.map(link => link.href)).toEqual([
19 '/docs/quickstart',
20 '/docs/providers',
21 '/docs/sessions-via-mcp',
22 ]);
23 expect(HOME_INTENTS[1].links.map(link => link.href)).toEqual([
24 '/docs/agent-plugins',
25 '/docs/cli',
26 '/docs/composio-connect',
27 ]);
28 });
29
30 test('serializes the same paths for agent-readable Markdown', () => {
31 const markdown = homeIntentsToMarkdown();
32
33 for (const intent of HOME_INTENTS) {
34 expect(markdown).toContain(`### ${intent.title}`);
35 expect(markdown).toContain(`**${intent.product}**`);
36 for (const link of intent.links) {
37 expect(markdown).toContain(`[${link.title}](${link.href})`);
38 }
39 }
40
41 expect(replaceHomeNavigationMarkdown('<HomeSurfaces />')).toBe(markdown);
42 expect(mdxToCleanMarkdown('<HomeSurfaces />')).toContain('## Two ways to start');
43 expect(mdxToCleanMarkdown('<HomeSurfaces />')).toContain('### Build with Composio');
44 expect(markdown).not.toContain('<HomeSurfaces');
45 expect(markdown.toLowerCase()).not.toContain('skills');
46 expect(markdown).toContain('native Composio plugin for Codex or Claude Code');
47 });
48
49 test('keeps rendered headings linkable and product visuals present', async () => {
50 const source = await Bun.file(
51 new URL('../../components/home-surfaces.tsx', import.meta.url)
52 ).text();
53 const lockupSource = await Bun.file(
54 new URL('../../components/product-lockup.tsx', import.meta.url)
55 ).text();
56
57 expect(source).toContain('id="two-ways-to-start"');
58 for (const intent of HOME_INTENTS) {
59 expect(homeIntentAnchor(intent.product)).toMatch(/^[a-z0-9-]+$/);
60 }
61 expect(source).toContain('id={homeIntentAnchor(intent.product)}');
62 // Each compact card is headed by the canonical product lockup: Composio
63 // logo plus the dashboard's ComposioProductBadge port.
64 expect(source).toContain('ProductLockup');
65 expect(source).toContain('ProductSelectionLink');
66 expect(source).toContain('md:grid-cols-2');
67 expect(lockupSource).toContain('ProductBadge');
68 expect(lockupSource).toContain('background: PLATFORM_BADGE_GRADIENT');
69 expect(lockupSource).toContain("backgroundClip: 'text'");
70 expect(lockupSource).toContain("WebkitTextFillColor: 'transparent'");
71 expect(lockupSource).toContain("mask: 'linear-gradient(#fff 0 0) content-box");
72 expect(lockupSource).toContain('text-[#0007cd] dark:text-[#4d6fff]');
73 expect(lockupSource).toContain('product-badge-platform-border');
74 expect(lockupSource).toContain('/Composio Logo.svg');
75 // Both logo variants carry the same alt: `dark:hidden` / `hidden dark:block`
76 // swap them in CSS, so an aria-hidden dark variant would drop "Composio"
77 // from the heading's accessible name in dark mode only.
78 expect(lockupSource.match(/alt="Composio"/g) ?? []).toHaveLength(2);
79 });
80
81 test('offers reusable agent setup actions on the homepage and quickstart', async () => {
82 const source = await Bun.file(
83 new URL('../../components/agent-setup-actions.tsx', import.meta.url)
84 ).text();
85 const heroSource = await Bun.file(
86 new URL('../../components/docs-hero-v2.tsx', import.meta.url)
87 ).text();
88 const quickstartSource = await Bun.file(
89 new URL('../../content/docs/quickstart.mdx', import.meta.url)
90 ).text();
91
92 expect(source).toContain('export function AgentSetupActions');
93 expect(source).toContain('Agent setup');
94 expect(source).toContain('/docs/agent-setup');
95 expect(source).not.toContain('ProductSelectionLink');
96 expect(source).toContain('navigator.clipboard.writeText(SETUP_PROMPT)');
97 expect(SETUP_PROMPT).toContain('npx skills add ComposioHQ/composio --skill composio');
98 expect(SETUP_PROMPT).toContain('https://docs.composio.dev');
99 expect(heroSource).toContain('<AgentSetupActions />');
100 expect(quickstartSource).toContain('<AgentSetupActions');
101 for (const logo of ['claude.svg', 'codex.png', 'cursor.svg']) {
102 expect(source).toContain(`/images/clients/${logo}`);
103 expect(await Bun.file(new URL(`../../public/images/clients/${logo}`, import.meta.url)).exists()).toBe(true);
104 }
105 });
106
107 test('links every agent setup card to instructions on the Clients page', async () => {
108 const grid = await Bun.file(
109 new URL('../../lib/agent-setup-clients.ts', import.meta.url)
110 ).text();
111 const clients = await Bun.file(
112 new URL('../../content/docs/agent-setup/clients.mdx', import.meta.url)
113 ).text();
114 const agents = [
115 'claude-code',
116 'openai-codex',
117 'cursor',
118 'github-copilot',
119 'gemini-cli',
120 'openclaw',
121 'opencode',
122 'cline',
123 'grok-build',
124 ];
125
126 for (const agent of agents) {
127 expect(grid).toContain(`href: '/docs/agent-setup/clients#${agent}'`);
128 }
129 const overview = await Bun.file(
130 new URL('../../content/docs/agent-setup/index.mdx', import.meta.url)
131 ).text();
132 expect(overview).toContain('<AgentSetupGrid />');
133 expect(clients).not.toContain('<AgentSetupGrid');
134 expect(clients).toContain('title: Clients');
135 expect(clients.match(/\*\*Global install\*\*/g) ?? []).toHaveLength(9);
136 expect(clients.match(/\*\*Project install\*\*/g) ?? []).toHaveLength(9);
137 expect(clients.match(/```bash/g) ?? []).toHaveLength(18);
138 for (const agent of [
139 'claude-code',
140 'opencode',
141 'cline',
142 'grok',
143 'codex',
144 'cursor',
145 'github-copilot',
146 'gemini-cli',
147 'openclaw',
148 ]) {
149 expect(clients).toContain(`<AgentFirstPrompt agent="${agent}" />`);
150 }
151 for (const agent of [
152 'claude-code',
153 'codex',
154 'cursor',
155 'github-copilot',
156 'gemini-cli',
157 'openclaw',
158 'opencode',
159 'cline',
160 'grok',
161 ]) {
162 expect(clients).toContain(`--agent ${agent} --global`);
163 expect(clients).toContain(`--agent ${agent}\n`);
164 }
165 for (const path of [
166 '.claude/skills/',
167 '~/.claude/skills/',
168 '~/.codex/skills/',
169 '~/.cursor/skills/',
170 '~/.copilot/skills/',
171 '~/.gemini/skills/',
172 '~/.openclaw/skills/',
173 '~/.config/opencode/skills/',
174 '~/.agents/skills/',
175 '.grok/skills/',
176 '~/.grok/skills/',
177 ]) {
178 expect(clients).toContain(path);
179 }
180 for (const logo of ['opencode.svg', 'cline.svg', 'grok.svg']) {
181 expect(grid).toContain(`/images/clients/${logo}`);
182 expect(await Bun.file(new URL(`../../public/images/clients/${logo}`, import.meta.url)).exists()).toBe(true);
183 }
184 expect(clients).not.toContain('Use Composio with your own apps');
185 expect(clients).not.toContain('personal apps');
186
187 const firstPrompt = await Bun.file(
188 new URL('../../components/agent-first-prompt.tsx', import.meta.url)
189 ).text();
190 const promptSource = await Bun.file(new URL('../../lib/agent-prompts.ts', import.meta.url)).text();
191 expect(firstPrompt).toContain('navigator.clipboard.writeText(prompt)');
192 expect(promptSource).toContain("'claude-code': 'Use the /composio skill");
193 expect(promptSource).toContain("codex: 'Use the $composio skill");
194 expect(promptSource).toContain("'github-copilot': 'Use /composio");
195 expect(promptSource).toContain("cursor: 'Use the composio agent skill");
196 expect(promptSource).toContain('Help me connect an integration and make my first real tool call.');
197 expect(promptSource).toContain('When it works, show me what changed and what I can try next.');
198 });
199
200 test('advertises only toolkits that exist in the catalog', async () => {
201 const source = await Bun.file(
202 new URL('../../components/home-features.tsx', import.meta.url)
203 ).text();
204 const block = source.match(/const TOOLKIT_LOGOS = \[([\s\S]*?)\]/)?.[1];
205 expect(block).toBeTruthy();
206 const slugs = [...block!.matchAll(/'([a-z0-9]+)'/g)].map(m => m[1]);
207 expect(slugs.length).toBe(29);
208
209 const catalog: { slug: string }[] = await Bun.file(
210 new URL('../../public/data/toolkits.json', import.meta.url)
211 ).json();
212 const known = new Set(catalog.map(t => t.slug));
213 // A tile that isn't in the catalog still renders (the logo CDN serves it)
214 // but advertises an app with no /toolkits/<slug> page behind it.
215 expect(slugs.filter(s => !known.has(s))).toEqual([]);
216 });
217
218 test('keeps the auth diagram wires drawable at every pane width', async () => {
219 const source = await Bun.file(
220 new URL('../../components/home-auth-diagram.tsx', import.meta.url)
221 ).text();
222
223 // The feature-grid pane is not monotonic in the viewport: ~404px at 1280px
224 // but only ~242px at 640px, where the grid goes two-column. Fixed hub/card
225 // widths that fit one end overflow the other, the horizontal run goes to
226 // zero, and every elbow degenerates into elbowPath's straight-line
227 // fallback — the middle wire to a zero-length, invisible path. Proportional
228 // widths keep a gap at every size; container queries gate the account label
229 // on the pane rather than the viewport.
230 expect(source).toContain('w-[36%] max-w-36');
231 expect(source).toContain('w-[52%] max-w-56');
232 expect(source).toContain('@container');
233 expect(source).toContain('@[340px]:inline');
234 expect(source).not.toMatch(/className="[^"]*\bw-44\b/);
235
236 // Stale paths outlive a resize when RO delivery is throttled, so the
237 // window listener backs it up (as in connection-refresh-visual.tsx).
238 expect(source).toContain("window.addEventListener('resize', calc)");
239 expect(source).toContain("window.removeEventListener('resize', calc)");
240 });
241
242 test('shows the sandbox on its real Python surface', async () => {
243 const source = await Bun.file(
244 new URL('../../components/home-features.tsx', import.meta.url)
245 ).text();
246
247 // content/docs/sandbox/remote.mdx — where this card links — describes a
248 // persistent Python environment with run_composio_tool / invoke_llm
249 // pre-initialized. There is no composio.sandbox.run() SDK method.
250 expect(source).toContain('run_composio_tool');
251 expect(source).toContain('invoke_llm');
252 expect(source).toContain('sandbox.py');
253 expect(source).not.toContain('composio.sandbox.run');
254 expect(source).not.toContain('composio.workbench.run');
255 });
256 });