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});