1
import { expect, test } from 'bun:test';
2
-import { GET, parseOgParams } from '../../app/api/og/route';
2
+import { GET, parseOgParams, toolkitCardTitle } from '../../app/api/og/route';
3
import { getOgImageUrl } from '../../lib/source';
4
+import { HOME_OG_DESCRIPTION } from '../../lib/toolkit-count';
5
6
async function expectPng(url: string) {
7
const response = await GET(new Request(url));
33
});
34
35
test('the URL builder names the section and forwards extras', () => {
35
- const home = new URL(getOgImageUrl('docs', [], 'Welcome', 'desc'));
36
+ // Both the root layout and the /docs index page build this URL; the home
37
+ // card ignores the page description so they agree and carry the live count.
38
+ const home = new URL(getOgImageUrl('docs', [], 'Welcome', 'page description'));
39
expect(home.searchParams.get('section')).toBe('home');
37
- expect(home.searchParams.get('description')).toBe('desc');
40
+ expect(home.searchParams.get('description')).toBe(HOME_OG_DESCRIPTION);
41
+ expect(HOME_OG_DESCRIPTION).toMatch(/^Build AI agents with [\d,]+\+ apps\./);
42
43
const changelog = new URL(getOgImageUrl('docs', ['changelog', '2026', '09', '04'], 'Title', 'Updates', { date: 'Sep 4, 2026' }));
44
expect(changelog.searchParams.get('section')).toBe('changelog');
80
await expectPng('https://docs.composio.dev/api/og?section=toolkits&title=GitHub&theme=light');
81
await expectPng('https://docs.composio.dev/api/og?section=home&theme=light');
82
});
83
+
84
+test('only catalog toolkit titles get the Toolkit suffix', () => {
85
+ expect(toolkitCardTitle('GitHub - Composio Toolkit')).toBe('GitHub Toolkit');
86
+ expect(toolkitCardTitle('Google Sheets - Composio Toolkit')).toBe('Google Sheets Toolkit');
87
+ expect(toolkitCardTitle('Toolkits')).toBe('Toolkits');
88
+ expect(toolkitCardTitle('Premium Tools')).toBe('Premium Tools');
89
+});