@devries-cameron20 / composio Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
ts 55 lines 2.02 KB
Raw
1 import { expect, test } from 'bun:test';
2 import { TOOLKIT_COUNT_LABEL } from '../../lib/toolkit-count';
3 import { fetchPage } from './helpers';
4
5 async function paragraphText(html: string): Promise<string> {
6 let content = '';
7 await new HTMLRewriter()
8 .on('main p', {
9 text(chunk) {
10 content += chunk.text;
11 },
12 })
13 .transform(new Response(html))
14 .text();
15 return content;
16 }
17
18 test('paragraph extraction ignores metadata and script contents', async () => {
19 for (const closeTag of ['</script>', '</script >']) {
20 const html = `<head><meta name="description" content="1,500+ apps"></head>
21 <body><main><script>const text = '<p>1,500+ apps</p>';${closeTag}
22 <p>1,500+ <strong>toolkits</strong></p></main></body>`;
23 expect(await paragraphText(html)).toBe('1,500+ toolkits');
24 }
25 });
26
27 test('catalog claims use apps in marketing copy and toolkits in technical docs', async () => {
28 for (const [path, noun] of [
29 ['/docs', 'apps'],
30 ['/docs/quickstart', 'apps'],
31 ['/docs/providers/openai', 'apps'],
32 ['/docs/claude-code-plugin', 'apps'],
33 ['/reference', 'toolkits'],
34 ['/toolkits/meta-tools', 'toolkits'],
35 ['/toolkits/meta-tools/search_tools', 'toolkits'],
36 ['/docs/quickstart.md', 'apps'],
37 ['/reference.md', 'toolkits'],
38 ['/llms.txt', 'apps'],
39 ]) {
40 const response = await fetchPage(path);
41 expect(response.status, path).toBe(200);
42 const text = await response.text();
43 // Parse authored paragraphs so metadata and hydration payloads cannot satisfy body assertions.
44 const body = response.headers.get('content-type')?.includes('text/html')
45 ? await paragraphText(text)
46 : text;
47 if (path !== '/docs/providers/openai') {
48 expect(body, path).toContain(`${TOOLKIT_COUNT_LABEL} ${noun}`);
49 }
50 expect(text, path).not.toContain('%TOOLKIT_COUNT%');
51 if (path === '/docs/providers/openai') {
52 expect(text).toContain(`name="description" content="Build an agent with OpenAI and enable it to use ${TOOLKIT_COUNT_LABEL} apps with Composio.`);
53 }
54 }
55 });