Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit ba6611dc4a0f65dcb9ccfb3aff622370aa553004
parent a3bdce4d7974f9b209345271da7164956cf6563a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 13 Oct 2026 23:37:28 -0400

umtool: e2e media-surfaces.spec.ts — Draft with per section and Draft everything over the editor stub (r28 M9)

The stub answers every isStepTask step: the kit's article (mdraft) runs the
real task as lane D made it; the surfaces' article (msurf) is drafted
canned — each task's field through applyDraft with its mark, the
operator's field kept as an alternative, a written field skipped unless
force, a <task>-draft.json in the scaffold's shape, the step on the
iteration, progress as entries. Fixture msurf: two done iterations whose
projects build offline, the chain recorded done to its manifest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/e2e/fixtures/editor-stub.mjs | 152+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mumtool/e2e/fixtures/make-fixture.mjs | 3+++
Aumtool/e2e/fixtures/media-surfaces-fixture.mjs | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/e2e/media-surfaces.spec.ts | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 379 insertions(+), 2 deletions(-)

diff --git a/umtool/e2e/fixtures/editor-stub.mjs b/umtool/e2e/fixtures/editor-stub.mjs @@ -20,6 +20,7 @@ import { spawn, spawnSync } from "node:child_process"; import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync, statSync } from "node:fs"; import path from "node:path"; import { portFor } from "yt-dlp-transcript-common/lib/ports.mjs"; +import { applyDraft, draftedOf, isCodeDraft, makeProvenance, ownerOf } from "yt-dlp-transcript-common/lib/report/drafted.mjs"; import { fileURLToPath } from "node:url"; const PORT = portFor("EDITOR_STUB_PORT"); @@ -112,6 +113,9 @@ function writeWindow(dir, name, seconds) { // `iteration` continues a research run, as the editor does. // Sentinels: a question or feedback containing "slow" keeps running until // cancelled; feedback "refuse" is refused (400) as the editor refuses. +// A media draft (release 28) runs the real task over the kit's article +// (mdraft; startMediaDraft), canned over the surfaces' (msurf; +// startCannedDraft) — every isStepTask step answered. const ARTICLES = process.env.ARTICLES_DIR ?? ""; const GEN_PROJECTS = process.env.E2E_GEN_PROJECTS ?? ""; const PRESETS = { @@ -432,10 +436,148 @@ function startMediaDraft(body, id) { return { jobId: id, iteration: n }; } +// The surfaces' article (release 28 M9, media-surfaces-fixture.mjs) is drafted +// CANNED, every media task: its fixed value written through applyDraft — +// the mark, the operator's field never replaced (kept as an alternative), a +// field already written skipped unless force — and a `<task>-draft.json` +// beside the manifest in the scaffold's shape, the step recorded on the +// iteration and the job's progress reported as `entries`. What each task +// does on msurf's cuts (no deck, no teaser entry): +// cut its two clips swapped done +// onscreen a title and subtitle per clip (entries) done +// teaser refused by a check (the stub's) failed +// flips, threads no deck to draw on failed +// narrate a line on each card that has none done +// youtube a title and a summary done +const CANNED_ARTICLES = new Set(["msurf"]); +const MEDIA_TASKS = new Set(["cut", "onscreen", "teaser", "flips", "threads", "narrate", "youtube"]); +const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); + +function cannedUnits(task, m, body) { + const tl = m.timeline ?? []; + const pick = (es) => (Array.isArray(body.entries) ? es.filter((e) => body.entries.includes(e.id)) : es); + switch (task) { + case "cut": { + const clips = tl.filter((e) => e.type === "clip").map((e) => e.id); + const at = clips.slice(0, 2).map((id) => tl.findIndex((e) => e.id === id)); + const order = [...tl]; + if (at.length === 2) [order[at[0]], order[at[1]]] = [order[at[1]], order[at[0]]]; + return [{ id: "cut", target: { field: "timeline" }, value: order }]; + } + case "onscreen": + return pick(tl.filter((e) => e.type === "clip")).map((e) => ({ + id: e.id, + target: { entry: e.id, field: "onscreen" }, + value: { title: `What ${e.id} shows`, subtitle: "From the county vote" }, + })); + case "teaser": + return [{ id: "teaser", target: { entry: "teaser", field: "lines" }, value: ["The county", "The vote"], hard: ["(the stub) 2 lines: a teaser has 3 to 5"] }]; + case "flips": + case "threads": + return { refused: `the cut has no on-screen deck (render.chrome) to draw the ${task} on` }; + case "narrate": + return pick(tl.filter((e) => e.type === "card")).map((e) => ({ + id: e.id, + target: { entry: e.id, field: "narration" }, + value: { text: `${e.heading ?? "This part"}, as the channel told it.` }, + })); + case "youtube": + return [{ id: "youtube", target: { field: "publish.youtube" }, value: { title: "The county vote, as the channel told it", description: "The channel said it twice, and the county voted." } }]; + } + return []; +} + +function readFieldOf(m, t) { + if (t.entry) return (m.timeline ?? []).find((e) => e.id === t.entry)?.[t.field]; + if (t.field === "timeline") return m.timeline; + if (t.field === "publish.youtube") return m.publish?.youtube; + return undefined; +} + +function cannedRun(job, body) { + const { task, article, n } = job; + const it = readIt(article, n); + const dir = it.projectDir; + const file = path.join(dir, "video.manifest.json"); + const m = JSON.parse(readFileSync(file, "utf8")); + const model = body.model ?? generation.models.local; + const at = new Date().toISOString(); + const draftFile = path.join(dir, task === "narrate" ? "narration-draft.json" : `${task}-draft.json`); + const earlier = existsSync(draftFile) ? (JSON.parse(readFileSync(draftFile, "utf8")).alternatives ?? []) : []; + const units = {}; + const alternatives = []; + let applied = 0; + let summary; + const planned = cannedUnits(task, m, body); + if (!Array.isArray(planned)) { + summary = planned.refused; + } else { + planned.forEach((u, i) => { + job.progress = { metric: "entries", initial: 0, current: i, target: planned.length }; + const has = readFieldOf(m, u.target) !== undefined && !(u.target.field === "timeline" && isCodeDraft(draftedOf(m, u.target))); + if (has && !body.force) { + units[u.id] = { target: u.target, skipped: `the field has a value (${ownerOf(m, u.target)}'s): force re-drafts a draft` }; + return; + } + const chosen = { value: u.value, hard: u.hard ?? [], soft: [] }; + units[u.id] = { target: u.target, attempts: [chosen], chosen }; + if (chosen.hard.length) return; + const provenance = makeProvenance({ task, model, at, iteration: n, attempt: 1 }); + const force = !!body.force || (u.target.field === "timeline" && isCodeDraft(draftedOf(m, u.target))); + const r = applyDraft(m, { ...u.target, value: u.value, provenance, force }); + units[u.id].applied = r.applied ? "applied" : r.reason; + if (r.applied) applied++; + else alternatives.push({ target: u.target, value: u.value, provenance, reason: r.reason }); + }); + job.progress = { metric: "entries", initial: 0, current: planned.length, target: planned.length }; + if (applied) writeFileSync(file, JSON.stringify(m, null, 2) + "\n"); + const refused = Object.values(units).filter((u) => u.chosen?.hard?.length).length; + summary = + applied || alternatives.length + ? `${applied} ${task} field(s) drafted${alternatives.length ? `, ${alternatives.length} as alternatives (see ${path.basename(draftFile)})` : ""}` + : `no ${task} drafted (see ${path.basename(draftFile)})${refused ? `: ${refused} refused by a check` : ""}`; + } + const ok = applied > 0 || alternatives.length > 0; + writeFileSync( + draftFile, + JSON.stringify( + { task, model, at, article, iteration: n, units, checks: [{ name: task, ok, detail: summary }], alternatives: [...earlier, ...alternatives].slice(-5) }, + null, + 2, + ) + "\n", + ); + const status = ok ? "done" : "failed"; + const cur = readIt(article, n); + patchIt(article, n, { steps: cur.steps.map((s) => (s.jobId === job.id ? { ...s, status, endedAt: at, minutes: 0.1, detail: summary } : s)) }); + job.status = status; + job.log.push(`${task}: ${summary}`, `@@report-draft ${JSON.stringify({ article, iteration: n, task, status, summary })}`); +} + +function startCannedDraft(body, id) { + const { task, article } = body; + const n = body.iteration; + const it = readIt(article, n); + if (it.status !== "done") throw new Error(`"${article}" i${n} is ${it.status}: a ${task} draft runs over a done iteration`); + const model = body.model ?? generation.models.local; + patchIt(article, n, { steps: [...it.steps, { task, model, status: "running", startedAt: new Date().toISOString(), jobId: id }] }); + const job = { id, article, n, task, status: "queued", log: [`report-draft ${task} ${article} i${n} (stub: canned)`], timers: [] }; + draftJobs.set(id, job); + job.timers.push( + setTimeout(() => { + job.status = "running"; + job.progress = { metric: "entries", initial: 0, current: 0, target: 1 }; + job.log.push(`drafting the ${task} (stub)`); + }, 400), + ); + job.timers.push(setTimeout(() => cannedRun(job, body), 1600)); + return { jobId: id, iteration: n }; +} + function startDraft(body) { const { task, article } = body; const now = new Date().toISOString(); const id = `stub-draft-${nextJob++}`; + if (MEDIA_TASKS.has(task) && CANNED_ARTICLES.has(article)) return startCannedDraft(body, id); if (MEDIA_RUN.has(task)) return startMediaDraft(body, id); let n; if (task === "narrate") { @@ -490,7 +632,7 @@ function cancelDraft(id) { job.log.push("cancelled"); job.child?.kill(); const it = readIt(job.article, job.n); - if (job.task === "narrate" || MEDIA_RUN.has(job.task)) { + if (job.task === "narrate" || MEDIA_RUN.has(job.task) || MEDIA_TASKS.has(job.task)) { patchIt(job.article, job.n, { steps: it.steps.map((s) => (s.jobId === id ? { ...s, status: "cancelled" } : s)) }); } else { patchIt(job.article, job.n, { status: "cancelled", endedAt: new Date().toISOString() }); @@ -587,7 +729,13 @@ function generationRoute(req, res, url, auth) { const tail = Number(url.searchParams.get("tail") ?? 0); return json(res, 200, { ok: true, - job: { id: j.id, kind: j.kind ?? "report-draft", status: j.status, ...(j.status === "queued" ? { queue: { key: "draft:api", position: 1, queued: 2 } } : {}) }, + job: { + id: j.id, + kind: j.kind ?? "report-draft", + status: j.status, + ...(j.status === "queued" ? { queue: { key: "draft:api", position: 1, queued: 2 } } : {}), + ...(j.progress ? { progress: j.progress } : {}), + }, ...(tail ? { tail: j.log.slice(-tail) } : {}), }); } 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 { makeMediaDraftFixture } from "./media-draft-fixture.mjs"; +import { makeMediaSurfacesFixture } from "./media-surfaces-fixture.mjs"; import { makeDeleteFixture } from "./delete-fixture.mjs"; import { makeDraftReviewFixture } from "./draft-review-fixture.mjs"; import { makeYoutubeFixture } from "./youtube-fixture.mjs"; @@ -1922,6 +1923,8 @@ const { sites: SITES, articles: ARTICLES } = makeSitesFixture({ dest, reports, c makeIterationsFixture({ dest, articles: ARTICLES }); // Release 28: the media drafts' article (mdraft), one iteration per task. makeMediaDraftFixture({ dest, articles: ARTICLES }); +// Release 28 M9: "Draft with" and Draft everything (msurf), drafted canned by the stub. +makeMediaSurfacesFixture({ dest, articles: ARTICLES, manifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") }); // The release 27 follow-up's deletes: psi (in the making) and // reports/delete-fixture (a project with two takes); article-delete.spec.ts // writes its draft (omega) itself. diff --git a/umtool/e2e/fixtures/media-surfaces-fixture.mjs b/umtool/e2e/fixtures/media-surfaces-fixture.mjs @@ -0,0 +1,82 @@ +// What media-surfaces.spec.ts drafts on (release 28 M9): `msurf`, an article +// in the making whose two done iterations each have a video project that +// builds offline (two clips over the cached window the build fixtures share, +// a title card and a chapter card, no deck) — the chain recorded done to its +// manifest, so Draft everything starts at its first draft: +// +// articles/msurf/iterations/{1,2} sweep, qwen3:8b, done; current … manifest done +// gen-projects/msurf/i1/ "Draft with" on the project page: the cut +// (the converter's order), on-screen, and an +// operator's publish.youtube (forced: an alternative) +// gen-projects/msurf/i2/ Draft everything on the Iterations tab +// +// The editor stub drafts this article's media CANNED (editor-stub.mjs +// cannedDraft): every media task, its field written through applyDraft with its +// mark and a `<task>-draft.json` beside it. Synthetic: the fixture's own +// channel and invented lines. +import { copyFileSync, mkdirSync, writeFileSync } from "node:fs"; +import path from "node:path"; + +export const MEDIA_SURFACES_ARTICLE = "msurf"; +const AT = "2026-10-13T10:00:00.000Z"; +const CODE = { task: "convert", model: "code", at: "2026-10-13T00:00:00.000Z", attempt: 1 }; +const CITE = (start, end, quote) => ({ kind: "video", channel: "testchan", id: "vid1", start, end, quote, speaker: "Test Channel", date: "2024-03-15" }); + +const put = (file, value) => { + mkdirSync(path.dirname(file), { recursive: true }); + writeFileSync(file, typeof value === "string" ? value : JSON.stringify(value, null, 2) + "\n"); +}; + +/** + * @param {{ dest: string, articles: 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 makeMediaSurfacesFixture({ dest, articles, manifest, cachedWindow }) { + const report = { + format: "archilyzer-report", + version: 1, + id: MEDIA_SURFACES_ARTICLE, + kind: "sweep", + title: "The county vote, as the channel told it", + citations: { c01: CITE(3, 6, "and because"), c02: CITE(9, 12, "another whole sentence") }, + sections: [{ id: "s1", title: "The county", body: "She said it [and because](cite:c01), then [another whole sentence](cite:c02)." }], + }; + for (const n of [1, 2]) { + const dir = path.join(articles, MEDIA_SURFACES_ARTICLE, "iterations", String(n)); + const project = path.join(dest, "gen-projects", MEDIA_SURFACES_ARTICLE, `i${n}`); + put(path.join(dir, "iteration.json"), { + format: "archilyzer-iteration", + version: 1, + article: MEDIA_SURFACES_ARTICLE, + n, + kind: "sweep", + parent: null, + copyOf: null, + model: "qwen3:8b", + question: "What did the channel say about the county vote?", + scope: { channels: ["testchan"] }, + status: "done", + usage: {}, + steps: ["current", "windows", "prepare", "posts", "manifest"].map((s) => ({ task: `chain:${s}`, status: "done", startedAt: AT, endedAt: AT, minutes: 0.1, detail: "the fixture's" })), + projectDir: project, + createdAt: AT, + updatedAt: AT, + endedAt: AT, + }); + put(path.join(dir, "report.json"), report); + const m = manifest(`msurf-i${n}`, "The county vote", { siteOrigin: "https://archive.example" }, [ + { type: "card", id: "title", style: "title", seconds: 4, heading: "The county vote" }, + { type: "clip", id: "c01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because" }, + { type: "card", id: "k01", style: "chapter", seconds: 3, heading: "The county" }, + { type: "clip", id: "c02", video: "vid1", start: 9.0, end: 12.0, cite: 9, section: 0, lock: true, quote: "another whole sentence" }, + ]); + m.drafted = { timeline: CODE }; + // i1's YouTube text is the operator's: a forced draft is kept as an alternative. + if (n === 1) m.publish = { youtube: { title: "The operator's own title", description: "Written by hand." } }; + put(path.join(project, "video.manifest.json"), m); + put(path.join(project, "report.json"), report); + mkdirSync(path.join(project, "out", "clips-raw"), { recursive: true }); + copyFileSync(cachedWindow, path.join(project, "out", "clips-raw", path.basename(cachedWindow))); + } +} diff --git a/umtool/e2e/media-surfaces.spec.ts b/umtool/e2e/media-surfaces.spec.ts @@ -0,0 +1,144 @@ +import { test, expect } from "@playwright/test"; +import { existsSync, readFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { WARM_TIMEOUT, warm } from "./warm"; + +// --------------------------------------------------------------------------- +// Release 28 M9, the surfaces of the media drafts: +// - "Draft with <model>" per section on a project page: the job asked of the +// editor (its model, its entries, its force), followed to its end; then +// the section re-read — the badge, the last run, the alternative kept for +// the operator's field and Use this; a project made from no iteration +// offers none, and says why; +// - Draft everything on the Iterations tab: the chain with its drafts, a +// refused draft recorded failed and passed, the panels skipped, the +// voices, the fast build and the podcast, then the YouTube draft and +// out/youtube.txt. +// The editor stub drafts this article canned (fixtures/editor-stub.mjs +// cannedDraft); the build, the voices (the stub's tone) and the podcast are +// real. Fixture: fixtures/media-surfaces-fixture.mjs. +// --------------------------------------------------------------------------- + +const HERE = path.dirname(fileURLToPath(import.meta.url)); +const FIXTURE = path.join(HERE, "..", ".e2e-song"); +const STUB_LOG = path.join(FIXTURE, "editor-stub.requests.json"); +const ARTICLE = "msurf"; +const PROJECT = `gen-projects/${ARTICLE}/i1`; +const projectDir = (n: number) => path.join(FIXTURE, "gen-projects", ARTICLE, `i${n}`); +const manifestOf = (n: number) => JSON.parse(readFileSync(path.join(projectDir(n), "video.manifest.json"), "utf8")); +const asked = () => + (JSON.parse(readFileSync(STUB_LOG, "utf8")) as { route?: string; article?: string; [k: string]: unknown }[]).filter((r) => r.route === "report-draft" && r.article === ARTICLE); + +test.beforeAll(async ({ playwright }) => { + test.setTimeout(WARM_TIMEOUT); + await warm(playwright, [`/browse/${PROJECT}`, `/api/articles/draft?project=${encodeURIComponent(PROJECT)}`, "/api/articles/policy", `/articles/${ARTICLE}?tab=iterations`]); +}); + +test("Draft with <model> per section: the job followed, the badge, the last run, an alternative and Use this", async ({ page }) => { + test.setTimeout(180_000); + await page.goto(`/browse/${PROJECT}`); + const panel = page.getByRole("region", { name: "draft with a model" }); + await expect(panel).toHaveAttribute("data-draft-panel", `${ARTICLE}/i1`); + // Seven sections; flips and threads say why they cannot draft on this cut. + await expect(panel.locator("[data-draft-task]")).toHaveCount(7); + await expect(panel.locator("[data-draft-task='flips'] [data-draft-blocked]")).toContainText("this cut has none (render.chrome)"); + const cut = panel.locator("[data-draft-task='cut']"); + // The policy's models, the route's preselected. + await expect(cut.getByRole("combobox", { name: "model for the cut" })).toHaveValue("qwen3:8b"); + + // The cut: drafted over the converter's order; its badge and its review. + await cut.getByRole("combobox", { name: "model for the cut" }).selectOption("claude-sonnet-5-5"); + await cut.getByRole("button", { name: "Draft the cut" }).click(); + await expect(cut).toHaveAttribute("data-draft-job", "done", { timeout: 30_000 }); + expect(asked().at(-1)).toMatchObject({ task: "cut", article: ARTICLE, iteration: 1, model: "claude-sonnet-5-5", authorization: "Bearer umtool-e2e-token" }); + await expect(cut.locator("[data-draft-badge='cut/*/timeline'] [data-draft-by]")).toHaveText("drafted by claude-sonnet-5-5"); + await expect(cut.locator("[data-draft-run='cut']")).toContainText("1 written"); + expect(manifestOf(1).timeline.filter((e: { type: string }) => e.type === "clip").map((e: { id: string }) => e.id)).toEqual(["c02", "c01"]); + await cut.locator("[data-draft-badge='cut/*/timeline']").getByRole("button", { name: "Approve" }).click(); + await expect(cut.locator("[data-draft-badge='cut/*/timeline']")).toHaveAttribute("data-state", "approved"); + + // On-screen, limited to the entry ticked. + const onscreen = panel.locator("[data-draft-task='onscreen']"); + await onscreen.locator("summary").click(); + await onscreen.getByRole("checkbox", { name: "only c01 (on-screen titles)" }).check(); + await onscreen.getByRole("button", { name: "Draft on-screen titles" }).click(); + await expect(onscreen).toHaveAttribute("data-draft-job", "done", { timeout: 30_000 }); + expect(asked().at(-1)).toMatchObject({ task: "onscreen", entries: ["c01"] }); + await expect(onscreen.locator("[data-draft-run='onscreen']")).toContainText("1 written"); + const m = manifestOf(1); + const c01 = m.timeline.find((e: { id: string }) => e.id === "c01"); + expect(c01.onscreen).toEqual({ title: "What c01 shows", subtitle: "From the county vote" }); + expect(c01.drafted.onscreen).toMatchObject({ task: "onscreen", model: "qwen3:8b", iteration: 1 }); + expect(m.timeline.find((e: { id: string }) => e.id === "c02").onscreen).toBeUndefined(); + + // YouTube: the operator's text. Unforced, nothing to draft; forced, the + // draft is kept as an alternative, and Use this writes it. + const yt = panel.locator("[data-draft-task='youtube']"); + await yt.getByRole("button", { name: "Draft YouTube text" }).click(); + await expect(yt).toHaveAttribute("data-draft-job", "failed", { timeout: 30_000 }); + await expect(yt.locator("[data-draft-run='youtube']")).toContainText("1 skipped"); + await yt.getByRole("checkbox", { name: "force: re-draft YouTube text" }).check(); + await yt.getByRole("button", { name: "Draft YouTube text" }).click(); + await expect(yt.locator("[data-draft-run='youtube']")).toContainText("1 kept as an alternative", { timeout: 30_000 }); + expect(asked().at(-1)).toMatchObject({ task: "youtube", force: true }); + expect(manifestOf(1).publish.youtube.title).toBe("The operator's own title"); + const alt = yt.locator("[data-draft-alternatives='youtube/*/publish.youtube']"); + await expect(alt).toContainText("The county vote, as the channel told it"); + await alt.getByRole("button", { name: "Use this" }).click(); + await expect.poll(() => manifestOf(1).publish.youtube.title, { timeout: 15_000 }).toBe("The county vote, as the channel told it"); + // Taken, it is the operator's: no mark. + expect(manifestOf(1).drafted?.["publish.youtube"]).toBeUndefined(); + + // A project made from no iteration offers no draft, and says why. + await page.goto("/browse/reports/youtube-fixture"); + await expect(page.getByRole("region", { name: "draft with a model" }).locator("[data-draft-unlinked]")).toContainText("not made from an article's iteration"); +}); + +test("Draft everything: every draft in order on the model chosen, a refused one passed, the panels skipped, then the fast build, the podcast and out/youtube.txt", async ({ page }) => { + test.setTimeout(420_000); + await page.goto(`/articles/${ARTICLE}?tab=iterations`); + const two = page.locator("[data-iteration='2']"); + // The Iterations tab's per-step drafts, beside Narrate. + await expect(two.getByRole("combobox", { name: "draft task for i2" })).toBeVisible(); + await two.getByRole("combobox", { name: "Draft everything model for i2" }).selectOption("qwen3:8b"); + const before = asked().length; + await two.getByRole("button", { name: "Draft everything" }).click(); + const chain = page.getByRole("region", { name: "i2 Draft everything" }); + await expect(chain.locator("[data-chain-step]")).toHaveCount(15); + const step = (name: string) => chain.locator(`[data-chain-step='${name}']`); + await expect(step("draft-youtube")).toHaveAttribute("data-step-status", "done", { timeout: 360_000 }); + await expect(chain.locator("[data-chain-job]")).toHaveAttribute("data-chain-job", "done", { timeout: 30_000 }); + for (const [name, status] of [ + ["current", "done"], + ["manifest", "done"], + ["draft-cut", "done"], + ["draft-onscreen", "done"], + ["draft-teaser", "failed"], + ["draft-flips", "skipped"], + ["draft-threads", "skipped"], + ["draft-narrate", "done"], + ["voices", "done"], + ["video", "done"], + ["podcast", "done"], + ["draft-youtube", "done"], + ] as const) { + await expect(step(name), name).toHaveAttribute("data-step-status", status); + } + await expect(step("draft-flips")).toContainText("no on-screen deck"); + // The drafts the editor was asked for, in order, on the model chosen (flips + // and threads never asked: no deck to draw them on). + const drafts = asked().slice(before); + expect(drafts.map((r) => r.task)).toEqual(["cut", "onscreen", "teaser", "narrate", "youtube"]); + expect(drafts.every((r) => r.model === "qwen3:8b" && r.iteration === 2)).toBe(true); + const m = manifestOf(2); + expect(m.drafted.timeline).toMatchObject({ task: "cut", model: "qwen3:8b" }); + expect(m.timeline.find((e: { id: string }) => e.id === "k01").narration.text).toBe("The county, as the channel told it."); + expect(m.publish.youtube.title).toBe("The county vote, as the channel told it"); + // The fast build, the podcast and the YouTube text are on disk. + const out = path.join(projectDir(2), "out"); + expect(existsSync(path.join(out, "msurf-i2.mp4"))).toBe(true); + const text = readFileSync(path.join(out, "youtube.txt"), "utf8"); + expect(text.split("\n")[0]).toBe("The county vote, as the channel told it"); + expect(text).toContain("Sources"); +});