1import { STARTER_FILES } from "../package/starter_template.ts";2import { listOverlayFiles, NEW_FILES, OVERLAY_ROOT, VERSION_PLACEHOLDER } from "./demo_overlay.ts";3import { join } from "node:path";45function assert(condition: unknown, message: string): asserts condition {6 if (!condition) throw new Error(message);7}89Deno.test("every overlay file shadows a starter file or is allowlisted", async () => {10 const overlayFiles = await listOverlayFiles();11 assert(overlayFiles.length > 0, "the demo overlay must not be empty");12 const starter = new Set(STARTER_FILES);13 const orphans = overlayFiles.filter(14 (path) => !starter.has(path) && !NEW_FILES.includes(path),15 );16 assert(17 orphans.length === 0,18 `overlay files without a starter counterpart (rename them with the starter ` +19 `or add them to NEW_FILES): ${orphans.join(", ")}`,20 );21});2223Deno.test("allowlisted new files exist in the overlay", async () => {24 const overlayFiles = new Set(await listOverlayFiles());25 const missing = NEW_FILES.filter((path) => !overlayFiles.has(path));26 assert(missing.length === 0, `NEW_FILES entries missing from the overlay: ${missing.join(", ")}`);27});2829Deno.test("the demo landing page stamps the released version", async () => {30 const index = await Deno.readTextFile(join(OVERLAY_ROOT, "src/pages/index.astro"));31 assert(32 index.includes(VERSION_PLACEHOLDER),33 `src/pages/index.astro must carry ${VERSION_PLACEHOLDER} so visitors can see ` +34 `which release produced the demo`,35 );36});3738Deno.test("the demo uses the starter's durable notice surface", async () => {39 const incidents = await Deno.readTextFile(40 join(OVERLAY_ROOT, "src/islands/use-incidents.ts"),41 );42 const board = await Deno.readTextFile(43 join(OVERLAY_ROOT, "src/islands/IncidentBoard.tsx"),44 );45 assert(incidents.includes("s.notice<Incident>"), "incident effects must enqueue durable notices");46 assert(47 !incidents.includes("publishNotice") && !incidents.includes("useIncidentNotice"),48 "the overlay must not restore the hand-rolled in-memory notice channel",49 );50 assert(board.includes("<Notices"), "the incident board must render the durable notice queue");51});