| 1 | import assert from "node:assert/strict"; |
| 2 | import { readFileSync, existsSync } from "node:fs"; |
| 3 | import { test } from "node:test"; |
| 4 | import { FEATURES } from "../apps/web/app/lib/features.ts"; |
| 5 | |
| 6 | const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8").replaceAll("\r\n", "\n"); |
| 7 | |
| 8 | test("llms.txt follows the heading and file-list format and preserves the detailed guide", () => { |
| 9 | const index = read("apps/web/public/llms.txt"); |
| 10 | assert.match(index, /^# g1t\n\n> /); |
| 11 | for (const section of index.split(/^## .+$/m).slice(1)) { |
| 12 | const lines = section.trim().split("\n").filter(Boolean); |
| 13 | assert.ok(lines.length > 0); |
| 14 | for (const line of lines) assert.match(line, /^- \[[^\]]+\]\(https:\/\/[^)]+\)(: .+)?$/); |
| 15 | } |
| 16 | for (const url of ["/features", "/developers", "/agents.md", "/openapi.json", "/reference/versioning.md", "/settings/tokens"]) assert.ok(index.includes(url), url); |
| 17 | assert.match(read("apps/web/public/agents.md"), /## Set someone up/); |
| 18 | }); |
| 19 | |
| 20 | test("features is routed, discoverable on desktop and mobile, and has real documentation targets", () => { |
| 21 | assert.match(read("apps/web/app/routes.ts"), /route\("features", "routes\/features.tsx"\)/); |
| 22 | assert.match(read("apps/web/app/routes/sitemap-xml.ts"), /"\/features"/); |
| 23 | const header = read("apps/web/app/components/public-header.tsx"); |
| 24 | assert.match(header, /<HeaderLink to="\/features">Features<\/HeaderLink>/); |
| 25 | assert.match(header, /<Link to="\/features">/); |
| 26 | assert.equal(new Set(FEATURES.map((f) => f.id)).size, FEATURES.length); |
| 27 | for (const feature of FEATURES) for (const link of feature.links) { |
| 28 | if (!link.href.startsWith("https://docs.g1t.sh/")) continue; |
| 29 | const slug = new URL(link.href).pathname.replace(/\/$/, ""); |
| 30 | assert.ok(["md", "mdx"].some((ext) => existsSync(new URL(`../apps/docs/src/content/docs${slug}.${ext}`, import.meta.url))), link.href); |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | test("built developer pages have branded headings, canonical URLs and Markdown counterparts", () => { |
| 35 | for (const slug of ["reference/developers", "reference/versioning", "reference/api", "reference/mcp", "guides/authentication"]) { |
| 36 | const html = read(`apps/docs/dist/${slug}/index.html`); |
| 37 | assert.match(html, /<title>g1t /); |
| 38 | assert.match(html, /<h1[^>]*[^]*?>g1t /); |
| 39 | assert.ok(html.includes(`https://docs.g1t.sh/${slug}/`)); |
| 40 | assert.match(read(`apps/docs/dist/${slug}.md`), /^# g1t /); |
| 41 | } |
| 42 | const policy = read("apps/docs/dist/reference/versioning.md"); |
| 43 | for (const text of ["X-G1t-Api-Version", "Deprecation", "Sunset", 'rel="deprecation"', "No REST version is currently deprecated"]) assert.ok(policy.includes(text), text); |
| 44 | }); |