| 1 | import assert from "node:assert/strict"; |
| 2 | import { readFile } from "node:fs/promises"; |
| 3 | import { test } from "node:test"; |
| 4 | |
| 5 | const css = await readFile(new URL("../styles/changelog.css", import.meta.url), "utf8"); |
| 6 | const component = await readFile(new URL("../components/ChangelogPage.astro", import.meta.url), "utf8"); |
| 7 | const versionPage = await readFile(new URL("../pages/changelog/[version].astro", import.meta.url), "utf8"); |
| 8 | |
| 9 | test("historical changelog styling remains readable", () => { |
| 10 | assert.doesNotMatch(css, /var\(--(?:muted|paper)\)/); |
| 11 | assert.match(css, /\.release-channel\s*\{/); |
| 12 | }); |
| 13 | |
| 14 | test("every release uses the version-ledger hero", () => { |
| 15 | assert.doesNotMatch(component, /isThematicTitle|isThematic/); |
| 16 | assert.doesNotMatch(component, /release-hero--compact|release-hero__actions|<blockquote>/); |
| 17 | assert.match(component, /<header class="release-hero">/); |
| 18 | assert.match(component, /<h1>Reasonix v\{release\.version\}<\/h1>/); |
| 19 | assert.match(component, /<p class="release-lede">/); |
| 20 | assert.doesNotMatch(css, /\.release-hero--compact|\.release-hero__actions|\.release-hero blockquote/); |
| 21 | }); |
| 22 | |
| 23 | test("targeted releases split Desktop and CLI updates without removing legacy sections", () => { |
| 24 | assert.match(component, /release\.targetingVersion === 1/); |
| 25 | assert.match(component, /id=\{target\.id\}/); |
| 26 | assert.match(component, /Desktop updates/); |
| 27 | assert.match(component, /CLI updates/); |
| 28 | assert.match(component, /CLI users may skip this version if preferred/); |
| 29 | assert.match(component, /<section id="highlights"/); |
| 30 | assert.match(css, /\.release-target-section__summary/); |
| 31 | assert.match(css, /\.release-item-targets/); |
| 32 | }); |
| 33 | |
| 34 | test("changelog has one official navigation and marks archives noindex", () => { |
| 35 | assert.doesNotMatch(component, /release-channel-tabs/); |
| 36 | assert.match(component, /Historical archive/); |
| 37 | assert.match(component, /noindex=\{isPreview\}/); |
| 38 | }); |
| 39 | |
| 40 | test("reviewed exact-version routes redirect safely until their publication marker exists", () => { |
| 41 | assert.match(versionPage, /publishedReleases/); |
| 42 | assert.match(versionPage, /publishedVersions\.has\(release\.version\)/); |
| 43 | assert.match(versionPage, /if \(!published\)/); |
| 44 | assert.match(versionPage, /return Astro\.redirect/); |
| 45 | assert.match(versionPage, /Astro\.redirect\('\/changelog\/'\)/); |
| 46 | }); |
| 47 |