commit 6ac75d61f31a1919a4f04aa20f879da2acfca9ab
parent 2edab1c18baea1b75fbb14303bfc83773aec83dd
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 28 Oct 2026 23:29:49 -0400
umtool: rail module tests (pitch spacing, settings order)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 51 insertions(+), 0 deletions(-)
diff --git a/umtool/report-to-video/modules/rail.test.mjs b/umtool/report-to-video/modules/rail.test.mjs
@@ -0,0 +1,51 @@
+// The rail module: pip spacing "pitch" (deck.mjs pipXs, chrome-deck.mjs deckCues)
+// and the settings every deck module validates (modules/settings.mjs).
+import { test } from "node:test";
+import assert from "node:assert/strict";
+
+import { estimateSchedule, pipXs, resolveDeck, validateChrome } from "../deck.mjs";
+import { deckCues, deckHtml } from "../chrome-deck.mjs";
+import rail from "./rail.mjs";
+import { SETTINGS, settingsOf } from "./settings.mjs";
+
+const PALETTE = { bg: "#101219", fg: "#f2f0ea", muted: "#979caa", accent: "#e5534b", amber: "#ffc860" };
+const render = (pip) => ({ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: { engine: "hyperframes", layout: "deck", deck: { pip } } });
+const clip = (id) => ({ type: "clip", id, video: id, start: 0, end: 8 });
+
+test("pipXs at a pitch: each pip a pitch after the last from the left; squeezed only when the track is too short", () => {
+ assert.deepEqual(pipXs(3, 48, 1872, "pitch", null, 40), [48, 88, 128]);
+ assert.deepEqual(pipXs(1, 48, 1872, "pitch", null, 40), [48]);
+ // 100 pips at 40 px need 3960 px: laid at the pitch that fits.
+ const xs = pipXs(100, 48, 1872, "pitch", null, 40);
+ assert.ok(Math.abs(xs.at(-1) - 1872) < 1e-9);
+ assert.equal(xs[0], 48);
+ // A pip's place does not depend on how many come after it.
+ assert.deepEqual(pipXs(4, 48, 1872, "pitch", null, 40).slice(0, 3), pipXs(3, 48, 1872, "pitch", null, 40));
+});
+
+test("the deck at a pitch: pips after the first hidden until the marker reaches the one before; the fuse against the track", () => {
+ const r = render({ spacing: "pitch", pitch: 40 });
+ const s = estimateSchedule({ render: r, timeline: [clip("a"), clip("b"), clip("c")], posts: [], provenance: {} });
+ const { init, cues, pips } = deckCues(s, r);
+ assert.deepEqual(pips.map((p) => p.x), [48, 88, 128]);
+ assert.deepEqual(init.pb1, { opacity: 0 });
+ assert.deepEqual(init.pb2, { opacity: 0 });
+ assert.equal(init.pb0, undefined);
+ assert.ok(cues.some((c) => c.k === "pb1" && c.to.opacity === 1));
+ const html = deckHtml(s, r, {});
+ assert.match(html, /\.fuse \{ position: absolute; left: 48px; top: -1px; width: 1824px;/);
+ assert.match(html, /<div class="pip" data-k="pb1" style="left:85px"><\/div>/);
+ // Even spacing: no pip is hidden, as it always was.
+ const e = deckCues(s, render({}));
+ assert.equal(e.init.pb1, undefined);
+});
+
+test("rail settings: spacing, pitch, and the deck's other keys refused by name", () => {
+ assert.deepEqual(validateChrome(render({ spacing: "pitch", pitch: 24 }).chrome, render({})), []);
+ assert.match(validateChrome(render({ spacing: "grid" }).chrome, render({}))[0], /pip\.spacing must be "even", "time" or "pitch"/);
+ assert.match(validateChrome(render({ pitch: 2 }).chrome, render({}))[0], /pip\.pitch must be from 8 to 200/);
+ assert.equal(resolveDeck(render({})).pip.pitch, undefined, "no pitch unless set: the deck resolves as it did");
+ assert.equal(rail.resolve(render({ spacing: "pitch" })).pip.pitch, 28);
+ assert.equal(rail.validate, settingsOf("rail").validate);
+ assert.deepEqual(SETTINGS.map((s) => s.id), ["stamp", "threads", "flips", "stats", "fx", "finale", "claims", "counter", "shell", "rail", "subtitle", "qr", "popup-posts"]);
+});