| 1 | import assert from "node:assert/strict"; |
| 2 | import { readFile } from "node:fs/promises"; |
| 3 | import test from "node:test"; |
| 4 | |
| 5 | const source = (path) => readFile(new URL(path, import.meta.url), "utf8"); |
| 6 | |
| 7 | test("primary site pages share the same header component", async () => { |
| 8 | const pages = await Promise.all([ |
| 9 | source("../pages/index.astro"), |
| 10 | source("../pages/docs.astro"), |
| 11 | source("../pages/skills.astro"), |
| 12 | source("../components/ChangelogPage.astro"), |
| 13 | source("../pages/404.astro"), |
| 14 | ]); |
| 15 | |
| 16 | for (const page of pages) { |
| 17 | assert.match(page, /<SiteHeader\b/); |
| 18 | assert.doesNotMatch(page, /<header class="nav/); |
| 19 | } |
| 20 | }); |
| 21 | |
| 22 | test("the shared header owns the complete global navigation", async () => { |
| 23 | const header = await source("../components/SiteHeader.astro"); |
| 24 | |
| 25 | for (const id of ["features", "surfaces", "skills", "community", "docs", "changelog"]) { |
| 26 | assert.match(header, new RegExp(`id: '${id}'`)); |
| 27 | } |
| 28 | |
| 29 | assert.doesNotMatch(header, /id: 'start'/); |
| 30 | assert.equal((header.match(/#start/g) ?? []).length, 1); |
| 31 | assert.match(header, /nav-sign-in/); |
| 32 | assert.match(header, /nav-install/); |
| 33 | assert.match(header, /class="nav-github"/); |
| 34 | assert.match(header, /https:\/\/github[.]com\/esengine\/DeepSeek-Reasonix/); |
| 35 | assert.match(header, /target="_blank"/); |
| 36 | assert.match(header, /aria-label="Reasonix GitHub repository"/); |
| 37 | }); |
| 38 |