commit 54c7b8b5a7cc8b80f48a02c53efe955e3237a30d
parent 4cba870075b355aaf8ae159a129731ab36791455
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 23:49:15 -0500
umtool e2e: take-items.spec.ts -- a post of another project imported into a draft take (its narration and picture hard-linked, again unchanged, lint --take clean), edited with --in-take (the project's manifest and the source's byte for byte the same), and played on the take; its fixture
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 174 insertions(+), 0 deletions(-)
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -55,6 +55,7 @@ import { makeReelFixture } from "./reel-fixture.mjs";
import { makeIntakeFixture } from "./intake-fixture.mjs";
import { makePostItemsFixture } from "./post-items-fixture.mjs";
import { makePostNarrationFixture } from "./post-narration-fixture.mjs";
+import { makeTakeItemsFixture } from "./take-items-fixture.mjs";
import { makePostComboFixture } from "./post-combo-fixture.mjs";
import { makeMediaScenesFixture } from "./media-scenes-fixture.mjs";
@@ -1915,6 +1916,8 @@ makeIntakeFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow: pat
makePostItemsFixture({ reports, channels: CHANNELS, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// Narrated post items (report-to-video/post-narration.mjs): a take read over a video, four pictures cycling (post-narration.spec.ts).
makePostNarrationFixture({ reports, deckManifest });
+// A take's own items (takeImport.mjs, takeScope.mjs): a post imported from another project into a draft take, edited in the take only (take-items.spec.ts).
+makeTakeItemsFixture({ reports, deckManifest });
// The combo counter (report-to-video/post-combo.mjs): one GIF answering three people (post-combo.spec.ts).
makePostComboFixture({ reports, channels: CHANNELS, deckManifest });
// Media scenes and the band censor (post-media-scene.mjs, post-censor.mjs): one picture answered three times in a row (media-scenes.spec.ts).
diff --git a/umtool/e2e/fixtures/take-items-fixture.mjs b/umtool/e2e/fixtures/take-items-fixture.mjs
@@ -0,0 +1,68 @@
+// A TAKE'S OWN ITEMS (take-items.spec.ts; umtool/docs/cli.md, "Edit a take, not
+// the project"): items of another project imported into a take, edited in the
+// take only. Two projects, written by that spec alone:
+//
+// take-items-fixture the take's project: two post items (p-1, p-3) and a
+// DRAFT take `t1` with no patch of its own yet
+// take-items-src-fixture the source: a narrated post item p-2 whose take
+// (narration/posts/2/take-1.orpheus-thread.wav, a 2 s
+// tone; its parts meta beside it) and attachment
+// (posts-media/takeitems-x/2/2_1.png) are files of
+// this project only, and a second take for the pick
+//
+// Synthetic, like every fixture.
+import { mkdirSync, writeFileSync } from "node:fs";
+import { createHash } from "node:crypto";
+import { spawnSync } from "node:child_process";
+import path from "node:path";
+
+const ff = (args) => {
+ const r = spawnSync("ffmpeg", ["-v", "error", "-y", ...args]);
+ if (r.status !== 0) throw new Error(`ffmpeg ${args.join(" ")}: ${String(r.stderr)}`);
+};
+
+/** @param {{ reports: string, deckManifest: Function }} o */
+export function makeTakeItemsFixture({ reports, deckManifest }) {
+ const base = (id, date, text, o = {}) => ({
+ type: "post", id: `p-${id}`, post: `takeitems-x/${id}`, platform: "x", author: "Take Subject", handle: "takesubject",
+ date, text, url: `https://x.com/takesubject/status/${id}`, engagement: { likes: 2 }, subjects: ["takesubject"], ...o,
+ });
+
+ // The source: p-2, narrated (two takes, the first picked), with a picture.
+ const src = path.join(reports, "take-items-src-fixture");
+ const takes = path.join(src, "narration", "posts", "2");
+ mkdirSync(takes, { recursive: true });
+ for (const [n, hz] of [[1, 262], [2, 330]]) {
+ ff(["-f", "lavfi", "-i", `sine=frequency=${hz}:sample_rate=24000:duration=2`, "-ac", "1", "-c:a", "pcm_s16le", path.join(takes, `take-${n}.orpheus-thread.wav`)]);
+ }
+ writeFileSync(path.join(takes, "take-1.parts.json"), JSON.stringify([{ n: 1, para: 100, text: "The imported words.", start: 0, seconds: 2 }]));
+ mkdirSync(path.join(src, "posts-media", "takeitems-x", "2"), { recursive: true });
+ ff(["-f", "lavfi", "-i", "color=c=teal:size=320x180", "-frames:v", "1", path.join(src, "posts-media", "takeitems-x", "2", "2_1.png")]);
+ const take = (n) => ({ file: `narration/posts/2/take-${n}.orpheus-thread.wav`, engine: "orpheus", voice: "zac", seconds: 2, script: "The imported words.", at: "2026-11-04T00:00:00.000Z" });
+ const sm = deckManifest("take-items-src-fixture", "The Take Items Source", [
+ base("2", "2026-11-02T10:00:00.000Z", "The imported words.", {
+ media: [{ src: "posts-media/takeitems-x/2/2_1.png", kind: "image", width: 320, height: 180 }],
+ narration: { script: "The imported words.", takes: [take(1), take(2)], pick: 0 },
+ }),
+ ]);
+ mkdirSync(src, { recursive: true });
+ writeFileSync(path.join(src, "video.manifest.json"), JSON.stringify(sm, null, 2) + "\n");
+
+ // The take's project: p-1 and p-3, and the draft take t1 (no patch: the project's timeline until its first edit).
+ const dir = path.join(reports, "take-items-fixture");
+ mkdirSync(dir, { recursive: true });
+ const m = deckManifest("take-items-fixture", "The Take Items Fixture", [
+ base("1", "2026-11-01T10:00:00.000Z", "The first post of the cut."),
+ base("3", "2026-11-03T10:00:00.000Z", "The last post of the cut."),
+ ]);
+ const text = JSON.stringify(m, null, 2) + "\n";
+ writeFileSync(path.join(dir, "video.manifest.json"), text);
+ const tdir = path.join(dir, "takes", "t1");
+ mkdirSync(tdir, { recursive: true });
+ writeFileSync(path.join(tdir, "take.json"), JSON.stringify({
+ id: "t1", group: "takes", order: 1, label: "Take one — with an imported post", kind: "different", summary: "", changes: [],
+ preview: "preview.mp4", seconds: null, builtAt: null, style: null, patch: null, window: null, draft: true,
+ draftedAt: "2026-11-04T00:00:00.000Z", baseHash: createHash("sha256").update(text).digest("hex"),
+ }, null, 2) + "\n");
+ return { dir, src };
+}
diff --git a/umtool/e2e/take-items.spec.ts b/umtool/e2e/take-items.spec.ts
@@ -0,0 +1,103 @@
+import { test, expect } from "@playwright/test";
+import { spawnSync } from "node:child_process";
+import { readFileSync, statSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// A TAKE'S OWN ITEMS (umtool/docs/cli.md, "Edit a take, not the project"):
+// `umtool take <p> --id <t> --import-item <src>:<item>` clones an item of
+// another project into a draft take with its files hard-linked in, and
+// `umtool posts … --in-take <t>` edits it in the take -- the take's project
+// manifest and the source's byte for byte the same throughout. Then Play on
+// the take plays the imported item, its narration and picture there.
+//
+// Fixture (fixtures/take-items-fixture.mjs), written by this file alone:
+// take-items-fixture (p-1, p-3; the draft take t1) and take-items-src-fixture
+// (p-2, narrated, two takes, a picture). The tests run in order.
+// ---------------------------------------------------------------------------
+
+test.describe.configure({ mode: "serial" });
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const DIR = path.join(FIXTURE, "reports", "take-items-fixture");
+const SRC = path.join(FIXTURE, "reports", "take-items-src-fixture");
+const P = "reports/take-items-fixture";
+const S = "reports/take-items-src-fixture";
+const TAKE = "t1";
+const env = { ...process.env, REPORTS_DIR: FIXTURE, CHANNELS_DIR: path.join(FIXTURE, "channels"), UMTOOL_CACHE_DIR: path.join(FIXTURE, "cache"), UMTOOL_MEDIA_DIR: "" };
+const umtool = (args: string[]) => spawnSync("node", ["bin/umtool.mjs", ...args], { cwd: path.join(HERE, ".."), encoding: "utf8", env });
+const ok = (args: string[]) => {
+ const r = umtool(args);
+ expect(r.status, `umtool ${args.join(" ")}\n${r.stdout}\n${r.stderr}`).toBe(0);
+ return r.stdout;
+};
+const text = (dir: string) => readFileSync(path.join(dir, "video.manifest.json"), "utf8");
+type Entry = { id: string; hold?: number; narration?: { pick?: number; takes: { file: string }[] } };
+const takeTimeline = () => (JSON.parse(readFileSync(path.join(DIR, "takes", TAKE, "take.json"), "utf8")).patch?.timeline ?? []) as Entry[];
+
+let projectBefore = "";
+let sourceBefore = "";
+test.beforeAll(() => {
+ projectBefore = text(DIR);
+ sourceBefore = text(SRC);
+});
+
+test("import: the source's item cloned into the take after p-1, its narration and picture hard-linked in; again: unchanged; lint --take passes", () => {
+ const plan = JSON.parse(ok(["take", P, "--id", TAKE, "--import-item", `${S}:p-2`, "--after", "p-1", "--dry-run", "--json"]));
+ expect(plan.dryRun).toBe(true);
+ expect(plan.items[0].at).toEqual({ index: 1, after: "p-1", before: "p-3" });
+ expect(() => statSync(path.join(DIR, "narration/posts/2/take-1.orpheus-thread.wav"))).toThrow();
+
+ const r = JSON.parse(ok(["take", P, "--id", TAKE, "--import-item", `${S}:p-2`, "--after", "p-1", "--json"]));
+ expect(r.items.map((x: { id: string; action: string }) => [x.id, x.action])).toEqual([["p-2", "added"]]);
+ expect(r.items[0].narration).toEqual({ takes: 2, pick: 1, file: "narration/posts/2/take-1.orpheus-thread.wav" });
+ expect(r.revision).toMatch(/^takes\/t1\/revisions\/.*-auto-before-import-item\.take\.json$/);
+ expect(takeTimeline().map((e) => e.id)).toEqual(["p-1", "p-2", "p-3"]);
+ for (const rel of ["narration/posts/2/take-1.orpheus-thread.wav", "narration/posts/2/take-1.parts.json", "narration/posts/2/take-2.orpheus-thread.wav", "posts-media/takeitems-x/2/2_1.png"]) {
+ expect(statSync(path.join(DIR, rel)).ino, rel).toBe(statSync(path.join(SRC, rel)).ino);
+ }
+ const again = JSON.parse(ok(["take", P, "--id", TAKE, "--import-item", `${S}:p-2`, "--after", "p-1", "--json"]));
+ expect([again.unchanged, again.items[0].action, again.revision]).toEqual([true, "unchanged", null]);
+ const lint = umtool(["lint", P, "--take", TAKE, "--json"]);
+ const doc = JSON.parse(lint.stdout);
+ expect(doc.errors, lint.stdout).toEqual([]);
+ expect(lint.status).toBe(0);
+ expect(text(DIR)).toBe(projectBefore);
+ expect(text(SRC)).toBe(sourceBefore);
+});
+
+test("--in-take: set-item and narrate --pick land in the take's patch only; narrate --take <the take> is refused naming --in-take; undo takes the pick back", () => {
+ const set = JSON.parse(ok(["posts", "set-item", P, "p-2", "hold=4", "--in-take", TAKE, "--json"]));
+ expect(set.take).toMatchObject({ id: TAKE, edits: 1, undo: `umtool timeline ${P} --take ${TAKE} undo` });
+ ok(["posts", "narrate", P, "p-2", "--pick", "2", "--in-take", TAKE]);
+ const e = takeTimeline().find((x) => x.id === "p-2");
+ expect(e?.hold).toBe(4);
+ expect(e?.narration?.pick).toBe(1);
+ const wrong = umtool(["posts", "narrate", P, "p-2", "--take", TAKE]);
+ expect(wrong.status).toBe(2);
+ expect(wrong.stderr).toContain(`to edit take ${TAKE}, say --in-take ${TAKE}`);
+ ok(["timeline", P, "--take", TAKE, "undo"]);
+ expect(takeTimeline().find((x) => x.id === "p-2")?.narration?.pick).toBe(0);
+ expect(text(DIR)).toBe(projectBefore);
+ expect(text(SRC)).toBe(sourceBefore);
+ // The project's own cut has no p-2: the same edit without --in-take is refused.
+ expect(umtool(["posts", "set-item", P, "p-2", "hold=4"]).status).not.toBe(0);
+});
+
+test("Play on the take plays the imported item: its row between p-1 and p-3, its card and picture -- the project's cut has no p-2", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 1000 });
+ await page.goto(urls.playHref(P, { take: TAKE, clip: "p-2" }));
+ await expect(page.locator(`[data-play-take="${TAKE}"]`)).toBeVisible();
+ const rows = page.locator("[data-play-row]");
+ await expect(rows).toHaveCount(3);
+ expect(await rows.evaluateAll((els) => els.map((x) => x.getAttribute("data-play-row")))).toEqual(["p-1", "p-2", "p-3"]);
+ await expect(page.locator("[data-play-cut]")).toHaveAttribute("data-play-item", "p-2");
+ await expect(page.locator('[data-post-play="p-2"]')).toBeVisible();
+ await expect(page.locator('[data-post-play="p-2"]')).toContainText("The imported words.");
+ await page.screenshot({ path: test.info().outputPath("take-items-play.png") });
+ await page.goto(urls.playHref(P, { bare: true }));
+ await expect(page.locator("[data-play-row]")).toHaveCount(2);
+});