import { test, expect, type Page } from "@playwright/test"; import { rmSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { BOARD_CASE } from "./fixtures/research-fixture.mjs"; import * as urls from "./urls"; import { researchCaseHref } from "../lib/research/hrefs"; // --------------------------------------------------------------------------- // The piece page (plans/umtool-redesign.md, P4a-1): a report video's project // page is a frame -- the head (title, lifecycle chip, ⋯), the stage stepper, // the Next card on the Overview, seven link tabs -- around ONE tab of its // sections. The tab is the URL's `?tab=`; `1`–`7` switch tabs and `n` runs the // Next card's action once the page has hydrated. // --------------------------------------------------------------------------- const PROJECT = "reports/report-fixture"; const FIXTURE = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song"); const PIECE = `p:${PROJECT}`; const tab = (page: Page, id: string) => page.getByTestId(`piece-tab-${id}`); const keysReady = (page: Page) => expect(page.locator("[data-piece-keys=ready]")).toBeAttached(); test("the frame: title, trail, stepper at Video, the Next card, four tabs (L7b) with the workspace's lit on its Overview", async ({ page }) => { const res = await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); expect(res?.status()).toBe(200); const crumbs = page.getByRole("navigation", { name: "Breadcrumb" }); await expect(crumbs.locator("h1")).toHaveText("The Report Fixture"); await expect(crumbs).toContainText(PROJECT); // The status line is still the head's last .micro. await expect(page.locator("header .micro").last()).toHaveText(/4 clips · 2 other · 0:12 · not built/i); // A project no article claims is its own piece; unbuilt, it is at Video. const frame = page.locator(`[data-piece-frame="${PIECE}"]`); await expect(frame).toHaveAttribute("data-piece-stage", "video"); const steps = page.getByRole("list", { name: "Stage" }).locator("li"); await expect(steps).toHaveText([/^Research/, /^Article/, /^Video/, /^Deliver/]); await expect(steps.nth(2)).toHaveAttribute("aria-current", "step"); // No article claims it and no board made it: Research and Article do not apply, and say why. await expect(steps.nth(0)).toHaveAttribute("data-step", "na"); await expect(steps.nth(0)).toHaveAttribute("title", "no research board"); await expect(steps.nth(1)).toHaveAttribute("data-step", "na"); await expect(steps.nth(1)).toHaveAttribute("title", "no article"); await expect(steps.nth(3)).toHaveAttribute("data-step", "todo"); // Four tabs since the workspace (L7b): the Overview is one of its views, out of the tab bar. const tabs = page.getByRole("navigation", { name: "Piece" }).getByRole("link"); await expect(tabs).toHaveText([/^Workspace/, /^Sources/, /^Deliver/, /^History/]); await expect(tab(page, "workspace")).toHaveAttribute("aria-current", "page"); await expect(tab(page, "workspace")).toHaveAttribute("href", urls.workspaceHref(PROJECT)); await expect(tab(page, "workspace")).toHaveText("Workspace4"); await expect(tab(page, "sources")).toHaveText("Sources2"); // The Overview: the Next card, the project's decisions, its stats -- and none // of the other tabs' sections. await expect(page.locator("[data-next]:visible")).toBeVisible(); await expect(page.locator(`[data-project="${PROJECT}"]`)).toBeVisible(); await expect(page.locator("[data-piece-stats]")).toContainText("4 clips"); await expect(page.locator("[data-entry][data-kind]")).toHaveCount(0); await expect(page.locator("[data-sources]")).toHaveCount(0); await expect(page.getByTestId("onscreen-section")).toHaveCount(0); }); test("the Next card is the piece's top Inbox call, and its one action goes where the Inbox's does", async ({ page, request }) => { const inbox = (await (await request.get("/api/browse/decisions")).json()) as { groups: { id: string; cards: { piece: string | null; kind: string; action: { label: string; href: string } }[] }[]; }; const top = inbox.groups.filter((g) => g.id !== "quiet").flatMap((g) => g.cards).find((c) => c.piece === PIECE); expect(top, "the fixture's report has a call waiting").toBeTruthy(); await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const next = page.locator("[data-next]:visible"); await expect(next.locator("[data-next-kind]")).toHaveAttribute("data-next-kind", top!.kind); const action = next.locator("[data-next-action] > a:visible"); await expect(action).toHaveText(top!.action.label); await expect(action).toHaveAttribute("href", top!.action.href); await action.click(); await expect(page).toHaveURL(new RegExp(`${top!.action.href.replace(/[?]/g, "\\?")}$`)); }); test("the tab is the URL: ?tab=, ?all=1 on the Cut, a bad tab the Overview, and the old address lands", async ({ page }) => { await page.goto(urls.section(PROJECT, "sources")); await expect(tab(page, "sources")).toHaveAttribute("aria-current", "page"); await expect(page.locator("[data-sources]")).toBeVisible(); await expect(page.locator("[data-next]")).toHaveCount(0); // The cut's list and the Overview are the workspace's views (L7b): its tab is lit on them. await page.goto(urls.projectHref(PROJECT, { all: true })); await expect(page.locator("[data-piece-tab]")).toHaveAttribute("data-piece-tab", "cut"); await expect(tab(page, "workspace")).toHaveAttribute("aria-current", "page"); await expect(page.locator("[data-entry=c01][data-kind]")).toBeVisible(); await page.goto(`${urls.projectHref(PROJECT)}?tab=nonsense`); await expect(page.locator("[data-piece-tab]")).toHaveAttribute("data-piece-tab", "overview"); // /browse/ (before P3) rides the redirect to the project's own address: its workspace (L7a); // the Overview is written out. await page.goto(`/browse/${PROJECT}`); await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}$`)); await expect(page.locator(`[data-workspace="${PROJECT}"]`)).toBeVisible(); await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await expect(page.locator("[data-piece-tab]")).toHaveAttribute("data-piece-tab", "overview"); // Clicking a tab is a link: the address changes, the section is there. await tab(page, "history").click(); await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}\\?tab=history$`)); await expect(page.locator("[data-provenance]")).toBeVisible(); }); test("a note's link opens the tab its anchor is drawn on", async ({ page, request }) => { const add = await request.post(`/api/notes?project=${PROJECT}`, { data: { op: { op: "add", text: "this row is long", anchor: { kind: "entry", entry: "c02" } } }, }); expect(add.status()).toBe(200); const id = ((await add.json()) as { note: { id: string } }).note.id; try { await page.goto(urls.projectHref(PROJECT, { note: id })); await expect(page.locator("[data-piece-tab]")).toHaveAttribute("data-piece-tab", "cut"); await expect(page.locator("[data-anchored-notes='c02']")).toHaveAttribute("data-open-notes", "1"); } finally { await request.post(`/api/notes?project=${PROJECT}`, { data: { op: { op: "delete", id } } }); } }); test("the lifecycle chip: Park, then Reactivate, each a round trip through the store", async ({ page, request }) => { const life = async () => ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE) ?.lifecycle; try { await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const chip = page.locator("[data-lifecycle-chip]"); await expect(chip).toHaveAttribute("data-lifecycle-chip", "active"); await chip.getByRole("button", { name: "Lifecycle: Active" }).click(); await chip.getByRole("button", { name: "Park" }).click(); await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "parked"); await expect(page.locator(`[data-undo="${PIECE}"]`)).toContainText("Parked"); expect(await life()).toBe("parked"); // Parked, the piece's calls are hidden: the Next card offers the way back. await expect(page.locator("[data-next-kind=lifecycle]")).toContainText("Parked"); await expect(page.locator("[data-next-action] > button:visible")).toHaveText("Reactivate"); const chip2 = page.locator("[data-lifecycle-chip]"); await chip2.getByRole("button", { name: "Lifecycle: Parked" }).click(); await chip2.getByRole("button", { name: "Reactivate" }).click(); await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "active"); expect(await life()).toBe("active"); } finally { await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "active" } }); } }); test("the lifecycle chip: Mark done says it hid the piece from Active, and Undo puts it back", async ({ page, request }) => { const life = async () => ((await (await request.get("/api/pieces")).json()) as { pieces: { id: string; lifecycle: string }[] }).pieces.find((p) => p.id === PIECE) ?.lifecycle; try { await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); const chip = page.locator("[data-lifecycle-chip]"); await chip.getByRole("button", { name: "Lifecycle: Active" }).click(); await chip.getByRole("button", { name: "Mark done" }).click(); await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "done"); const bar = page.locator(`[data-undo="${PIECE}"]`); await expect(bar).toContainText("Marked done — hidden from Active."); expect(await life()).toBe("done"); await bar.getByRole("button", { name: "Undo" }).click(); await expect(bar).toHaveCount(0); await expect(page.locator("[data-lifecycle-chip]")).toHaveAttribute("data-lifecycle-chip", "active"); expect(await life()).toBe("active"); } finally { await request.post("/api/pieces/lifecycle", { data: { piece: PIECE, state: "active" } }); } }); test("keys: 1–4 open the tabs (1 the workspace), n runs the Next card's action; typing in a field is left alone", async ({ page }) => { await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await keysReady(page); await page.keyboard.press("2"); await expect(page).toHaveURL(/\?tab=sources$/); await expect(tab(page, "sources")).toHaveAttribute("aria-current", "page"); await keysReady(page); await page.keyboard.press("4"); await expect(page).toHaveURL(/\?tab=history$/); await keysReady(page); // The snapshot label is a field: a digit typed there is a digit. const label = page.locator("[data-revisions] input").first(); await label.fill(""); await label.press("3"); await expect(label).toHaveValue("3"); await expect(page).toHaveURL(/\?tab=history$/); await label.evaluate((el: HTMLElement) => el.blur()); await page.keyboard.press("1"); await expect(page.locator(`[data-workspace="${PROJECT}"]`)).toBeVisible({ timeout: 30_000 }); await page.goto(urls.projectHref(PROJECT, { tab: "overview" })); await keysReady(page); const href = await page.locator("[data-next-action] > a:visible").getAttribute("href"); await page.keyboard.press("n"); await expect(page).toHaveURL(new RegExp(`${href!.replace(/[?]/g, "\\?")}$`)); }); // ── the article-rooted piece (P4a-2) ───────────────────────────────────────── // zeta: an article in the making (four iterations, no report.json) whose i1 and // i3 made video projects; no current.json, so its Cut is the newest, i3. const ZETA = { site: "articles", id: "zeta" }; const ZETA_CUT = "gen-projects/zeta/i3"; const ZETA_OTHER = "gen-projects/zeta/i1"; test("an article piece: nine tabs, the stepper by what exists, the policy chip, its keys", async ({ page }) => { const res = await page.goto(urls.articleHref(ZETA)); expect(res?.status()).toBe(200); await expect(page.locator("[data-piece-frame='a:articles/zeta']")).toBeVisible(); const tabs = page.getByRole("navigation", { name: "Piece" }).getByRole("link"); await expect(tabs).toHaveText([/^Overview/, /^Article/, /^Iterations/, /^Cut/, /^Media/, /^Build/, /^Deliver/, /^Sources/, /^History/]); await expect(tab(page, "overview")).toHaveAttribute("aria-current", "page"); await expect(tab(page, "iterations")).toHaveText("Iterations4"); await expect(tab(page, "cut")).toHaveText("Cut1"); // The one stage rule: iterations (Research done), no report yet (Article to // do, and why), its iterations made a video (Video current), nothing delivered // -- the stage Work's facet shows too. const steps = page.getByRole("list", { name: "Stage" }).locator("li"); await expect(steps.nth(0)).toHaveAttribute("data-step", "done"); await expect(steps.nth(1)).toHaveAttribute("data-step", "todo"); await expect(steps.nth(1)).toHaveAttribute("title", "no report yet"); await expect(steps.nth(2)).toHaveAttribute("aria-current", "step"); await expect(steps.nth(3)).toHaveAttribute("data-step", "todo"); await expect(page.locator("[data-piece-frame='a:articles/zeta']")).toHaveAttribute("data-piece-stage", "video"); await page.goto(urls.workHref({ kind: "article" })); await expect(page.locator("[data-lit-line][data-piece='a:articles/zeta']")).toHaveAttribute("data-stage", "video"); await page.goto(urls.articleHref(ZETA)); // The policy is a chip linking its page, not the panel. await expect(page.locator("[data-policy-chip]")).toHaveAttribute("href", urls.generationPolicyHref()); await expect(page.locator("[data-policy-chip]")).toContainText("balanced"); await expect(page.getByRole("region", { name: "generation policy" })).toHaveCount(0); // The Overview: the Next card, the iterations, the Cut on show. await expect(page.locator("[data-next]:visible")).toBeVisible(); await expect(page.locator("[data-piece-iterations='4']")).toBeVisible(); await expect(page.locator(`[data-piece-cut='${ZETA_CUT}']`)).toContainText("Cut · i3"); await expect(page.locator("[data-piece-videos='2']")).toContainText("i1"); await keysReady(page); await page.keyboard.press("3"); await expect(page).toHaveURL(/\?tab=iterations$/); await expect(page.getByRole("region", { name: "iterations", exact: true })).toHaveAttribute("data-iterations", "4"); await keysReady(page); await page.keyboard.press("9"); await expect(page).toHaveURL(/\?tab=history$/); await expect(page.locator("[data-provenance]")).toBeVisible(); }); test("the video tabs are the claimed project's: the article's Cut, another by ?project=", async ({ page }) => { await page.goto(urls.articleHref(ZETA, { tab: "cut" })); await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); await expect(page.locator("[data-walk-start]")).toHaveAttribute("href", urls.clipBenchHref(ZETA_CUT, "a1")); await page.goto(urls.articleHref(ZETA, { tab: "cut", project: ZETA_OTHER })); await expect(page.locator("[data-walk-start]")).toHaveAttribute("href", urls.clipBenchHref(ZETA_OTHER, "a1")); // The other project rides along from tab to tab. await expect(tab(page, "build")).toHaveAttribute("href", urls.articleHref(ZETA, { tab: "build", project: ZETA_OTHER })); // An article with no video project says so on the video tabs. await page.goto(urls.articleHref({ site: "articles", id: "delta" }, { tab: "cut" })); await expect(page.locator("[data-video-none]")).toContainText("No video project yet"); }); test("a claimed project's address redirects to its article piece on the same tab; the benches stay and link back", async ({ page, request }) => { const at = async (href: string) => { const r = await request.get(href, { maxRedirects: 0 }); return { status: r.status(), location: r.headers()["location"] ?? "" }; }; expect(await at(urls.projectHref(ZETA_CUT, { tab: "build" }))).toEqual({ status: 307, location: urls.articleHref(ZETA, { tab: "build" }) }); expect(await at(urls.projectHref(ZETA_CUT, { tab: "overview" }))).toEqual({ status: 307, location: urls.articleHref(ZETA) }); // Its own address is its workspace (L7a): the video's one screen, claimed or not. expect((await at(urls.projectHref(ZETA_CUT))).status).toBe(200); expect(await at(urls.projectHref(ZETA_OTHER, { tab: "sources" }))).toEqual({ status: 307, location: urls.articleHref(ZETA, { tab: "sources", project: ZETA_OTHER }), }); expect(await at(urls.projectHref(ZETA_CUT, { all: true }))).toEqual({ status: 307, location: urls.articleHref(ZETA, { tab: "cut", all: true }) }); // A project no article claims is its own page. expect((await at(urls.projectHref(PROJECT))).status).toBe(200); // In a browser: the old /browse address rides both hops. await page.goto(`/browse/${ZETA_CUT}?tab=history`); await expect(page).toHaveURL(new RegExp(`/articles/zeta\\?tab=history$`)); await expect(tab(page, "history")).toHaveAttribute("aria-current", "page"); // The video's workspace is its own address: the article piece's ⋯ More leads there. await page.getByRole("button", { name: "More" }).click(); await expect(page.locator(`[data-primary-workspace="${ZETA_CUT}"]`)).toHaveAttribute("href", urls.workspaceHref(ZETA_CUT)); // The benches and kind views stay at the project's address, and lead back to the piece. expect((await at(urls.takesHref(ZETA_CUT))).status).toBe(200); expect((await at(urls.reviewHref(ZETA_CUT))).status).toBe(200); await page.goto(urls.clipBenchHref(ZETA_CUT, "a1")); await expect(page).toHaveURL(new RegExp(`${urls.clipBenchHref(ZETA_CUT, "a1")}$`)); await expect(page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "i3" })).toHaveAttribute( "href", urls.articleHref(ZETA, { tab: "cut" }), ); await page.goto(urls.clipBenchHref(ZETA_OTHER, "a1")); await expect(page.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "i1" })).toHaveAttribute( "href", urls.articleHref(ZETA, { tab: "cut", project: ZETA_OTHER }), ); }); test("a note on the video lands on its tab inside the article piece", async ({ page, request }) => { const add = await request.post(`/api/notes?project=${ZETA_CUT}`, { data: { op: { op: "add", text: "this clip runs long", anchor: { kind: "entry", entry: "a1" } } }, }); expect(add.status()).toBe(200); const id = ((await add.json()) as { note: { id: string } }).note.id; try { // The Inbox links the project's address; it lands on the article piece's Cut, the note kept last. const r = await request.get(urls.projectHref(ZETA_CUT, { note: id }), { maxRedirects: 0 }); expect(r.status()).toBe(307); expect(r.headers()["location"]).toBe(urls.articleHref(ZETA, { tab: "cut", note: id })); await page.goto(urls.projectHref(ZETA_CUT, { note: id })); await expect(page).toHaveURL(new RegExp(`[?&]note=${id}$`)); await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); await expect(page.locator("[data-anchored-notes='a1']")).toHaveAttribute("data-open-notes", "1"); // The article's own address with the note and no tab finds it on the video too. await page.goto(urls.articleHref(ZETA, { note: id })); await expect(tab(page, "cut")).toHaveAttribute("aria-current", "page"); } finally { await request.post(`/api/notes?project=${ZETA_CUT}`, { data: { op: { op: "delete", id } } }); } }); test("fits 1366×768: the head, the tabs and the Next card's action without a horizontal scroll", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); for (const href of [urls.projectHref(PROJECT, { tab: "overview" }), urls.articleHref(ZETA)]) { await page.goto(href); await expect(page.locator("[data-next-action] > :is(a, button):visible")).toBeInViewport(); await expect(tab(page, "history")).toBeInViewport(); const overflow = await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); expect(overflow, href).toBeLessThanOrEqual(0); } }); test("a video started from a research board: Research done, Article not applicable, the board linked", async ({ page, request }) => { const made = (await (await request.post("/api/research/cases", { data: { title: "Piece board" } })).json()) as { case: { id: string } }; const id = made.case.id; const slug = "piece-board-video"; try { const board = (await (await request.get(`/api/research/cases/${BOARD_CASE}`)).json()) as { case: { scope: { source: string }; quotes: { cite: { channel: string; video: string; t: number } }[] }; }; const q = board.case.quotes[0].cite; const pin = await request.post(`/api/research/cases/${id}/quotes`, { data: { source: board.case.scope.source, channel: q.channel, video: q.video, t: q.t } }); expect(pin.ok(), await pin.text()).toBe(true); const done = await request.post(`/api/research/cases/${id}/handoff`, { data: { to: "video", slug, confirm: true } }); expect(done.ok(), await done.text()).toBe(true); await page.goto(urls.projectHref(slug, { tab: "overview" })); const steps = page.getByRole("list", { name: "Stage" }).locator("li"); await expect(steps.nth(0)).toHaveAttribute("data-step", "done"); await expect(steps.nth(1)).toHaveAttribute("data-step", "na"); await expect(steps.nth(1)).toHaveAttribute("title", "no article"); await expect(page.locator(`[data-piece-board="${id}"] a`)).toHaveAttribute("href", researchCaseHref(id)); await expect(page.locator(`[data-piece-from-board="${id}"] a`)).toHaveText("Piece board"); } finally { await request.post("/api/projects/delete", { data: { project: slug, force: true } }); rmSync(path.join(FIXTURE, ".umtool", "research", id), { recursive: true, force: true }); } }); test("an article drafted from a research board: at Research (its sweep running, no report yet), the board in the head and on the Overview", async ({ page, request }) => { const made = (await (await request.post("/api/research/cases", { data: { title: "Piece article board" } })).json()) as { case: { id: string } }; const id = made.case.id; const article = "piece-board-article"; try { const board = (await (await request.get(`/api/research/cases/${BOARD_CASE}`)).json()) as { case: { scope: { source: string }; quotes: { cite: { channel: string; video: string; t: number } }[] }; }; const q = board.case.quotes[0].cite; const pin = await request.post(`/api/research/cases/${id}/quotes`, { data: { source: board.case.scope.source, channel: q.channel, video: q.video, t: q.t } }); expect(pin.ok(), await pin.text()).toBe(true); const done = await request.post(`/api/research/cases/${id}/handoff`, { data: { to: "article", article, confirm: true } }); expect(done.ok(), await done.text()).toBe(true); const { href } = (await done.json()) as { href: string }; expect(href).toBe(urls.articleHref({ site: "articles", id: article })); await page.goto(href); // The board's hand-off reached Research; nothing past it yet, so it is the current stage. const steps = page.getByRole("list", { name: "Stage" }).locator("li"); await expect(steps.nth(0)).toHaveAttribute("aria-current", "step"); await expect(steps.nth(1)).toHaveAttribute("data-step", "todo"); await expect(page.locator(`[data-piece-from-board="${id}"] a`)).toHaveText("Piece article board"); await expect(page.locator(`[data-piece-board="${id}"] a`)).toHaveAttribute("href", researchCaseHref(id)); } finally { rmSync(path.join(FIXTURE, ".umtool", "research", id), { recursive: true, force: true }); rmSync(path.join(FIXTURE, "articles", article), { recursive: true, force: true }); } }); // --------------------------------------------------------------------------- // The Media tab (P4b; canvas "Piece · Media"): ONE surface for every drafted // field -- its words, where it came from (the draft file, the model, the // attempt kept, the rule a refused attempt broke), approve or reject per // field and all at once -- with the on-screen panel moved in from Build. // fixtures/bench-shell-fixture.mjs: media-tab-fixture, written here alone. // --------------------------------------------------------------------------- test("the Media tab, folded into Deliver (L7b): every drafted field with where it came from, approve per field and all, on-screen and the build beside it", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); const P = "reports/media-tab-fixture"; await page.goto(urls.projectHref(P, { tab: "media" })); await expect(page).toHaveURL(new RegExp(`${urls.projectHref(P, { tab: "deliver" }).replace(/[?]/g, "\\?")}$`)); await expect(tab(page, "deliver")).toHaveAttribute("aria-current", "page"); // One number: the fields awaiting review -- the two drafted titles and the release-25 narration its // draft file records -- on the tab, in the header and on the Inbox's drafts card. await expect(tab(page, "deliver")).toHaveText("Deliver3"); const media = page.getByRole("region", { name: "Media drafts" }); await expect(media.locator("[data-media-counts]")).toHaveText("3 fields · 0 approved · 3 to review"); await expect(media.locator("[data-draft-row]")).toHaveCount(3); // Made from no iteration, it drafts nothing: the sections with fields, in Draft everything's order. await expect(media.locator("[data-media-section]")).toHaveCount(2); await expect(media.locator("[data-draft-unlinked]")).toHaveText("Drafting is off: no article iteration made this project."); const m01 = media.locator("[data-draft-row='onscreen/m01/onscreen']"); await expect(m01.locator("[data-draft-text]")).toContainText("She will not sell"); const prov = m01.locator("[data-draft-prov]"); for (const words of ["onscreen-draft.json", "by qwen3:8b", "attempt 2 of 2 chosen", "attempt 1 failed", "title over 60 characters", "not reviewed"]) { await expect(prov).toContainText(words); } // A release-25 narration: no mark in the manifest, its file says how it was made. const k01 = media.locator("[data-draft-row='narrate/k01/narration']").locator("[data-draft-prov]"); await expect(k01).toContainText("narration-draft.json"); await expect(k01).toContainText("text in quotation marks"); // Signal on the lit field's Approve draft only. await expect(media.locator("[data-draft-action=approve].bg-signal")).toHaveCount(1); // A chip narrows the list to its section. await media.locator("[data-media-chip=narrate]").click(); await expect(media.locator("[data-media-section]")).toHaveCount(1); await expect(media.locator("[data-draft-row]")).toHaveCount(1); await media.locator("[data-media-chip=all]").click(); await expect(media.locator("[data-draft-row]")).toHaveCount(3); // The Inbox's drafts card counts the same three fields. const before = (await (await page.request.get("/api/browse/decisions")).json()) as { items: { kind: string; project?: string }[] }; expect(before.items.filter((d) => d.kind === "drafts-unreviewed" && d.project === P)).toHaveLength(3); // Approve one, then all the rest. const m02 = media.locator("[data-draft-row='onscreen/m02/onscreen']"); await m02.locator("[data-draft-action=approve]").click(); await expect(m02).toHaveAttribute("data-state", "approved"); await expect(media.locator("[data-approve-all]")).toHaveText("Approve all 2"); await media.locator("[data-approve-all]").click(); await expect(media.locator("[data-draft-row][data-state=approved]")).toHaveCount(3); await expect(media.locator("[data-drafts-gate]")).toHaveAttribute("data-drafts-gate", "passes"); await expect(media.locator("[data-approve-all]")).toHaveCount(0); // Nothing awaits review: the tab says no number, and the Inbox has no drafts card for it. await page.reload(); await expect(tab(page, "deliver")).toHaveText("Deliver"); const inbox = (await (await page.request.get("/api/browse/decisions")).json()) as { items: { kind: string; project?: string }[] }; expect(inbox.items.filter((d) => d.kind === "drafts-unreviewed" && d.project === P)).toEqual([]); // The on-screen panel and the build, on Deliver both (Build folded in too). await expect(page.getByTestId("onscreen-section")).toBeVisible(); const w = await page.evaluate(() => document.documentElement.scrollWidth); expect(w).toBeLessThanOrEqual(1366); await page.goto(urls.projectHref(P, { tab: "build" })); await expect(page).toHaveURL(new RegExp(`${urls.projectHref(P, { tab: "deliver" }).replace(/[?]/g, "\\?")}$`)); await expect(page.getByTestId("onscreen-section")).toBeVisible(); await expect(page.locator("[data-build-options]")).toBeVisible(); });