4
5
const read = (path: string) => Bun.file(new URL(`../../${path}`, import.meta.url)).text();
6
7
+/**
8
+ * The 7 auth guides live in the Authentication folder; shared connections is a
9
+ * session capability and lives under Extend sessions.
10
+ */
11
+const AUTH_GUIDES = [
12
+ 'manually-authenticating',
13
+ 'managing-multiple-connected-accounts',
14
+ 'importing-existing-connections',
15
+ 'custom-app-vs-managed-app',
16
+ 'programmatic-auth-configs',
17
+ 'controlling-scopes',
18
+ 'white-labeling-authentication',
19
+];
20
+
21
+const GUIDE_URLS = [
22
+ ...AUTH_GUIDES.map(guide => `/docs/authentication/${guide}`),
23
+ '/docs/extending-sessions/shared-connections',
24
+];
25
+
26
describe('getting-started routing policy', () => {
27
test('publishes native plugins for both supported agent hosts', async () => {
28
const plugins = await read('content/docs/agent-plugins.mdx');
57
read('content/docs/authentication/meta.json'),
58
read('content/docs/extending-sessions/meta.json'),
59
]);
41
- const authGuides = [
42
- 'manually-authenticating',
43
- 'managing-multiple-connected-accounts',
44
- 'importing-existing-connections',
45
- 'custom-app-vs-managed-app',
46
- 'programmatic-auth-configs',
47
- 'controlling-scopes',
48
- 'white-labeling-authentication',
49
- ];
60
const authPages = JSON.parse(authMeta).pages as string[];
61
const sessionPages = JSON.parse(sessionsMeta).pages as string[];
62
53
- for (const guide of authGuides) {
63
+ for (const guide of AUTH_GUIDES) {
64
expect(authentication).toContain(`href="/docs/authentication/${guide}"`);
65
expect(authPages).toContain(guide);
66
}
68
expect(authentication).toContain('href="/docs/extending-sessions/shared-connections"');
69
expect(sessionPages).toContain('shared-connections');
70
});
71
+
72
+ /**
73
+ * Asserts the generated bytes, not the meta.json inputs. These guides used to
74
+ * be listed in llms.txt by a hardcoded `AUTHENTICATION_GUIDE_URLS` constant
75
+ * because they had been dropped from the page tree; they are emitted by the
76
+ * page-tree walk now, so a regression in that walk — not just in the meta
77
+ * files — has to fail something.
78
+ */
79
+ test('emits every authentication guide into llms.txt exactly once', async () => {
80
+ const { GET } = await import('../../app/llms.txt/route');
81
+ const llms = await (await GET()).text();
82
+
83
+ for (const url of GUIDE_URLS) {
84
+ const occurrences = llms.split(`https://docs.composio.dev${url}.md`).length - 1;
85
+ expect(occurrences, `${url} appears ${occurrences}x in llms.txt`).toBe(1);
86
+ }
87
+ });
88
+
89
+ test('files the authentication guides under Core concepts, not a trailing section', async () => {
90
+ const { GET } = await import('../../app/llms.txt/route');
91
+ const lines = (await (await GET()).text()).split('\n');
92
+
93
+ const sectionOf = (url: string) => {
94
+ const index = lines.findIndex(line => line.endsWith(`${url}.md`));
95
+ expect(index, `${url} missing from llms.txt`).toBeGreaterThan(-1);
96
+ const preceding = lines.slice(0, index);
97
+ const last = (prefix: string) => preceding.findLast(line => line.startsWith(prefix));
98
+ return [last('## '), last('### ')];
99
+ };
100
+
101
+ for (const guide of AUTH_GUIDES) {
102
+ expect(sectionOf(`/docs/authentication/${guide}`)).toEqual([
103
+ '## Core concepts',
104
+ '### Authentication',
105
+ ]);
106
+ }
107
+
108
+ expect(sectionOf('/docs/extending-sessions/shared-connections')).toEqual([
109
+ '## Guides',
110
+ '### Extend sessions',
111
+ ]);
112
+ expect(lines).not.toContain('## Authentication guides');
113
+ });
114
});