From 927eb51154855aa0939de94c950e047f4148bd51 Mon Sep 17 00:00:00 2001 From: 0thernet Date: Sat, 29 Aug 2026 13:31:51 -0400 Subject: [PATCH] test(site): bind install link to README heading --- site/tests/source.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/site/tests/source.test.ts b/site/tests/source.test.ts index a0636d7..589e1c4 100644 --- a/site/tests/source.test.ts +++ b/site/tests/source.test.ts @@ -7,6 +7,14 @@ const site = join(import.meta.dir, ".."); const read = async (path: string): Promise => await readFile(join(site, path), "utf8"); +function githubHeadingFragment(heading: string): string { + return heading + .trim() + .toLocaleLowerCase("en-US") + .replace(/[^\p{L}\p{N}\s-]/gu, "") + .replace(/\s+/gu, "-"); +} + function record(value: unknown, label: string): Readonly> { if (typeof value !== "object" || value === null || Array.isArray(value)) { throw new TypeError(`${label} must be an object.`); @@ -130,6 +138,22 @@ describe("Oh site source contract", () => { expect(home).toContain('className="text-action" href="/spec"'); }); + test("links the install action to an existing README heading", async () => { + const [home, readme] = await Promise.all([ + read("app/page.tsx"), + readFile(join(site, "..", "README.md"), "utf8"), + ]); + const installLink = home.match( + /href="https:\/\/github\.com\/hraness\/oh#([^"#]+)"/u, + ); + const installFragment = installLink?.[1] ?? ""; + const readmeFragments = [...readme.matchAll(/^#{1,6}\s+(.+?)\s*#*$/gmu)] + .map(([, heading]) => githubHeadingFragment(heading ?? "")); + + expect(installFragment).toBe("install-and-first-run"); + expect(readmeFragments).toContain(installFragment); + }); + test("derives public contract identity, version, and status from mirrored data", async () => { const [home, specification] = await Promise.all([ read("app/page.tsx"),