// Tests for the effects region's page (chrome-fx.mjs, release 35 O2) and // compose-chrome's `fx` region: the page's nodes and its contract, escaping, // nothing fetched, the cues the page plays are the schedule's to the frame, // and -- through a headless Chromium still, the same seek the renderer makes // -- the pixels each effect puts where it says, when it says. One more test // runs ffmpeg's own `wipeleft` and finds the THEN/NOW divider on its edge. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; import test from "node:test"; import { fileURLToPath } from "node:url"; import { cardSize, fxHtml, fxPlan, odoCells, railX, zoomPush } from "./chrome-fx.mjs"; import { deckSchedule, fxGeometry } from "./deck.mjs"; import { validateFxEntries } from "./fx.mjs"; import { frameKeys } from "./frame-keys.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); const PALETTE = { bg: "#12100c", fg: "#f6f1e6", muted: "#a2957f", accent: "#c8752a", amber: "#ffc860" }; const FPS = 30; const FRAME = 1 / FPS; const FONT_R = path.join(HERE, "fonts", "IBMPlexMono-Regular.ttf"); const FONT_B = path.join(HERE, "fonts", "IBMPlexMono-Bold.ttf"); const render = (fx, D = 0.5) => ({ width: 1920, height: 1080, fps: FPS, transition: D, palette: PALETTE, fontRegular: FONT_R, fontBold: FONT_B, chrome: { engine: "hyperframes", layout: "deck", deck: { qr: { show: false } }, fx }, }); const clip = (id, date, extra = {}) => ({ type: "clip", id, channel: "ch", video: `v${id}`, start: 10, end: 18, cutStart: 11, cutEnd: 17, date, quote: "it must be an exceedingly slow news week as we have what appears to be collusion", montage: { match: "slow news week", n: Number(id.slice(1)) * 9 }, ...extra, }); const TIMELINE = [ clip("c1", "2019-05-02"), clip("c2", "2020-06-11", { fx: { receipts: [{ shot: "shots/b.png", mark: [0.04, 0.3, 0.9, 0.5] }, { shot: "shots/a.png", mark: [0.05, 0.25, 0.9, 0.45] }] } }), clip("c3", "2021-01-01"), clip("c4", "2026-01-01", { fx: { zoom: { shot: "shots/a.png", focus: [0.1, 0.2, 0.6, 0.4] } } }), ]; const ALL = { kineticQuote: { clips: ["c1", "c3", "c4"] }, redact: { clips: ["c2"] }, odometer: {}, scrubber: {}, glitch: {}, thenNow: { pairs: [{ then: "c3", now: "c4" }] }, receipts: {}, zoom: {}, }; const WORDS = new Map(["c1", "c2", "c3", "c4"].map((id) => [id, [ { text: "it", start: 1.0, end: 1.2 }, { text: "was", start: 1.2, end: 1.5 }, { text: "a", start: 1.5, end: 1.6 }, { text: "slow", start: 1.7, end: 2.0 }, { text: "news", start: 2.0, end: 2.3 }, { text: "week.", start: 2.3, end: 2.7 }, { text: "really", start: 3.1, end: 3.6 }, ]])); const schedule = (fx = ALL, D = 0.5) => deckSchedule({ entries: TIMELINE, durs: [6.4, 6.4, 6.4, 6.4], D, render: render(fx, D), fxWords: WORDS }); const FONTS = { regular: "assets/DeckSans.ttf", bold: "assets/DeckSansBold.ttf", mono: "assets/FxMono.ttf" }; const SHOTS = { "shots/a.png": { src: "assets/fxshot00.png", w: 600, h: 480 }, "shots/b.png": { src: "assets/fxshot01.png", w: 600, h: 360 } }; const near = (a, b, tol, msg) => assert.ok(Math.abs(a - b) <= tol + 1e-9, `${msg}: ${a} vs ${b} (±${tol})`); const dataOf = (html) => JSON.parse(/