commit e2531a7fc35a0bbeb3eb4300db9d1ac93cccaa7e
parent 3cf594404ec65c5cb3fb9dab0f5e6d61fbbc1ca5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 13 Oct 2026 21:32:16 -0400
umtool: e2e draft-review.spec — badges, approve and reject, Use this, the final gate
Two fixture projects (e2e/fixtures/draft-review-fixture.mjs): one with a
drafted title, narration and teaser and an alternative for a hand-written
title; one built by the spec, whose drafted title refuses a final build until
it is approved, then builds (a real offline final build). narration-review
.spec reads the verdicts from drafts.review.json, where the narration page
writes them now.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
4 files changed, 220 insertions(+), 5 deletions(-)
diff --git a/umtool/e2e/draft-review.spec.ts b/umtool/e2e/draft-review.spec.ts
@@ -0,0 +1,125 @@
+import { test, expect, type APIRequestContext } from "@playwright/test";
+import { existsSync, readFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+// ---------------------------------------------------------------------------
+// The drafts review (release 28, M0). A drafted field shows "drafted by
+// <model>" and its review state beside it, with Approve / Reject (a note
+// required); an edit makes it the operator's (the mark goes); the review page
+// lists every drafted field, and an alternative a draft task kept for the
+// operator's field is written with "Use this"; a FINAL build refuses a drafted
+// field until it is approved, then builds. Verdicts are drafts.review.json
+// beside the manifest. Fixtures: e2e/fixtures/draft-review-fixture.mjs.
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const PROJECT = "reports/draft-review-fixture";
+const DIR = path.join(FIXTURE, "reports", "draft-review-fixture");
+const BUILD_PROJECT = "reports/draft-review-build-fixture";
+const BUILD_DIR = path.join(FIXTURE, "reports", "draft-review-build-fixture");
+
+type Entry = { id: string; onscreen?: { title?: string }; drafted?: Record<string, unknown>; lines?: unknown[] };
+const manifest = (dir = DIR) => JSON.parse(readFileSync(path.join(dir, "video.manifest.json"), "utf8")) as { timeline: Entry[] };
+const entry = (id: string, dir = DIR) => manifest(dir).timeline.find((e) => e.id === id)!;
+const review = (dir = DIR): Record<string, { verdict: string | null; note: string }> => {
+ const f = path.join(dir, "drafts.review.json");
+ return existsSync(f) ? JSON.parse(readFileSync(f, "utf8")) : {};
+};
+
+test("badges: drafted by <model>, approve, reject with a note; an edit makes the field the operator's", async ({ page }) => {
+ await page.goto(`/browse/${PROJECT}`);
+ await expect(page.locator("[data-review-link]")).toHaveAttribute("data-review-link", "3");
+
+ // The On-screen table (folded: the deck is off) -- c02's title was drafted, c01's was not.
+ await page.getByTestId("onscreen-words-folded").locator("summary").click();
+ const c02 = page.locator('[data-draft-badge="onscreen/c02/onscreen"]');
+ await expect(c02).toHaveAttribute("data-state", "unreviewed");
+ await expect(c02.locator("[data-draft-by]")).toHaveText("drafted by qwen3:8b");
+ await expect(page.locator('[data-draft-badge="onscreen/c01/onscreen"]')).toHaveCount(0);
+ await c02.locator('[data-draft-action="approve"]').click();
+ await expect(c02).toHaveAttribute("data-state", "approved");
+ expect(review()["onscreen/c02/onscreen"].verdict).toBe("approved");
+
+ // The teaser's lines: a rejection needs its note.
+ await page.getByTestId("structure-folded").locator("summary").click();
+ const t01 = page.locator('[data-draft-badge="teaser/t01/lines"]');
+ await expect(t01.locator("[data-draft-by]")).toHaveText("drafted by claude-sonnet-5-5");
+ await t01.locator('[data-draft-action="reject"]').click();
+ await expect(t01.locator("[data-draft-error]")).toContainText("a rejection needs its note");
+ await t01.locator("[data-draft-note]").fill("the lease is not next season");
+ await t01.locator('[data-draft-action="reject"]').click();
+ await expect(t01).toHaveAttribute("data-state", "rejected");
+ expect(review()["teaser/t01/lines"]).toMatchObject({ verdict: "rejected", note: "the lease is not next season" });
+
+ // Edit c02's drafted title: saved through the manifest writer, it is the
+ // operator's now -- no mark, no badge.
+ const row = page.locator('[data-testid="onscreen-row"][data-entry="c02"]');
+ await row.getByTestId("onscreen-title").fill("My own title");
+ await page.getByTestId("onscreen-save").click();
+ await expect(c02).toHaveCount(0);
+ expect(entry("c02").onscreen).toEqual({ title: "My own title" });
+ expect(entry("c02").drafted).toBeUndefined();
+});
+
+test("the review page: every drafted field, the narration's badge, and Use this for the operator's field", async ({ page }) => {
+ await page.goto(`/browse/${PROJECT}`);
+ await page.locator("[data-review-link]").click();
+ await expect(page).toHaveURL(new RegExp(`/browse/${PROJECT}/review$`));
+ // The narration and the teaser are drafted; a final build would refuse them.
+ const k01 = page.locator('[data-draft-row="narrate/k01/narration"]');
+ await expect(k01).toHaveAttribute("data-state", "unreviewed");
+ await expect(k01.locator("[data-draft-text]")).toHaveText("Half a year on, the county said yes.");
+ await expect(page.locator('[data-draft-row="teaser/t01/lines"]')).toBeVisible();
+ await expect(page.locator("[data-drafts-gate]")).toHaveAttribute("data-drafts-gate", "refuses");
+
+ // c01's title is the operator's: the draft that could not replace it is an
+ // alternative under it. Use this writes it as the operator's edit.
+ const alt = page.locator('[data-draft-alternatives="onscreen/c01/onscreen"]');
+ await expect(alt.locator("[data-draft-alternative-text]")).toHaveText("Kept aside title");
+ await alt.locator("[data-draft-use]").click();
+ await expect(alt).toHaveCount(0);
+ expect(entry("c01").onscreen).toEqual({ title: "Kept aside title" });
+ expect(entry("c01").drafted).toBeUndefined();
+
+ // Approve the narration here; the narration page shows who drafted it, and its state.
+ await k01.locator('[data-draft-action="approve"]').click();
+ await expect(k01).toHaveAttribute("data-state", "approved");
+ await page.goto(`/browse/${PROJECT}/narration`);
+ const card = page.locator('[data-narration-card="k01"]');
+ await expect(card.locator("[data-narration-drafted]")).toHaveText("drafted by qwen3:8b");
+ await expect(card).toHaveAttribute("data-state", "approved");
+});
+
+async function build(request: APIRequestContext, replace = false) {
+ const start = await request.post(`/api/report/build${replace ? "?replace=1" : ""}`, { data: { project: BUILD_PROJECT, preset: "final" } });
+ expect(start.ok(), await start.text()).toBeTruthy();
+ const { job } = (await start.json()) as { job: { id: string } };
+ let done: { state: string; error: string | null } = { state: "running", error: null };
+ const until = Date.now() + 240_000;
+ while (Date.now() < until) {
+ done = (await (await request.get(`/api/report/build?job=${job.id}`)).json()) as typeof done;
+ if (done.state !== "running") break;
+ await new Promise((r) => setTimeout(r, 400));
+ }
+ return done;
+}
+
+test("a final build refuses an unapproved draft, and builds once it is approved", async ({ page, request }) => {
+ test.setTimeout(360_000);
+ const refused = await build(request);
+ expect(refused.state).toBe("failed");
+ expect(JSON.stringify(refused)).toContain("timeline c02: its on-screen text (drafted by qwen3:8b) is not approved");
+ expect(existsSync(path.join(BUILD_DIR, "out", "draft-review-build-fixture.mp4"))).toBe(false);
+
+ await page.goto(`/browse/${BUILD_PROJECT}/review`);
+ const row = page.locator('[data-draft-row="onscreen/c02/onscreen"]');
+ await row.locator('[data-draft-action="approve"]').click();
+ await expect(row).toHaveAttribute("data-state", "approved");
+ await expect(page.locator("[data-drafts-gate]")).toHaveAttribute("data-drafts-gate", "passes");
+
+ const done = await build(request);
+ expect(done.state, done.error ?? "").toBe("done");
+ expect(existsSync(path.join(BUILD_DIR, "out", "draft-review-build-fixture.mp4"))).toBe(true);
+});
diff --git a/umtool/e2e/fixtures/draft-review-fixture.mjs b/umtool/e2e/fixtures/draft-review-fixture.mjs
@@ -0,0 +1,80 @@
+// What draft-review.spec.ts reviews (release 28, M0): two report projects whose
+// fields carry drafted marks, so the badges, the review page, "Use this" and
+// the final build's refusal have something to act on. Their own, so the other
+// specs' projects are never touched.
+//
+// reports/draft-review-fixture/ writable, deck off, never built:
+// c01 on-screen text written BY HAND (the operator's), and an
+// alternative for it in onscreen-draft.json (a draft that was not
+// allowed to replace it)
+// c02 on-screen text DRAFTED by qwen3:8b
+// k01 a chapter card whose narration was DRAFTED
+// t01 a teaser whose lines were DRAFTED by claude-sonnet-5-5
+// reports/draft-review-build-fixture/ two clips over the cached window, c02's
+// on-screen text DRAFTED: a final build refuses it until approved
+//
+// Synthetic, like every fixture.
+import { copyFileSync, mkdirSync, writeFileSync } from "node:fs";
+import path from "node:path";
+
+const AT = "2026-10-13T10:00:00.000Z";
+const P = (task, model = "qwen3:8b") => ({ task, model, at: AT, iteration: 1, attempt: 1 });
+
+const write = (dir, name, doc) => {
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(dir, name), JSON.stringify(doc, null, 2) + "\n");
+};
+
+/**
+ * @param {{ reports: string, manifest: Function, cachedWindow: string }} o
+ * `manifest` is make-fixture's manifest(slug, title, provenance, timeline);
+ * `cachedWindow` the vid1 0-9 s window the build fixtures share.
+ */
+export function makeDraftReviewFixture({ reports, manifest, cachedWindow }) {
+ const ui = path.join(reports, "draft-review-fixture");
+ write(
+ ui,
+ "video.manifest.json",
+ manifest("draft-review-fixture", "The Draft Review Fixture", { siteOrigin: "https://archive.example" }, [
+ { type: "clip", id: "c01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because", onscreen: { title: "Hand title" } },
+ {
+ type: "clip", id: "c02", video: "vid1", start: 9.0, end: 12.0, cite: 9, section: 0, lock: true, quote: "another whole sentence",
+ onscreen: { title: "Drafted title" }, drafted: { onscreen: P("onscreen") },
+ },
+ {
+ type: "card", id: "k01", style: "chapter", seconds: "auto", heading: "The county",
+ narration: { text: "Half a year on, the county said yes." }, drafted: { narration: P("narrate") },
+ },
+ {
+ type: "teaser", id: "t01", lines: ["Next Season", "The lease", "Spring 2027"],
+ drafted: { lines: P("teaser", "claude-sonnet-5-5") },
+ },
+ ]),
+ );
+ write(ui, "onscreen-draft.json", {
+ task: "onscreen",
+ model: "qwen3:8b",
+ at: AT,
+ article: "draft-review",
+ iteration: 1,
+ units: {},
+ checks: [],
+ alternatives: [{ target: { entry: "c01", field: "onscreen" }, value: { title: "Kept aside title" }, provenance: P("onscreen"), reason: "operator" }],
+ });
+
+ const build = path.join(reports, "draft-review-build-fixture");
+ write(
+ build,
+ "video.manifest.json",
+ manifest("draft-review-build-fixture", "The Draft Review Build Fixture", { siteOrigin: "https://archive.example" }, [
+ { type: "clip", id: "c01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because" },
+ {
+ type: "clip", id: "c02", video: "vid1", start: 9.0, end: 12.0, cite: 9, section: 0, lock: true, quote: "another whole sentence",
+ onscreen: { title: "Drafted title" }, drafted: { onscreen: P("onscreen") },
+ },
+ ]),
+ );
+ mkdirSync(path.join(build, "out", "clips-raw"), { recursive: true });
+ copyFileSync(cachedWindow, path.join(build, "out", "clips-raw", path.basename(cachedWindow)));
+ return { ui, build };
+}
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -25,6 +25,7 @@ import { songCapabilities } from "./song-capabilities.mjs";
import { makeSitesFixture } from "./sites-fixture.mjs";
import { makeIterationsFixture } from "./iterations-fixture.mjs";
import { makeDeleteFixture } from "./delete-fixture.mjs";
+import { makeDraftReviewFixture } from "./draft-review-fixture.mjs";
const CODE = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..", "..", "song");
const dest = path.resolve(process.argv[2] ?? path.join(process.cwd(), ".e2e-song"));
@@ -1652,6 +1653,10 @@ for (const dir of [BENCH, BUILD, ONSCREEN, ONSCREEN_BUILD, ONSCREEN_POSTS, ONSCR
);
}
+// Release 28: drafted fields to review, and a final build they hold
+// (draft-review.spec.ts).
+makeDraftReviewFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
+
// TWO MORE cached windows for vid1, and they are the regression rather than
// decoration.
//
@@ -1952,4 +1957,5 @@ console.log(` deliver-stop-fixture (writable: six confirmed clips to
console.log(` takes-fixture (writable: takes/ with 4 takes over 2 groups, 1 skipped)`);
console.log(` narration-fixture (writable: a narrated card, voiced by the editor stub's tone)`);
console.log(` narration-review-fixture (writable: two narrated cards, nothing judged)`);
+console.log(` draft-review-fixture (writable: drafted on-screen, narration, teaser; an alternative), draft-review-build-fixture`);
console.log(` ${taken} candidate files copied, 2 mix tracks synthesised`);
diff --git a/umtool/e2e/narration-review.spec.ts b/umtool/e2e/narration-review.spec.ts
@@ -8,19 +8,23 @@ import { fileURLToPath } from "node:url";
// card, before synthesis. Approve / reject (a note required) / edit the words
// (which un-approves them) / play one card through the editor -- the suite's
// stub, whose "voice" is an ffmpeg tone -- and a build that refuses what is not
-// approved once verdicts exist. Verdicts are narration.review.json beside the
-// manifest.
+// approved once verdicts exist. Verdicts are drafts.review.json beside the
+// manifest (release 28; release 25's narration.review.json is still read).
// ---------------------------------------------------------------------------
const HERE = path.dirname(fileURLToPath(import.meta.url));
const FIXTURE = path.join(HERE, "..", ".e2e-song");
const PROJECT = "reports/narration-review-fixture";
const DIR = path.join(FIXTURE, "reports", "narration-review-fixture");
-const REVIEW = path.join(DIR, "narration.review.json");
+// Since release 28 the verdicts are the drafts review's: a card's are
+// `narrate/<cardId>/narration` in drafts.review.json.
+const REVIEW = path.join(DIR, "drafts.review.json");
const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json");
-const review = (): Record<string, { verdict: string | null; note: string; text: string }> =>
- existsSync(REVIEW) ? JSON.parse(readFileSync(REVIEW, "utf8")) : {};
+const review = (): Record<string, { verdict: string | null; note: string; text: string }> => {
+ const all = existsSync(REVIEW) ? (JSON.parse(readFileSync(REVIEW, "utf8")) as Record<string, { verdict: string | null; note: string; text: string }>) : {};
+ return Object.fromEntries(Object.entries(all).map(([address, row]) => [address.replace(/^narrate\/(.+)\/narration$/, "$1"), row]));
+};
const manifest = () => JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")) as { timeline: { id: string; narration?: { text: string } }[] };
const ttsAsks = (): { route?: string; text?: string }[] => {
try {