// A SCRIPT WRITTEN BY THE SEVERAL-ITEMS WRITER IS MARKED FOR READING TOO (lane reads-find; operator ruling 3): the // import (`posts narrate --import`, narration/posts/index.json) sets a script through updatePostNarrations, and a script // that is not the post's words as drafted must leave the card on the shown text -- as the single writer does // (postNarrationIn's forReading). Pinned with the reading pin's hashes: the card draws what it drew before. import "./noLiveEditor.mjs"; import assert from "node:assert/strict"; import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; import { after, test } from "node:test"; import { manifestToken, updatePostNarrations } from "./manifest.mjs"; import { scriptEditOf } from "umtool-report-to-video/post-item"; import { PINNED_SHAS, drawn, singleItem } from "../../report-to-video/post-reading-pin.fixtures.mjs"; const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-narrations-for-reading-")); after(() => rm(ROOT, { recursive: true, force: true })); async function project(timeline) { const dir = path.join(ROOT, "p"); await mkdir(dir, { recursive: true }); await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ schemaVersion: 1, slug: "p", title: "p", render: { width: 1920, height: 1080, fps: 30 }, timeline }, null, 2)); return dir; } const read = async (dir) => JSON.parse(await readFile(path.join(dir, "video.manifest.json"), "utf8")); test("updatePostNarrations: an edited script (no take yet) is marked for reading, and the card draws as it did", async () => { const { narration: _n, ...bare } = singleItem(); void _n; const dir = await project([bare]); const edited = "The council met on Tuesday about the new bridge, the B R I D G E.\n\nNobody from the ministry came to explain the delay."; await updatePostNarrations(dir, [{ id: bare.id, patch: { script: edited } }], { token: await manifestToken(dir), op: "post-narration-import" }); const e = (await read(dir)).timeline[0]; assert.equal(e.narration.forReading, true); assert.equal(scriptEditOf(e), "reading"); const d = drawn(e); assert.equal(d.plain, PINNED_SHAS.single.plain); assert.equal(d.blocks, drawn({ ...e, narration: { ...e.narration, script: singleItem().narration.script } }).blocks); }); test("updatePostNarrations: a script that says the post's words as drafted is not marked; other patches are as before", async () => { const dir = await project([singleItem()]); await updatePostNarrations(dir, [{ id: "p-7003", patch: { script: singleItem().narration.script } }, { id: "p-7003", patch: { character: "teller" } }], { token: await manifestToken(dir) }); const e = (await read(dir)).timeline[0]; assert.equal("forReading" in e.narration, false); assert.equal(e.narration.character, "teller"); });