Archilyzer · Source

archilyzer

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

commit 415b2cf8d4d6f6d891204127eaca70a2e73234a4
parent fd0db8b48694eefa2bdbf66e4f6d8833f541aa97
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 14:17:01 -0500

umtool: intro-play e2e -- the intro in Play, Present, the walk and the Cut tab editor

intro-play-fixture: the Play cut opening on a title-card intro with a sound of
its own (intro.wav, written by the fixture: the stand-in is not in git) and a
whole-cut version v1. A version whose patch carries the cut's own intro reads
as the cut's (introState), so on after off is not "its own intro".

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

Diffstat:
Aumtool/e2e/fixtures/intro-play-fixture.mjs | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/fixtures/make-fixture.mjs | 5+++++
Aumtool/e2e/intro-play.spec.ts | 139+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/introEdit.mjs | 9+++++++--
4 files changed, 203 insertions(+), 2 deletions(-)

diff --git a/umtool/e2e/fixtures/intro-play-fixture.mjs b/umtool/e2e/fixtures/intro-play-fixture.mjs @@ -0,0 +1,52 @@ +// THE INTRO, PLAYABLE (intro-play.spec.ts, lane intro-play): the Play cut (play-cut-fixture.mjs) opening on a +// title-card intro -- the project's title and its date (`generatedOn` 2026-10-29) over the brand -- with a sound of +// the project's own (intro.wav: a 4.2 s tone written here, so the stand-in, which is not in git, is never needed), +// and a whole-cut version v1 (a made take, its patch empty) whose intro the spec switches off and on. +// +// The spec WRITES (the intro's title, v1's patch): this fixture is its own. +// +// Synthetic, like every fixture. +import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import path from "node:path"; + +/** A mono 16-bit PCM WAV of `seconds` of a quiet 440 Hz tone. */ +export function toneWav(seconds, rate = 8000) { + const n = Math.round(seconds * rate); + const data = Buffer.alloc(n * 2); + for (let i = 0; i < n; i++) data.writeInt16LE(Math.round(Math.sin((2 * Math.PI * 440 * i) / rate) * 3000), i * 2); + const h = Buffer.alloc(44); + h.write("RIFF", 0); + h.writeUInt32LE(36 + data.length, 4); + h.write("WAVE", 8); + h.write("fmt ", 12); + h.writeUInt32LE(16, 16); + h.writeUInt16LE(1, 20); + h.writeUInt16LE(1, 22); + h.writeUInt32LE(rate, 24); + h.writeUInt32LE(rate * 2, 28); + h.writeUInt16LE(2, 32); + h.writeUInt16LE(16, 34); + h.write("data", 36); + h.writeUInt32LE(data.length, 40); + return Buffer.concat([h, data]); +} + +/** @param {{ reports: string, deckManifest: Function, cachedWindow: string, makePlayCutFixture: Function }} o */ +export function makeIntroPlayFixture({ reports, deckManifest, cachedWindow, makePlayCutFixture }) { + const { dir } = makePlayCutFixture({ reports, deckManifest, cachedWindow, name: "intro-play-fixture", title: "The Intro Play Fixture" }); + const file = path.join(dir, "video.manifest.json"); + const m = JSON.parse(readFileSync(file, "utf8")); + m.generatedOn = "2026-10-29"; + m.render.intro = { style: "title-card", sound: "intro.wav" }; + const text = JSON.stringify(m, null, 2) + "\n"; + writeFileSync(file, text); + writeFileSync(path.join(dir, "intro.wav"), toneWav(4.2)); + // A whole-cut version, made: its patch empty, so it opens on the cut's intro until the spec says otherwise. + mkdirSync(path.join(dir, "takes", "v1"), { recursive: true }); + writeFileSync( + path.join(dir, "takes", "v1", "take.json"), + JSON.stringify({ id: "v1", group: "takes", order: 2, label: "Version 1", kind: "different", preview: "preview.mp4", window: "full", style: null, patch: {}, seconds: 12, builtAt: "2026-11-01T10:00:00.000Z" }, null, 2) + "\n", + ); + writeFileSync(path.join(dir, "takes", "v1", "video.manifest.json"), text); + return { dir }; +} diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs @@ -65,6 +65,7 @@ import { makePlayPreloadFixture } from "./play-preload-fixture.mjs"; import { makePostComboFixture } from "./post-combo-fixture.mjs"; import { makeMediaScenesFixture } from "./media-scenes-fixture.mjs"; import { makeInstrumentsFixture } from "./instruments-fixture.mjs"; +import { makeIntroPlayFixture } from "./intro-play-fixture.mjs"; const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song"); const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song")); @@ -2080,6 +2081,10 @@ pt.timeline = pt.timeline.map((e) => (e.id === "k01" writeFileSync(ptFile, JSON.stringify(pt, null, 2) + "\n"); } +// THE INTRO, PLAYABLE (intro-play.spec.ts, lane intro-play): the Play cut opening on a title-card intro with a +// sound of its own, and a whole-cut version v1 the spec switches the intro off and on in. WRITABLE, its own. +makeIntroPlayFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), makePlayCutFixture }); + // The measure's instruments (instruments.spec.ts): the Play cut with the dial, the odometer and // the trail on, and a built schedule carrying a measure slice (instruments-fixture.mjs). await makeInstrumentsFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), makePlayCutFixture }); diff --git a/umtool/e2e/intro-play.spec.ts b/umtool/e2e/intro-play.spec.ts @@ -0,0 +1,139 @@ +import { test, expect, type Page } from "@playwright/test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import * as urls from "./urls"; + +// --------------------------------------------------------------------------- +// THE INTRO AS A REAL, PLAYABLE BLOCK (lane intro-play; operator, 8 Nov 2026: "more first-class intro support (view +// in play the cut)"; umtool/docs/knobs.md, "The intro, played and edited"): the cut's render.intro plays as the build +// draws it -- its own page (report-to-video intro.mjs introPageHtml, composed by POST /api/report/chrome/intro) and +// its sound -- in Play, as Present's first slide, first on the walk; and the Cut tab's intro row opens an editor whose +// live preview follows the unsaved knobs and whose Save writes the manifest. +// +// Fixture: e2e/fixtures/intro-play-fixture.mjs -- the Play cut opening on a title-card intro (the project's title, +// "29 October 2026"), its sound intro.wav, and a whole-cut version v1. WRITES (the title, v1's patch): its own. +// +// INTRO_SHOTS (a directory): the surfaces' screenshots at 1366×768 go there too. +// --------------------------------------------------------------------------- + +test.describe.configure({ mode: "serial" }); + +const PROJECT = "reports/intro-play-fixture"; +const DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song", "reports", "intro-play-fixture"); +const SHOTS = process.env.INTRO_SHOTS ?? null; +const manifest = () => JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")) as { render: { intro?: unknown } }; +const takeDoc = (id: string) => JSON.parse(readFileSync(path.join(DIR, "takes", id, "take.json"), "utf8")) as { patch: { render?: { intro?: unknown } } }; + +const shot = async (page: Page, name: string) => { + await page.screenshot({ path: test.info().outputPath(name) }); + if (SHOTS) await page.screenshot({ path: path.join(SHOTS, name) }); +}; + +test.beforeEach(async ({ page }) => { + test.setTimeout(120_000); + await page.setViewportSize({ width: 1366, height: 768 }); +}); + +test("Play opens on the intro as the build draws it -- its page, its words, its sound -- not a placeholder", async ({ page }) => { + await page.goto(urls.playHref(PROJECT, { clip: "brand-intro", at: 3.4 })); + const root = page.locator("[data-play-cut]"); + await expect(root).toHaveAttribute("data-play-item", "brand-intro", { timeout: 30_000 }); + const intro = page.locator('[data-play-intro="brand-intro"]'); + await expect(intro).toHaveAttribute("data-play-intro-ready", "1", { timeout: 30_000 }); + await expect(intro).toHaveAttribute("data-play-intro-style", "title-card"); + await expect(page.locator("[data-play-placeholder]")).toHaveCount(0); + const frame = page.frameLocator('[data-testid="play-intro-iframe"]'); + await expect(frame.locator('[data-k="tt"]')).toHaveText("The Intro Play Fixture"); + await expect(frame.locator('[data-k="tl0"]')).toHaveText("29 October 2026"); + // Its sound: the project's own file, through the intro route. + await expect(intro.locator("[data-play-intro-audio]")).toHaveAttribute("src", /\/api\/report\/chrome\/intro\?.*sound=1.*path=intro\.wav/); + const sound = await page.request.get(String(await intro.locator("[data-play-intro-audio]").getAttribute("src"))); + expect(sound.status()).toBe(200); + expect(sound.headers()["content-type"]).toBe("audio/wav"); + await shot(page, "intro-play.png"); + // Playing from the top: the sound runs with the clock, then the first clip takes over. + await page.goto(urls.playHref(PROJECT, { clip: "brand-intro", at: 0.2 })); + await expect(intro).toHaveAttribute("data-play-intro-ready", "1", { timeout: 30_000 }); + await page.locator("[data-play-toggle]").click(); + await expect(intro).toHaveAttribute("data-play-intro-sound", "playing", { timeout: 15_000 }); + await expect(root).toHaveAttribute("data-play-item", "c01", { timeout: 20_000 }); + await expect(intro).toHaveCount(0); +}); + +test("Present opens the deck on the intro slide, playing the build's page", async ({ page }) => { + await page.goto(urls.presentHref(PROJECT)); + const root = page.locator("[data-present]"); + await expect(root).toHaveAttribute("data-present-slide", "brand-intro", { timeout: 30_000 }); + await expect(root).toHaveAttribute("data-present-kind", "intro"); + await expect(page.locator('[data-present-cell]').first()).toHaveAttribute("data-present-cell", "brand-intro"); + const intro = page.locator('[data-testid="present-intro"]'); + await expect(intro).toHaveAttribute("data-play-intro-ready", "1", { timeout: 30_000 }); + await expect(page.frameLocator('[data-testid="present-intro-iframe"]').locator('[data-k="tt"]')).toHaveText("The Intro Play Fixture"); + await shot(page, "intro-present.png"); + await page.keyboard.press("ArrowRight"); + await expect(root).not.toHaveAttribute("data-present-slide", "brand-intro"); +}); + +test("the walk lists the intro first: the take walk's first row, and the walk's stops", async ({ page, request }) => { + await page.goto(urls.takeWalkHref(PROJECT, "v1")); + const rows = page.locator("[data-take-walk-clips] tbody tr"); + await expect(rows.first()).toHaveAttribute("data-take-walk-intro", "title-card"); + await expect(rows.first()).toContainText("watched, not judged"); + await expect(rows.first()).toContainText("29 October 2026"); + await expect(rows.nth(1)).toHaveAttribute("data-take-walk-clip", /c0\d/); + await shot(page, "intro-walk.png"); + const w = (await (await request.get(`/api/report/walk?project=${encodeURIComponent(PROJECT)}`)).json()) as { stops: string[]; intro: { style: string } | null; first: string | null }; + expect(w.stops[0]).toBe("brand-intro"); + expect(w.intro?.style).toBe("title-card"); + expect(w.first).not.toBe("brand-intro"); +}); + +test("the Cut tab's intro row: Edit opens the knobs and a live preview; a new title changes the preview, Save writes it; a version goes without", async ({ page }) => { + await page.goto(urls.projectHref(PROJECT, { tab: "cut" })); + const row = page.locator("[data-intro-row]"); + await expect(row).toHaveAttribute("data-intro-row", "on"); + await expect(row.locator("[data-intro-summary]")).toContainText("title-card", { timeout: 20_000 }); + await row.locator("[data-intro-edit]").click(); + const editor = page.locator("[data-intro-editor]"); + await expect(editor).toBeVisible(); + const preview = page.frameLocator('[data-testid="intro-editor-preview-iframe"]'); + await expect(page.locator('[data-testid="intro-editor-preview"]')).toHaveAttribute("data-play-intro-ready", "1", { timeout: 30_000 }); + await expect(preview.locator('[data-k="tt"]')).toHaveText("The Intro Play Fixture"); + await expect(editor.locator('[data-intro-field="style"]')).toHaveValue("title-card"); + + // A new title, unsaved: the preview follows it; the manifest does not. + await editor.locator('[data-intro-field="title"]').fill("A title of its own"); + await expect(preview.locator('[data-k="tt"]')).toHaveText("A title of its own", { timeout: 20_000 }); + expect((manifest().render.intro as { title?: string }).title).toBeUndefined(); + // A length the build refuses is said, and Save waits. + await editor.locator('[data-intro-field="seconds"]').fill("9"); + await expect(editor.locator("[data-intro-problems]")).toContainText("render.intro.seconds must be a number from 3.5 to 8", { timeout: 20_000 }); + await expect(editor.locator("[data-intro-save]")).toBeDisabled(); + await editor.locator('[data-intro-field="seconds"]').fill("5"); + await expect(editor.locator("[data-intro-problems]")).toHaveCount(0, { timeout: 20_000 }); + await shot(page, "intro-editor.png"); + await editor.locator("[data-intro-save]").click(); + await expect(editor.locator('[data-intro-said="ok"]')).toBeVisible(); + expect(manifest().render.intro).toEqual({ style: "title-card", sound: "intro.wav", title: "A title of its own", seconds: 5 }); + await expect(row.locator("[data-intro-summary]")).toContainText("A title of its own"); + + // A version without the intro: its patch's render.intro is null; the project's manifest keeps it. + const v1 = editor.locator('[data-intro-version="v1"]'); + await expect(v1).toBeChecked(); + await v1.uncheck(); + await expect(v1).not.toBeChecked({ timeout: 10_000 }); + expect(takeDoc("v1").patch.render?.intro).toBeNull(); + expect((manifest().render.intro as { title?: string }).title).toBe("A title of its own"); + await expect(row.locator("[data-intro-versions-off]")).toContainText("v1"); + // Play on that version opens on c01: no intro. + await page.goto(urls.playHref(PROJECT, { take: "v1" })); + await expect(page.locator("[data-play-cut]")).toHaveAttribute("data-play-item", "c01", { timeout: 30_000 }); + await expect(page.locator("[data-play-intro]")).toHaveCount(0); + // Back on: it opens on the cut's intro again. + await page.goto(urls.projectHref(PROJECT, { tab: "cut" })); + await page.locator("[data-intro-edit]").click(); + await page.locator('[data-intro-version="v1"]').check(); + await expect(page.locator('[data-intro-version="v1"]')).toBeChecked({ timeout: 10_000 }); + expect(takeDoc("v1").patch.render?.intro).toEqual(manifest().render.intro); +}); diff --git a/umtool/lib/report/introEdit.mjs b/umtool/lib/report/introEdit.mjs @@ -130,8 +130,13 @@ export async function introState(project) { id: t.id, label: t.label, draft: !!t.draft, - // A version's own word: its patch takes the intro off (or puts one on of its own). - intro: takeIntroOff(t.patch) ? "off" : isObj(t.patch?.render) && "intro" in t.patch.render ? "own" : "cut", + // A version's own word: its patch takes the intro off, or puts one on of its own (one the same as the cut's, + // which `on` writes, is the cut's). + intro: takeIntroOff(t.patch) + ? "off" + : isObj(t.patch?.render) && "intro" in t.patch.render && JSON.stringify(t.patch.render.intro) !== JSON.stringify(written) + ? "own" + : "cut", })); return { project: project.id,