Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 2ef48072184301471ac7a91432b675b0fb1c4023
parent 1841cb88e384d138b364ad8568cdfb5102d28612
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 29 Oct 2026 00:14:36 -0400

umtool: e2e for the module panel, the single-layer preview, the look presets and modules apply

modules.spec.ts over two fixtures (modules-fixture.mjs): a module switched on,
filled through the list editor and off; a refused save; a chapter at a clip the
cut does not hold; Preview alone (the route and the button); a preset named
from the panel, read through, refused and removed from a terminal; umtool
modules apply --dry-run and for real.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/e2e/fixtures/make-fixture.mjs | 3+++
Aumtool/e2e/fixtures/modules-fixture.mjs | 46++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/e2e/modules.spec.ts | 218+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 267 insertions(+), 0 deletions(-)

diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -39,6 +39,7 @@ import { makeRunTraceFixture } from "./run-trace-fixture.mjs"; import { makeClipsSuggestFixture } from "./clips-suggest-fixture.mjs"; import { makeVideoAssistFixture } from "./video-assist-fixture.mjs"; import { makeKnobsFixture } from "./knobs-fixture.mjs"; +import { makeModulesFixture } from "./modules-fixture.mjs"; import { makeMarksFixture } from "./marks-fixture.mjs"; import { makeLivePreviewFixture } from "./live-preview-fixture.mjs"; import { makePlayCutFixture } from "./play-cut-fixture.mjs"; @@ -1853,6 +1854,8 @@ makeClipsSuggestFixture({ reports, manifest, cachedWindow: path.join(REPORT, "ou makeVideoAssistFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // Video knobs (plans/video-knobs-ui.md): Count & stamp, Audio, Make variants, Sync and the Markers editor (knobs.spec.ts). makeKnobsFixture({ reports, manifest, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); +// Release 39, the video modules: the generic module panel, the single-layer preview, the look presets (modules.spec.ts). +makeModulesFixture({ reports, manifest, deckManifest }); // Marks (plans/clip-marks.md): the clip editor's Marks box -- add at the playhead, verdict, Shift+S/M, remove (marks.spec.ts). makeMarksFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), cues: CUES.vid1 }); // The clip editor's live preview and Render this clip (plans/live-preview.md, live-preview.spec.ts). diff --git a/umtool/e2e/fixtures/modules-fixture.mjs b/umtool/e2e/fixtures/modules-fixture.mjs @@ -0,0 +1,46 @@ +// What modules.spec.ts edits (release 39, the video modules): +// +// modules-fixture the deck on (make-fixture.mjs deckManifest), three +// clips, a then-and-now pair (c01 → c02) and a status +// ledger row -- the generic module panel: on/off, +// a list editor, a refused save, the single-layer +// preview (pair, chapter) +// modules-preset-fixture NO chrome of its own, a module-config.json beside +// it -- the look preset (the panel's list and +// `umtool preset apply`) and `umtool modules apply` +// +// Synthetic, like every fixture. +import { mkdirSync, writeFileSync } from "node:fs"; +import path from "node:path"; + +const clip = (id, start) => ({ type: "clip", id, video: "vid1", start, end: start + 3, cite: start, section: 0, lock: true, quote: "and because" }); + +/** @param {{ reports: string, manifest: Function, deckManifest: Function }} o */ +export function makeModulesFixture({ reports, manifest, deckManifest }) { + const dir = path.join(reports, "modules-fixture"); + mkdirSync(dir, { recursive: true }); + const m = deckManifest("modules-fixture", "The Modules Fixture", [clip("c01", 3), clip("c02", 9), clip("c03", 0)]); + m.render.chrome = { + ...m.render.chrome, + pair: { pairs: [{ topic: "The opening", then: { clip: "c01", date: "2012-09-29" }, now: { clip: "c02", date: "2026-02-27" }, caption: "The same opening, renamed." }] }, + status: { items: [{ item: "The lawsuit", announced: { clip: "c01", date: "2019-06-01" }, outcome: "no follow-up found", evidence: ["c01", "c03"] }] }, + }; + writeFileSync(path.join(dir, "video.manifest.json"), JSON.stringify(m, null, 2) + "\n"); + + const pdir = path.join(reports, "modules-preset-fixture"); + mkdirSync(pdir, { recursive: true }); + const p = manifest("modules-preset-fixture", "The Modules Preset Fixture", { siteOrigin: "https://archive.example" }, [clip("c01", 3), clip("c02", 9)]); + writeFileSync(path.join(pdir, "video.manifest.json"), JSON.stringify(p, null, 2) + "\n"); + writeFileSync( + path.join(pdir, "module-config.json"), + JSON.stringify({ + preset: "plain-deck", + modules: { + shell: { title: "Not mapped" }, + chapter: [{ atClip: "c02", title: "Part two", subtitle: "the second clip" }], + pair: [{ then: { clip: "c01", date: "2012" }, now: { clip: "c02", date: "2026-02" }, caption: "then and now" }], + }, + }, null, 2) + "\n", + ); + return { dir, pdir }; +} diff --git a/umtool/e2e/modules.spec.ts b/umtool/e2e/modules.spec.ts @@ -0,0 +1,218 @@ +import { test, expect, type APIRequestContext, type Page } from "@playwright/test"; +import { execFileSync, spawnSync } from "node:child_process"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// THE VIDEO MODULES (release 39): the generic module panel in the Media tab +// (components/projects/ModulesPanel.tsx), drawn from each module's `ui` +// descriptor and writing through the writers (PUT /api/report/modules); the +// single-layer preview (POST /api/report/chrome/preview { layers }); the look +// presets (the panel's list, `umtool preset apply`) and `umtool modules +// apply` (a module-config.json onto the cut). +// +// modules-fixture the deck on, three clips, a pair and a status row +// modules-preset-fixture no chrome of its own, a module-config.json beside it +// +// The deck refuses to draw without its faces: the preview test skips on a +// machine make-fixture.mjs found no font on, as onscreen.spec.ts does. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const UMTOOL = path.join(HERE, ".."); +const FIXTURE = path.join(UMTOOL, ".e2e-song"); +const PROJECT = "reports/modules-fixture"; +const DIR = path.join(FIXTURE, "reports", "modules-fixture"); +const PRESET_PROJECT = "reports/modules-preset-fixture"; +const PRESET_DIR = path.join(FIXTURE, "reports", "modules-preset-fixture"); +const enc = encodeURIComponent; + +const cliEnv = { + ...process.env, + SONG_REPORTS_DIR: path.join(FIXTURE, "reports"), + SONG_DIR: path.join(FIXTURE, "data"), + CHANNELS_DIR: path.join(FIXTURE, "channels"), + UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), + UMTOOL_MEDIA_DIR: "", +}; +const umtool = (args: string[]) => spawnSync("node", ["bin/umtool.mjs", ...args], { cwd: UMTOOL, encoding: "utf8", env: cliEnv }); + +type Manifest = { preset?: string; render: Record<string, any>; timeline: { id: string; claim?: unknown }[] }; +const readManifest = (dir = DIR): Manifest => JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")); + +async function modulesState(request: APIRequestContext, project = PROJECT) { + const r = await request.get(`/api/report/modules?project=${enc(project)}`); + expect(r.ok(), await r.text()).toBeTruthy(); + return (await r.json()) as { token: string; preset: string | null; presets: { name: string }[]; modules: { id: string; enabled: boolean; fields: Record<string, unknown>; effective: Record<string, unknown>; problems: string[] }[] }; +} + +async function putModule(request: APIRequestContext, body: Record<string, unknown>, project = PROJECT) { + const { token } = await modulesState(request, project); + return request.put("/api/report/modules", { data: { project, token, ...body } }); +} + +async function openPanel(page: Page, project = PROJECT) { + await page.goto(urls.section(project, "onscreen")); + const panel = page.getByTestId("modules-panel"); + await expect(panel.getByTestId("module-pair")).toBeAttached({ timeout: 60_000 }); + return panel; +} + +async function openModule(page: Page, id: string) { + const card = page.getByTestId(`module-${id}`); + await card.locator("summary").click(); + await expect(card).toHaveAttribute("open", ""); + return card; +} + +// workers: 1, not fully parallel (playwright.config.ts): the tests run in +// file order, and the later ones start from the state the earlier leave. + +test.beforeEach(() => { + test.setTimeout(120_000); +}); + +test("the panel draws every module from its descriptor, and a module is switched on, filled and off through the writers", async ({ page, request }) => { + // From a known state: no chapters. + expect((await putModule(request, { module: "chapter", enabled: false })).ok() || true).toBeTruthy(); + const panel = await openPanel(page); + for (const id of ["pair", "chapter", "status", "finale", "intro", "counter", "shell", "rail", "stamp"]) { + await expect(panel.getByTestId(`module-${id}`)).toBeAttached(); + } + await expect(panel.getByTestId("module-state-chapter")).toHaveText("off"); + await expect(panel.getByTestId("module-state-pair")).toHaveText("on"); + + const card = await openModule(page, "chapter"); + await card.getByTestId("module-toggle-chapter").check(); + await expect(panel.getByTestId("module-state-chapter")).toHaveText("on"); + await expect.poll(() => readManifest().render.chrome.chapter).toEqual({ list: [] }); + + // A row of the list editor, its clip from the cut's clips, saved. + await card.getByTestId("module-field-chapter-list-add").click(); + await card.getByTestId("module-field-chapter-list-0-at").fill("c02"); + await card.getByTestId("module-field-chapter-list-0-title").fill("Part two"); + await card.getByTestId("module-field-chapter-list-0-date").fill("2020-10"); + await card.getByTestId("module-save-chapter").click(); + await expect(card.getByTestId("module-status-chapter")).toHaveText("saved"); + await expect.poll(() => readManifest().render.chrome.chapter).toEqual({ list: [{ at: "c02", title: "Part two", date: "2020-10" }] }); + + // A scalar field: the pair strip to the top. + const pair = await openModule(page, "pair"); + await pair.getByTestId("module-field-pair-position").selectOption("top"); + await pair.getByTestId("module-save-pair").click(); + await expect(pair.getByTestId("module-status-pair")).toHaveText("saved"); + await expect.poll(() => readManifest().render.chrome.pair.position).toBe("top"); + // The rest of the pair as it was. + expect(readManifest().render.chrome.pair.pairs[0].then.clip).toBe("c01"); + + // Off: the object removed, nothing else of the deck moved. + await card.getByTestId("module-toggle-chapter").uncheck(); + await expect(panel.getByTestId("module-state-chapter")).toHaveText("off"); + await expect.poll(() => "chapter" in readManifest().render.chrome).toBe(false); + expect(readManifest().render.chrome.layout).toBe("deck"); +}); + +test("a save the build would refuse is refused with the build's sentence, and the manifest is untouched", async ({ page }) => { + const before = JSON.stringify(readManifest().render.chrome.status); + await openPanel(page); + const card = await openModule(page, "status"); + await card.getByTestId("module-field-status-rows").fill("12"); + await card.getByTestId("module-save-status").click(); + await expect(card.getByTestId("module-errors-status")).toContainText("render.chrome.status.rows"); + expect(JSON.stringify(readManifest().render.chrome.status)).toBe(before); +}); + +test("a chapter at a clip the cut does not hold is refused by the writer", async ({ request }) => { + const r = await putModule(request, { module: "chapter", fields: { list: [{ at: "nope", title: "Gone" }] } }); + expect(r.status()).toBe(400); + expect(JSON.stringify(await r.json())).toContain("no timeline entry is nope"); + const off = await putModule(request, { module: "chapter", enabled: false }); + expect(off.ok() || off.status() === 400).toBeTruthy(); +}); + +test("Preview alone composes one module's page by itself; the files route serves it", async ({ page, request }) => { + test.skip(!readManifest().render.fontRegular, "the deck refuses to draw without its faces, and make-fixture.mjs found no font on this machine"); + // The route: a whole-cut layer (pair) and a window layer (chapter), alone. + expect((await putModule(request, { module: "chapter", enabled: true, fields: { list: [{ at: "c02", title: "Part two" }] } })).ok()).toBeTruthy(); + const res = await request.post("/api/report/chrome/preview", { data: { project: PROJECT, layers: ["pair", "chapter", "subtitle", "threads"] } }); + expect(res.ok(), await res.text()).toBeTruthy(); + const j = (await res.json()) as { layers: { id: string; region?: string; src?: string; off?: string; windows?: { segment: string; src?: string }[] }[] }; + const by = Object.fromEntries(j.layers.map((l) => [l.id, l])); + expect(by.pair.src).toContain("pair-preview/index.html"); + expect(by.chapter.windows?.[0]?.segment).toBe("c02"); + expect(by.chapter.windows?.[0]?.src).toContain("chapter-preview-c02/index.html"); + expect(by.subtitle.region).toBe("deck"); + expect(by.threads.off).toBeTruthy(); + const html = await (await request.get(by.pair.src!)).text(); + expect(html).toContain('id="pair-data"'); + expect(html).toContain("The same opening, renamed."); + expect(html).not.toContain('id="deck-data"'); + // A window page another cut's entry names is not served. + expect((await request.get(by.pair.src!.replace("pair-preview/", "chapter-preview-zz/"))).status()).toBe(404); + + // The panel's button: the module's own iframe over a scaled frame. + await openPanel(page); + const card = await openModule(page, "pair"); + await card.getByTestId("module-preview-pair").click(); + await expect(card.getByTestId("module-preview-iframe")).toHaveAttribute("src", /pair-preview\/index\.html/); + await expect(card.getByTestId("module-preview-scrub")).toBeVisible(); + await putModule(request, { module: "chapter", enabled: false }); +}); + +test("a look preset is the layer under the manifest: named from the panel, read through, removed from a terminal", async ({ page, request }) => { + const r0 = umtool(["preset", "apply", "none", PRESET_PROJECT]); + expect(r0.status, r0.stderr).toBe(0); + const s0 = await modulesState(request, PRESET_PROJECT); + expect(s0.presets.map((p) => p.name)).toEqual(expect.arrayContaining(["huck-deck", "plain-deck", "archive-catalog"])); + expect(s0.modules.find((m) => m.id === "intro")!.enabled).toBe(false); + + await openPanel(page, PRESET_PROJECT); + await page.getByTestId("modules-preset").selectOption("plain-deck"); + await expect(page.getByTestId("modules-preset-status")).toContainText("plain-deck"); + await expect.poll(() => readManifest(PRESET_DIR).preset).toBe("plain-deck"); + // Nothing of the preset copied in: the manifest's render is as it was. + expect(readManifest(PRESET_DIR).render.chrome).toBeUndefined(); + // Read through: the intro and the deck are the preset's, as the build reads them. + const s1 = await modulesState(request, PRESET_PROJECT); + expect(s1.modules.find((m) => m.id === "intro")!.enabled).toBe(true); + expect(s1.modules.find((m) => m.id === "intro")!.effective.style).toBe("boot-dark"); + expect(s1.modules.find((m) => m.id === "subtitle")!.effective.parts).toEqual(["channel", "title", "date", "clock"]); + // A chrome save over the preset is whole: the writer reads the deck from it. + expect((await putModule(request, { module: "pair", enabled: true }, PRESET_PROJECT)).ok()).toBeTruthy(); + expect(readManifest(PRESET_DIR).render.chrome).toEqual({ pair: { pairs: [] } }); + + const r1 = umtool(["preset", "list", "--json"]); + expect(JSON.parse(r1.stdout).map((p: { name: string }) => p.name)).toContain("archive-catalog"); + const bad = umtool(["preset", "apply", "no-such-preset", PRESET_PROJECT]); + expect(bad.status).toBe(1); + expect(bad.stderr).toContain('no preset "no-such-preset"'); + // Removed: the chrome named only what it changed from the preset, so the cut + // over no preset would not build -- refused, the preset kept. + const r2 = umtool(["preset", "apply", "none", PRESET_PROJECT]); + expect(r2.status).toBe(1); + expect(readManifest(PRESET_DIR).preset).toBe("plain-deck"); + expect((await putModule(request, { module: "pair", enabled: false }, PRESET_PROJECT)).ok()).toBeTruthy(); + const r3 = umtool(["preset", "apply", "none", PRESET_PROJECT]); + expect(r3.status, r3.stderr).toBe(0); + expect(readManifest(PRESET_DIR).preset).toBeUndefined(); +}); + +test("umtool modules apply maps a module-config.json onto the cut, listing what has no home", async () => { + const dry = umtool(["modules", "apply", PRESET_PROJECT, "--dry-run", "--json"]); + expect(dry.status, dry.stderr).toBe(0); + const plan = JSON.parse(dry.stdout); + expect(plan.patch.preset).toBe("plain-deck"); + expect(plan.patch.render.chrome.chapter.list[0]).toEqual({ at: "c02", title: "Part two", subtitle: "the second clip" }); + expect(plan.unmapped.some((u: string) => u.startsWith("modules.shell.title"))).toBe(true); + expect(readManifest(PRESET_DIR).preset).toBeUndefined(); + + const run = umtool(["modules", "apply", PRESET_PROJECT]); + expect(run.status, run.stderr).toBe(0); + const m = readManifest(PRESET_DIR); + expect(m.preset).toBe("plain-deck"); + expect(m.render.chrome.pair.pairs[0].now).toEqual({ clip: "c02", date: "2026-02" }); + // Back as it was, through the same writers. + execFileSync("node", ["bin/umtool.mjs", "preset", "apply", "plain-deck", PRESET_PROJECT], { cwd: UMTOOL, env: cliEnv }); +});