commit ed982b06b624482b71cc2f0d92b2ea3636c0361f
parent 48ae6dfc3e5fbb5d57203ef47615cc1cd3147665
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 23:27:29 -0500
umtool: the instruments in the module panel, and an e2e over their preview pages
The dial, the odometer and the trail switch on and off in the module panel
(on while deck.<id> is there). instruments.spec.ts on instruments-fixture
(the Play cut with the three on and a built schedule carrying six measure
rows): they are play layers of the full chrome preview at the column's
geometry; each page posts <region>:ready and is seeked by deck:seek -- the
needle and the readout on each stated weight, the wheels rolling up, the
trail's points by date and its under-300 count; the panel previews the dial
alone and its scrubber seeks it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 242 insertions(+), 0 deletions(-)
diff --git a/umtool/e2e/fixtures/instruments-fixture.mjs b/umtool/e2e/fixtures/instruments-fixture.mjs
@@ -0,0 +1,58 @@
+// What instruments.spec.ts previews: the Play cut (play-cut-fixture.mjs) with the
+// measure's instruments on -- `deck.dial`, `deck.odometer`, `deck.trail` -- and
+// a BUILT schedule (out/sourced/schedule.json, the estimate's own timings) that
+// carries a measure slice, as the build writes one for a cut with a measure
+// ledger (the producer is lane measure-ledger's; until it lands the slice is
+// written here). The chrome preview without `estimate` reads that schedule;
+// Play the cut composes on the estimate's, which carries the measure once the
+// producer puts it there. Six rows of the instruments' fixture
+// (report-to-video/fixtures/measure-dial/measure.json), each at a second of
+// the cut, with the state after it:
+//
+// c01 +0.6 w07 stated >240 c01 +1.2 w21 remembered ≈390
+// c02 +0.4 w27 goal 250 c02 +1.0 w62 lost 40 (run 6)
+// c04 +0.2 w115 stated <300 c04 +0.6 w118 stated 291.5
+//
+// Synthetic, like every fixture: real ledger rows, fake cut times.
+import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const MEASURE = path.join(HERE, "..", "..", "report-to-video", "fixtures", "measure-dial", "measure.json");
+
+/** The rows, and where each lands: [row, clip, seconds into the clip]. */
+export const INSTRUMENT_ROWS = Object.freeze([
+ ["w07", "c01", 0.6], ["w21", "c01", 1.2], ["w27", "c02", 0.4], ["w62", "c02", 1.0], ["w115", "c04", 0.2], ["w118", "c04", 0.6],
+]);
+
+export async function makeInstrumentsFixture({ reports, deckManifest, cachedWindow, makePlayCutFixture, name = "instruments-fixture" }) {
+ const { estimateSchedule } = await import("../../report-to-video/deck.mjs");
+ const { dir } = makePlayCutFixture({
+ reports, deckManifest, cachedWindow, name, title: "The Instruments Fixture",
+ chrome: {
+ deck: { dial: true, odometer: true, trail: true },
+ // The tally's word fitted to its cell, as play-modules-fixture's.
+ factcheck: { verdicts: { CORROBORATED: { label: "Seizures", tallyLabel: "Seized", color: "#6fa8dc" } }, stamp: { seconds: 1 } },
+ },
+ });
+ const file = path.join(dir, "video.manifest.json");
+ const manifest = JSON.parse(readFileSync(file, "utf8"));
+ const schedule = estimateSchedule(manifest);
+ const M = JSON.parse(readFileSync(MEASURE, "utf8"));
+ const startOf = new Map(schedule.segments.map((s) => [s.id, s.start]));
+ const r3 = (v) => Math.round(v * 1000) / 1000;
+ const events = [];
+ const state = [{ ...M.state[0], t: 0 }];
+ for (const [row, clip, at] of INSTRUMENT_ROWS) {
+ const i = M.events.findIndex((e) => e.row === row);
+ if (i < 0) throw new Error(`instruments-fixture: ${row} is not in ${MEASURE}`);
+ const t = r3(startOf.get(clip) + at);
+ events.push({ ...M.events[i], t, segment: clip });
+ state.push({ ...M.state[i + 1], t });
+ }
+ const measure = { ...M, events, state, _fixture: "instruments-fixture: six rows of measure-dial's fixture at seconds of the Play cut" };
+ mkdirSync(path.join(dir, "out", "sourced"), { recursive: true });
+ writeFileSync(path.join(dir, "out", "sourced", "schedule.json"), JSON.stringify({ ...schedule, measure }, null, 2) + "\n");
+ return { dir, schedule: { ...schedule, measure } };
+}
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -61,6 +61,7 @@ import { makeTakeItemsFixture } from "./take-items-fixture.mjs";
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";
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"));
@@ -2029,6 +2030,10 @@ pm.timeline = pm.timeline.map((e) => (e.id === "c03" ? { ...e, verdict: "incorre
writeFileSync(pmFile, JSON.stringify(pm, null, 2) + "\n");
}
+// 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 });
+
// Wrong speaker in Play the cut (play-modules.spec.ts), which WRITES (removes c02, then undoes):
// its own copy, so no other spec's cut moves under it.
makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-wrong-fixture", title: "The Play Wrong Speaker Fixture" });
diff --git a/umtool/e2e/instruments.spec.ts b/umtool/e2e/instruments.spec.ts
@@ -0,0 +1,175 @@
+import { test, expect, type APIRequestContext, 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 MEASURE'S INSTRUMENTS (umtool/docs/knobs.md, Modules: "Scale dial",
+// "Lost odometer", "Weight trail"): three deck modules that read the
+// schedule's measure slice and declare `play` -- each page composed for the
+// chrome preview, posting `<region>:ready`, seeked by `deck:seek` in the cut's
+// seconds; the same page the build captures.
+//
+// Fixture: e2e/fixtures/instruments-fixture.mjs -- the Play cut with
+// deck.dial/odometer/trail on and a built schedule carrying six rows of the
+// measure (w07 stated >240 at 0.6 s, w21 remembered ≈390 at 1.2, w27 goal 250
+// at 2.0, w62 lost 40 at 2.6, w115 stated <300 at 6.1, w118 stated 291.5 at
+// 6.5; the cut is 7.9 s). The chrome preview without `estimate` reads that
+// schedule. (Play the cut composes on the estimate's clock: the instruments
+// join it there once the build's measure producer puts the slice in the
+// estimate.)
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const PROJECT = "reports/instruments-fixture";
+const DIR = path.join(HERE, "..", ".e2e-song", "reports", "instruments-fixture");
+const manifest = () => JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8"));
+
+type Layer = { id: string; z?: number; region?: string; ready?: string; src?: string; error?: string; off?: string; geometry?: { x: number; y: number; width: number; height: number } };
+
+async function preview(request: APIRequestContext, data: Record<string, unknown>) {
+ const res = await request.post("/api/report/chrome/preview", { data: { project: PROJECT, ...data } });
+ expect(res.ok(), await res.text()).toBeTruthy();
+ return (await res.json()) as { layers: Layer[]; geometry: { footage: { x: number; width: number } } };
+}
+
+/**
+ * A harness page holding one layer's page in an iframe, as Play holds it: the
+ * messages it posts are kept in `window.__msgs`; `seek(t)` posts `deck:seek`.
+ */
+async function harness(page: Page, src: string, baseURL: string) {
+ const url = new URL(`${src}${src.includes("?") ? "&" : "?"}preview=1`, baseURL).toString();
+ await page.setContent(`<!doctype html><body style="margin:0;background:#0f1311">
+ <iframe id="f" src="${url}" style="border:0;width:600px;height:540px"></iframe>
+ <script>window.__msgs = []; addEventListener("message", (e) => window.__msgs.push(e.data));</script></body>`);
+ return {
+ frame: page.frameLocator("#f"),
+ messages: () => page.evaluate(() => (window as unknown as { __msgs: { type: string }[] }).__msgs.map((m) => m.type)),
+ seek: (t: number) => page.evaluate((v) => (document.getElementById("f") as HTMLIFrameElement).contentWindow!.postMessage({ type: "deck:seek", t: v }, "*"), t),
+ };
+}
+
+/** The readout block the dial shows: the one `cv` block that is visible. */
+const visibleReadout = (frame: ReturnType<Page["frameLocator"]>) =>
+ frame.locator(".read").evaluateAll((els) =>
+ els.filter((e) => getComputedStyle(e).visibility !== "hidden" && Number(getComputedStyle(e).opacity) > 0.5).map((e) => (e.querySelector(".big")?.textContent ?? "").trim()),
+ );
+
+/** The needle's rotation in degrees, read off its computed transform. */
+const needleDeg = (frame: ReturnType<Page["frameLocator"]>) =>
+ frame.locator('[data-k="nd"]').evaluate((el) => {
+ const m = new DOMMatrix(getComputedStyle(el).transform);
+ return Math.round((Math.atan2(m.b, m.a) * 180) / Math.PI);
+ });
+
+test.beforeEach(() => {
+ test.setTimeout(120_000);
+});
+
+test("the dial, the odometer and the trail are play layers of a cut with a measure, at the instruments' column", async ({ request }) => {
+ test.skip(!manifest().render.fontRegular, "the deck refuses to draw without its faces, and make-fixture.mjs found no font on this machine");
+ const full = await preview(request, {});
+ const by = Object.fromEntries(full.layers.map((l) => [l.id, l]));
+ for (const id of ["dial", "odometer", "trail"]) {
+ expect(by[id], `${id} is a play layer`).toBeTruthy();
+ expect(by[id].error ?? null).toBeNull();
+ expect(by[id].ready).toBe(`${id}:ready`);
+ expect(by[id].src).toContain(`${id}-preview/index.html`);
+ }
+ // The column at the frame's right, the footage moved to the left for it (1920x1080).
+ expect(by.dial.geometry).toEqual({ x: 1296, y: 24, width: 600, height: 540 });
+ expect(by.odometer.geometry).toEqual({ x: 1296, y: 576, width: 600, height: 140 });
+ expect(by.trail.geometry).toEqual({ x: 1296, y: 728, width: 600, height: 138 });
+ expect(full.geometry.footage.x).toBe(24);
+ expect(full.geometry.footage.x + full.geometry.footage.width).toBeLessThanOrEqual(1296 - 24);
+ // No finale in this cut: no dial finale.
+ expect(by["dial-finale"]).toBeUndefined();
+
+ // The page it serves is the instrument's own, drawn from the measure.
+ const dial = await (await request.get(by.dial.src!)).text();
+ expect(dial).toContain('id="dial-data"');
+ expect(dial).toContain(">240<i>LB</i>");
+ expect(dial).toContain("291.5<i>LB</i>");
+ const odo = await (await request.get(by.odometer.src!)).text();
+ expect(odo).toContain('id="odometer-data"');
+ expect(odo).toContain("POUNDS HE SAYS HE");
+});
+
+test("the dial's page posts dial:ready and is seeked in the cut's seconds: the needle and the readout land on each stated weight", async ({ page, request, baseURL }) => {
+ test.skip(!manifest().render.fontRegular, "the deck refuses to draw without its faces, and make-fixture.mjs found no font on this machine");
+ const { layers } = await preview(request, { layers: ["dial"] });
+ const dial = layers.find((l) => l.id === "dial")!;
+ expect(dial.src, dial.off ?? dial.error).toBeTruthy();
+ const h = await harness(page, dial.src!, baseURL!);
+ await expect.poll(h.messages, { timeout: 30_000 }).toContain("dial:ready");
+
+ // Before any stated weight: the dash, the needle at rest on the scale's foot (220 lb: -135°).
+ await h.seek(0.2);
+ await expect.poll(() => visibleReadout(h.frame)).toEqual(["—"]);
+ await expect.poll(() => needleDeg(h.frame)).toBe(-135);
+ // After "over 240" (0.6 s) has settled: its weight, the needle at 240 (-105°), its wedge up.
+ await h.seek(2.2);
+ await expect.poll(() => visibleReadout(h.frame)).toEqual([">240LB"]);
+ await expect.poll(() => needleDeg(h.frame)).toBe(-105);
+ await expect(h.frame.locator('[data-k="q1"]')).toBeVisible();
+ // The remembered ≈390 is a ghost with its as-of date.
+ await expect(h.frame.locator('[data-k="gn"]')).toBeVisible();
+ await expect(h.frame.locator('[data-k="ga0"]')).toContainText("AS OF");
+ // The last stated weight: 291.5 (-27.75°), and back again -- a seek lands the same from either side.
+ await h.seek(7.8);
+ await expect.poll(() => visibleReadout(h.frame)).toEqual(["291.5LB"]);
+ await expect.poll(() => needleDeg(h.frame)).toBe(-28);
+ await h.seek(2.2);
+ await expect.poll(() => visibleReadout(h.frame)).toEqual([">240LB"]);
+ await page.screenshot({ path: test.info().outputPath("instruments-dial.png") });
+});
+
+test("the odometer and the trail post ready and seek: the wheels only roll up, the line draws by date", async ({ page, request, baseURL }) => {
+ test.skip(!manifest().render.fontRegular, "the deck refuses to draw without its faces, and make-fixture.mjs found no font on this machine");
+ const { layers } = await preview(request, { layers: ["odometer", "trail"] });
+ const by = Object.fromEntries(layers.map((l) => [l.id, l]));
+ const odo = await harness(page, by.odometer.src!, baseURL!);
+ await expect.poll(odo.messages, { timeout: 30_000 }).toContain("odometer:ready");
+ // A wheel's digit: which of its strip's cells stands in its window.
+ const digits = () => odo.frame.locator(".wheel").evaluateAll((ws) => ws.map((w) => {
+ const strip = w.querySelector(".strip") as HTMLElement;
+ const y = new DOMMatrix(getComputedStyle(strip).transform).f;
+ return Math.round(-y / w.getBoundingClientRect().height) % 10;
+ }).join(""));
+ await odo.seek(7.8);
+ const end = await digits();
+ await odo.seek(0.1);
+ const start = await digits();
+ expect(Number(end)).toBeGreaterThan(Number(start));
+ await page.screenshot({ path: test.info().outputPath("instruments-odometer.png") });
+
+ const trail = await harness(page, by.trail.src!, baseURL!);
+ await expect.poll(trail.messages, { timeout: 30_000 }).toContain("trail:ready");
+ const shown = () => trail.frame.locator(".pt").evaluateAll((ps) => ps.filter((p) => Number(getComputedStyle(p).opacity) > 0.5).length);
+ await trail.seek(0.3);
+ await expect.poll(shown).toBe(0);
+ await trail.seek(7.8);
+ await expect.poll(shown).toBe(3);
+ await expect(trail.frame.locator('[data-k="uc0"]')).toContainText("UNDER 300 · SAID 1×");
+});
+
+test("the module panel lists the instruments and previews the dial alone, seeked by its scrubber", async ({ page }) => {
+ test.skip(!manifest().render.fontRegular, "the deck refuses to draw without its faces, and make-fixture.mjs found no font on this machine");
+ await page.goto(urls.section(PROJECT, "onscreen"));
+ const panel = page.getByTestId("modules-panel");
+ await expect(panel.getByTestId("module-dial")).toBeAttached({ timeout: 60_000 });
+ await expect(panel.getByTestId("module-odometer")).toBeAttached();
+ await expect(panel.getByTestId("module-trail")).toBeAttached();
+ const card = page.getByTestId("module-dial");
+ await card.locator("summary").click();
+ await card.getByTestId("module-preview-dial").click();
+ const iframe = card.getByTestId("module-preview-iframe");
+ await expect(iframe).toHaveAttribute("src", /dial-preview\/index\.html/);
+ // The scrubber to the cut's end, as a person drags it (a key, so React hears the input).
+ await card.getByTestId("module-preview-scrub").focus();
+ await page.keyboard.press("End");
+ const frame = card.frameLocator('[data-testid="module-preview-iframe"]');
+ await expect.poll(() => visibleReadout(frame), { timeout: 30_000 }).toEqual(["291.5LB"]);
+ await page.screenshot({ path: test.info().outputPath("instruments-panel.png") });
+});
diff --git a/umtool/report-to-video/modules/panel.mjs b/umtool/report-to-video/modules/panel.mjs
@@ -42,6 +42,10 @@ const TOGGLES = Object.freeze({
intro: { style: "boot-dark", site: "auto" },
claims: null,
"section-title": {},
+ // The measure's instruments (instruments.mjs): on while `deck.<id>` is there.
+ dial: {},
+ odometer: {},
+ trail: {},
});
/** Is this module toggled by its object's presence, and what does turning it on write? */