// The effects against the popup posts' footage move, in TIME: an effect is // refused only while it is on screen with the footage held aside (fx.mjs // fxShiftConflicts), not whenever the two are both in the cut. The operator's // case: persisting posts on ss1 and r01 early, one fx.zoom ten minutes on. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import test from "node:test"; import { fxBoxWindows, fxShiftConflicts, postShiftWindows, validateFxEntries } from "./fx.mjs"; import { estimateSchedule } from "./deck.mjs"; import { validatorErrors } from "./lint.mjs"; import { footageAt } from "../lib/report/footage-move.mjs"; const PALETTE = { bg: "#12100c", fg: "#f6f1e6", muted: "#a2957f", accent: "#c8752a", amber: "#ffc860" }; const renderOf = (fx, posts = { persist: { seconds: 12, gap: 6 } }) => ({ width: 1920, height: 1080, fps: 30, transition: 0.5, palette: PALETTE, chrome: { engine: "hyperframes", layout: "deck", deck: { posts }, ...(fx ? { fx } : {}) }, }); // ss1 and r01 (12 s each), then c03…c19 and kr4 (30 s each): kr4 about nine minutes in. const ids = ["ss1", "r01", ...Array.from({ length: 17 }, (_, i) => `c${String(i + 3).padStart(2, "0")}`), "kr4"]; const clip = (id, extra = {}) => ({ type: "clip", id, video: `v-${id}`, start: 100, end: ["ss1", "r01"].includes(id) ? 112 : 130, date: "2024-05-01", ...extra }); const ZOOM = { shot: "shots/z.png", focus: [0.1, 0.1, 0.6, 0.5], at: 4 }; const POSTS = [ { id: "p1", platform: "x", text: "one", date: "2024-05-01", url: "https://x.com/a/status/1", attachTo: "ss1" }, { id: "p2", platform: "x", text: "two", date: "2024-05-01", url: "https://x.com/a/status/2", attachTo: "r01" }, ]; const manifestOf = ({ zoomOn = "kr4", fx = { zoom: {} }, posts = POSTS, deckPosts } = {}) => ({ slug: "t", title: "t", provenance: {}, render: renderOf(fx, deckPosts), timeline: ids.map((id) => clip(id, id === zoomOn ? { fx: { zoom: ZOOM } } : {})), posts, }); const check = (m) => validateFxEntries(m, { schedule: estimateSchedule(m) }); test("the operator's cut: persisting posts on ss1 and r01, a zoom on kr4 ten minutes on -- accepted", () => { const m = manifestOf(); const s = estimateSchedule(m); assert.ok(s.segments.find((x) => x.id === "kr4").start > 500, "kr4 is ten minutes in"); assert.deepEqual(postShiftWindows(s).map((w) => w.clips), [["ss1", "r01"]], "one bar over both clips' posts"); assert.deepEqual(check(m), []); assert.deepEqual(fxShiftConflicts(s), []); // And wherever the zoom is drawn, the footage is in the (unshifted) box it is drawn over. const [z] = fxBoxWindows(s); assert.equal(z.what, "the zoom"); for (let t = z.from; t <= z.to; t += 0.25) { const at = footageAt(s, t); assert.ok(at === null || at.progress === 0, `the footage is aside at ${t} under the zoom`); } // The lint says nothing about it either. assert.ok(!validatorErrors(m).some((e) => /footage box/.test(e)), validatorErrors(m).join("\n")); }); test("a zoom while the bar holds the footage aside is refused, naming the zoom's clip, the posts' clips and both spans of seconds", () => { for (const zoomOn of ["r01", "c03"]) { const m = manifestOf({ zoomOn }); const errs = check(m); assert.equal(errs.length, 1, errs.join("\n")); const [bar] = postShiftWindows(estimateSchedule(m)); assert.match(errs[0], new RegExp(`the zoom on ${zoomOn} \\([\\d.]+–[\\d.]+ s\\) is drawn over the footage box while the popup posts on ss1, r01 move it aside \\(${bar.from}–[\\d.]+ s\\)`)); assert.match(errs[0], /set render\.chrome\.deck\.posts\.shift to false/); assert.ok(validatorErrors(m).some((e) => /the zoom on/.test(e)), "the lint refuses it too"); } }); test("an effect over every clip (the scrubber) coincides with any shift: refused; a plain popup's move is its own clip's", () => { const scr = manifestOf({ fx: { scrubber: {} }, zoomOn: null }); assert.match(check(scr).join("\n"), /the scrubber \([\d.]+–[\d.]+ s\) is drawn over the footage box while the popup posts on ss1, r01/); // Without persist the move is the carrying clip's alone, to its end. const plain = (zoomOn) => manifestOf({ zoomOn, deckPosts: {} }); assert.match(check(plain("r01")).join(), /the zoom on r01 .* popup posts on r01 move it aside/); assert.deepEqual(check(plain("c03")), []); assert.deepEqual(check(plain("kr4")), []); }); test("unchanged: no posts, no effect, shift false, or no schedule -- the messages as they were", () => { assert.deepEqual(check(manifestOf({ posts: [] })), []); assert.deepEqual(check(manifestOf({ fx: null })), []); assert.deepEqual(check(manifestOf({ zoomOn: "r01", deckPosts: { shift: false, persist: true } })), []); // No schedule: any shift beside an effect, as ever; `false`: left to the build's measured check. assert.deepEqual(validateFxEntries(manifestOf()), [ "render.chrome.fx is drawn over the footage box, which the popup posts move aside: set render.chrome.deck.posts.shift to false, or use the feed", ]); assert.deepEqual(validateFxEntries(manifestOf({ zoomOn: "r01" }), { schedule: false }), []); // The other entry checks still run whatever the schedule. const bad = manifestOf(); bad.timeline[19].fx.zoom = { ...ZOOM, focus: [0.9, 0, 0.1, 1] }; assert.match(check(bad).join(), /focus must be \[left, top, right, bottom\]/); });