// Montage rulings (release 34 N1): the key rule, the file's shape, and how a // render applies the clip deck's rulings -- the ruled-out clips left out of // the cut and the wall, a ruled phrase in place of `montage.match`, the // counter numbered over the kept clips -- and that no file (or a file that // changes nothing) is today's render, byte for byte. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import { spawnSync } from "node:child_process"; import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import test from "node:test"; import { applyMontageRulings, clipMomentKey, isMomentKey, leftOutWords, momentKey, MONTAGE_RULINGS_FILE, parseMomentKey, parseMontageRulings, readMontageRulings, rulingsLines, } from "./montage-rulings.mjs"; // The build's cue reader takes its corpus from CHANNELS_DIR when the module // loads, so the variable is set before the import: the render tests' clips are // corpus moments (a channel, a video, a cut start), their windows and cues in // a synthetic channels tree. const corpus = await mkdtemp(path.join(os.tmpdir(), "rtv-rulings-corpus-")); process.env.CHANNELS_DIR = corpus; const { buildVideo } = await import("./build-video.mjs"); const { verifyBuild } = await import("./verify-build.mjs"); const { MONO_BOLD_FONT_FILE, MONO_FONT_FILE } = await import("./brand.mjs"); test.after(() => rm(corpus, { recursive: true, force: true })); const AT = "2026-10-18T12:00:00.000Z"; const clip = (id, video, cutStart, extra = {}) => ({ type: "clip", id, channel: "chan", video, start: cutStart - 2.5, end: cutStart + 4, cutStart, cutEnd: cutStart + 2, montage: { n: Number(id.slice(1)), of: 5, match: "slow news day" }, ...extra, }); const five = () => ({ slug: "m", provenance: { channelSlug: "chan" }, render: {}, timeline: [clip("s1", "va", 10), clip("s2", "vb", 20.5), clip("s3", "vc", 30.25), clip("s4", "vd", 40), clip("s5", "ve", 50)], }); const doc = (rulings) => ({ version: 1, rulings: Object.fromEntries(Object.entries(rulings).map(([k, r]) => [k, { reason: "", at: AT, ...r }])) }); test("the key: /