import { test } from "node:test"; import assert from "node:assert/strict"; import { NAV_GROUPS, NAV_LINKS } from "./nav"; // Run with: pnpm -C editor exec tsx --test "app/**/*.test.ts" // // The nav's arithmetic, not its looks. The IA doc's end state is FOUR GROUPS // and ELEVEN entries, and slice 5 reached it by folding the Sites group's five // satellites into /sites and the site's tabs. This test is what stops the // twelfth entry from being added beside them instead of under one of them. test("four groups, one noun each", () => { assert.deepEqual( NAV_GROUPS.map((g) => g.label), ["Corpus", "Operations", "Sites", "Machine"], ); }); // THIRTEEN, and the twelfth and thirteenth are recorded exceptions rather than // slips. The IA rule is "fold, do not add" and this test is where it is either // true or not — so the number moves only when a plan says why. /storage is a // Machine NOUN (a place the machine keeps bytes), not a fold of Cleanup (an // operation over bytes that already have a place); /tags is a Corpus NOUN (a // vocabulary over every channel and every site), which is precisely what it // stops being if it is folded under one site or one channel. See nav.ts's // header, plans/editor-operations-ia.md and plans/curated-tags.md. test("thirteen entries, every href distinct", () => { assert.equal(NAV_LINKS.length, 13); assert.equal(new Set(NAV_LINKS.map((l) => l.href)).size, 13); }); test("the Sites group is one entry", () => { const sites = NAV_GROUPS.find((g) => g.label === "Sites"); assert.deepEqual(sites?.links.map((l) => l.href), ["/sites"]); }); test("no retired route is in the nav", () => { const hrefs = new Set(NAV_LINKS.map((l) => l.href)); for (const retired of [ "/charts", "/aliases", "/deploy", "/build", "/homepage", "/jobs/active", "/jobs/queue", "/actionable", "/auto-queue", "/scheduler", ]) { assert.equal(hrefs.has(retired), false, `${retired} is retired`); } });