// `clip-incorrect`: a clip the walk ruled INCORRECT that is still in the // timeline is BLOCKING in `umtool check`, named with its correction -- the // build would render it and the counter count its marks otherwise. A // confirmed clip with a note, and an unreviewed one, are not. // // Run with: pnpm test:scripts import assert from "node:assert/strict"; import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import test from "node:test"; import { decisionsFor } from "../projects/core.mjs"; import { incorrectClips, incorrectWhy } from "../projects/report.mjs"; import { walkProjects } from "../projects/walk.mjs"; async function decisionsOf(timeline) { const root = await mkdtemp(path.join(tmpdir(), "clip-incorrect-")); try { const channelsDir = path.join(root, "channels"); const reportsRoot = path.join(root, "reports"); const vdir = path.join(channelsDir, "chan", "data", "vid"); await mkdir(vdir, { recursive: true }); const cues = Array.from({ length: 200 }, (_, i) => ({ start: i, end: i + 1, text: `Line ${i}.` })); await writeFile(path.join(vdir, "transcript.cues.json"), JSON.stringify({ cues })); const dir = path.join(reportsRoot, "cut"); await mkdir(dir, { recursive: true }); await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ schemaVersion: 1, slug: "cut", title: "Cut", provenance: { channelSlug: "chan", channelsDir: path.relative(dir, channelsDir), siteOrigin: "https://example.test" }, render: { width: 1920, height: 1080, fps: 30 }, timeline: timeline.map((e) => ({ type: "clip", video: "vid", cite: Math.floor(e.start), lock: true, ...e })), }, null, 2)); const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut"); return (await decisionsFor(ref, reportsRoot)).filter((d) => d.kind === "clip-incorrect"); } finally { await rm(root, { recursive: true, force: true }); } } test("a clip marked incorrect still in the timeline is blocking, with its correction and what to do", async () => { const ds = await decisionsOf([ { id: "c01", start: 10, end: 20, verdict: "confirmed", correction: "window moved to the sentence" }, { id: "e01", start: 30, end: 40, verdict: "incorrect", correction: "Other speaker, not Ember." }, { id: "c02", start: 50, end: 60 }, // The bench's legacy `x`: a correction with no verdict reads as incorrect. { id: "e02", start: 70, end: 80, correction: "wrong date" }, ]); assert.deepEqual(ds.map((d) => [d.target, d.severity, d.why]), [ ["e01", "blocking", "e01 is marked incorrect: Other speaker, not Ember — remove it, fix it and re-confirm, or clear the verdict"], ["e02", "blocking", "e02 is marked incorrect: wrong date — remove it, fix it and re-confirm, or clear the verdict"], ]); assert.match(ds[0].href, /\/clip\/e01$/); }); test("none marked incorrect: nothing; the helpers skip cards and confirmed clips", async () => { assert.deepEqual(await decisionsOf([{ id: "c01", start: 10, end: 20, verdict: "confirmed" }]), []); assert.deepEqual(incorrectClips([{ type: "card", id: "k", correction: "x" }, { type: "clip", id: "a", verdict: "confirmed", correction: "note" }]), []); assert.equal(incorrectWhy({ id: "a" }), "a is marked incorrect — remove it, fix it and re-confirm, or clear the verdict"); });