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 | import { expect, test } from 'bun:test'; |
| 2 | import { fetchPage } from './helpers'; |
| 3 | |
| 4 | async function providerLinks(html: string): Promise<Map<string, string>> { |
| 5 | const links = new Map<string, string>(); |
| 6 | let href = ''; |
| 7 | await new HTMLRewriter() |
| 8 | .on('article ul > li > a', { |
| 9 | element(element) { |
| 10 | const target = element.getAttribute('href') ?? ''; |
| 11 | href = target.startsWith('/docs/providers/') || target.includes('/ts/packages/providers/cloudflare/') |
| 12 | ? target : ''; |
| 13 | }, |
| 14 | text(text) { |
| 15 | if (href) links.set(href, (links.get(href) ?? '') + text.text); |
| 16 | }, |
| 17 | }) |
| 18 | .transform(new Response(html)) |
| 19 | .text(); |
| 20 | return links; |
| 21 | } |
| 22 | |
| 23 | test('providers are semantic linked lists in server HTML and processed Markdown', async () => { |
| 24 | const htmlResponse = await fetchPage('/docs/providers', { timeout: 120_000 }); |
| 25 | expect(htmlResponse.status).toBe(200); |
| 26 | expect(htmlResponse.headers.get('content-type')).toContain('text/html'); |
| 27 | const html = await htmlResponse.text(); |
| 28 | const links = await providerLinks(html); |
| 29 | |
| 30 | const markdownResponse = await fetchPage('/docs/providers.md', { timeout: 120_000 }); |
| 31 | expect(markdownResponse.status).toBe(200); |
| 32 | expect(markdownResponse.headers.get('content-type')).toContain('text/markdown'); |
| 33 | const markdown = await markdownResponse.text(); |
| 34 | const providerSection = markdown.split('## AI SDKs')[1]?.split('More documentation')[0] ?? ''; |
| 35 | const markdownLinks = Array.from(providerSection.matchAll(/^- \[([^\]]+)\]\(([^)]+)\)/gm)); |
| 36 | expect([...links.keys()].sort()).toEqual([...new Set(markdownLinks.map(match => match[2]))].sort()); |
| 37 | for (const [, name, href] of markdownLinks) expect(links.get(href), href).toContain(name); |
| 38 | for (const [name, slug] of [ |
| 39 | ['Anthropic', 'anthropic'], ['OpenAI Agents SDK', 'openai'], |
| 40 | ['Claude Agent SDK', 'anthropic'], ['Google ADK', 'google'], |
| 41 | ['LangGraph', 'langchain'], ['Eve', 'eve'], ['Build your own', 'custom-providers'], |
| 42 | ]) { |
| 43 | expect(links.get(`/docs/providers/${slug}`)).toContain(name); |
| 44 | expect(providerSection).toContain(`[${name}](/docs/providers/${slug})`); |
| 45 | } |
| 46 | for (const slug of ['pi', 'eve']) { |
| 47 | expect(links.get(`/docs/providers/${slug}`)).toContain('Experimental'); |
| 48 | expect(providerSection).toContain(`](/docs/providers/${slug}) (TypeScript; experimental)`); |
| 49 | } |
| 50 | expect(providerSection).not.toMatch(/ProviderList|languages=|\/>/); |
| 51 | expect(links.get('https://github.com/ComposioHQ/composio/blob/next/ts/packages/providers/cloudflare/README.md')) |
| 52 | .toContain('Cloudflare Workers AI'); |
| 53 | }, 180_000); |