import test from "node:test"; import assert from "node:assert/strict"; import { VIEW_CONTRACT, VIEW_NAMES } from "./names"; test("every name has a contract, and the contract names nothing else", () => { assert.deepEqual(Object.keys(VIEW_CONTRACT).sort(), [...VIEW_NAMES].sort()); }); test("the names are unique", () => { assert.equal(new Set(VIEW_NAMES).size, VIEW_NAMES.length); }); // The one view that may not construct. If this flips, /api/view/pulse has // stopped being the cheap change-token the whole UI polls, and e2e/pulse.spec.ts // (< 250 ms, no corpus contact) is the next thing to go red. test("pulse observes; every other view constructs", () => { assert.equal(VIEW_CONTRACT.pulse, "observe"); for (const name of VIEW_NAMES) { if (name === "pulse") continue; assert.equal(VIEW_CONTRACT[name], "construct", `${name} may construct`); } }); // A `/api/test/*` route is unauthenticated AND mutating; the dispatcher has no // guard, so the only thing standing between the two is this tuple. test("no test-harness route is a view", () => { for (const name of VIEW_NAMES) { assert.equal(/test/i.test(name), false, `${name} smells like the harness`); } });