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
| 1 | import { describe, expect, test } from 'bun:test'; |
| 2 | import { readFileSync } from 'node:fs'; |
| 3 | import { Glob } from 'bun'; |
| 4 | import { mdxToCleanMarkdown, getLLMText } from '../../lib/source'; |
| 5 | import { recordsFromMarkdownPage } from '../../lib/search-index'; |
| 6 | |
| 7 | describe('PackageInstall Markdown', () => { |
| 8 | test('preserves alternatives and comments in authored and processed MDX', () => { |
| 9 | for (const input of [ |
| 10 | `<PackageInstall packages="@composio/core" comment={['Use @composio/slim instead.', 'Choose one package.']} />`, |
| 11 | `<PackageInstall packages="@composio/core" comment="['Use @composio/slim instead.', 'Choose one package.']" />`, |
| 12 | ]) { |
| 13 | const markdown = mdxToCleanMarkdown(input); |
| 14 | for (const command of ['npm install', 'pnpm add', 'bun add', 'yarn add']) { |
| 15 | expect(markdown).toContain(`${command} @composio/core`); |
| 16 | } |
| 17 | expect(markdown).toContain('# Use @composio/slim instead.'); |
| 18 | expect(markdown).toContain('# Choose one package.'); |
| 19 | } |
| 20 | const python = mdxToCleanMarkdown(`<PackageInstall ecosystem="python" packages="composio 'ag2[openai]'" />`); |
| 21 | expect(python).toContain("uv add composio 'ag2[openai]'"); |
| 22 | expect(python).toContain("pip install composio 'ag2[openai]'"); |
| 23 | }); |
| 24 | |
| 25 | test('every authored installation reaches page text and search records', async () => { |
| 26 | let checked = 0; |
| 27 | for (const path of new Glob('content/**/*.mdx').scanSync('.')) { |
| 28 | const raw = readFileSync(path, 'utf8'); |
| 29 | const installs = [...raw.matchAll(/<PackageInstall\b[\s\S]*?packages="([^"]+)"[\s\S]*?\/>/g)]; |
| 30 | if (!installs.length) continue; |
| 31 | const url = '/' + path.replace(/^content\//, '').replace(/\/index\.mdx$/, '').replace(/\.mdx$/, ''); |
| 32 | const page = await getLLMText({ url, data: { title: path, getText: async () => raw } }); |
| 33 | const records = recordsFromMarkdownPage({ url, title: path, type: 'docs', markdown: raw }); |
| 34 | const search = records.map(record => record.content).join('\n'); |
| 35 | for (const install of installs) { |
| 36 | expect(page, path).toContain(install[1]); |
| 37 | expect(search, path).toContain(install[1]); |
| 38 | checked++; |
| 39 | } |
| 40 | } |
| 41 | expect(checked).toBeGreaterThan(40); |
| 42 | }); |
| 43 | |
| 44 | test('keeps agent setup instructions, client links, and video descriptions', () => { |
| 45 | const text = mdxToCleanMarkdown(`<AgentSetupActions /><AgentSetupGrid /><AgentFirstPrompt agent="codex" /><Video src="/demo.mp4" caption="Connect your account" />`); |
| 46 | expect(text).toContain('npx skills add ComposioHQ/composio --skill composio'); |
| 47 | expect(text).toContain('Use the $composio skill'); |
| 48 | expect(text).toContain('/docs/agent-setup/clients#openai-codex'); |
| 49 | expect(text).toContain('[Video: Connect your account](/demo.mp4)'); |
| 50 | }); |
| 51 | }); |