// A clip with its own media (`src` + `cues`, no `video`) is a supported shape // (report-to-video/local-media.mjs). The checker used to send its undefined // `video` into path.join() through sourcesOf -> cuePathFor, so `umtool check` // reported the WHOLE project as "unreadable" (blocking) and every other // decision on it was lost -- candace/video, 6 of 142 clips local. // // 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, summarise } from "../projects/core.mjs"; import { cuePathFor, readClipDetail, sourcesOf } from "../projects/report.mjs"; import { walkProjects } from "../projects/walk.mjs"; test("a local-media clip does not make the project unreadable, and is not a corpus source", async () => { const root = await mkdtemp(path.join(tmpdir(), "local-media-clip-")); try { const channelsDir = path.join(root, "channels"); const reportsRoot = path.join(root, "reports"); await mkdir(path.join(channelsDir, "chan", "data", "here"), { recursive: true }); const dir = path.join(reportsRoot, "cut"); await mkdir(path.join(dir, "clips"), { recursive: true }); await writeFile(path.join(dir, "clips", "local.mp4"), ""); 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, transition: 0.5 }, timeline: [ { type: "clip", id: "a", video: "here", start: 10, end: 20, cite: 10 }, { type: "clip", id: "b", src: "clips/local.mp4", cues: "clips/local.transcript.json", start: 0, end: 5, cite: 0 }, ], }, null, 2)); const [ref] = (await walkProjects(reportsRoot)).filter((p) => p.id === "cut"); const ds = await decisionsFor(ref, reportsRoot); assert.deepEqual(ds.filter((d) => d.kind === "unreadable"), [], "the project reads"); // The corpus clip is still checked: its cue file is missing. assert.ok(ds.some((d) => d.kind === "clip-no-cues" && d.target === "chan/here")); assert.ok(!ds.some((d) => String(d.target).includes("undefined")), "nothing names chan/undefined"); const card = await summarise(ref, reportsRoot); assert.ok(!card.flags.some((f) => /could not be read/.test(f)), card.flags.join("; ")); const src = await sourcesOf(dir); assert.deepEqual(src.rows.map((r) => r.key), ["chan/here"], "the local clip is not a corpus source row"); assert.equal(cuePathFor({ provenance: { channelSlug: "chan" } }, { src: "clips/local.mp4" }, channelsDir), null); // The project page's clip rows read too. const detail = await readClipDetail(dir); assert.ok(detail, "the clip detail reads"); } finally { await rm(root, { recursive: true, force: true }); } });