import { test, expect, type Page, type Route } from "@playwright/test"; import { readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { BOARD_CASE, DRIFTED_QUOTE, EN_REWRITE, RESEARCH_PHRASE } from "./fixtures/research-fixture.mjs"; import { researchCaseHref, researchHref } from "../lib/research/hrefs"; import { WARM_TIMEOUT, warm } from "./warm"; // --------------------------------------------------------------------------- // Research boards (plans/umtool-redesign.md, R2) on the research fixture // corpus (e2e/fixtures/research-fixture.mjs) and its board, `fixture-board` // (a drifted quote, an intact one, one quoted from the served `en` track): // a case made from a pin, pins from the results (p) and from the reader, // sections and order by the keys, the claim and the note, the export, the // re-verify, and the hand-offs' plans. // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); const FIXTURE = path.join(HERE, "..", ".e2e-song"); const caseJson = (id: string) => JSON.parse(readFileSync(path.join(FIXTURE, ".umtool", "research", id, "case.json"), "utf8")); const results = (page: Page) => page.getByRole("group", { name: "Results" }); const reader = (page: Page) => page.getByRole("complementary", { name: "Reader" }); const board = (page: Page) => page.getByRole("group", { name: "Board" }); const litId = (page: Page) => board(page).locator("[data-lit-line][data-lit]"); const status = (page: Page) => page.locator("[data-board-status]"); /** * Hold the next board write matching `method` and `part` at the network: it * reaches the server only on `release()`. While it is held the board is * settling, deterministically, for as long as the spec needs. */ async function holdNext(page: Page, method: string, part: string) { let release!: () => void; const gate = new Promise((r) => (release = r)); let arrived!: () => void; const seen = new Promise((r) => (arrived = r)); let taken = false; const pattern = "**/api/research/cases/**"; const handler = async (route: Route) => { const req = route.request(); if (!taken && req.method() === method && req.url().includes(part)) { taken = true; arrived(); await gate; } await route.continue(); }; await page.route(pattern, handler); return { seen, release, done: () => page.unroute(pattern, handler) }; } /** * Open a board and wait until its keys are live (hydrated, every listener * attached: `data-board-keys="ready"`). Before that a key is the browser's: * the slips are server-drawn, but nothing on the page listens yet. */ async function openBoard(page: Page, id: string) { await page.goto(researchCaseHref(id)); await expect(page.locator('[data-board-keys="ready"]')).toHaveCount(1); } async function searched(page: Page) { await page.goto(researchHref({ q: RESEARCH_PHRASE })); await expect(page.locator("[data-honest]")).toBeVisible({ timeout: 30_000 }); } test.beforeAll(async ({ playwright }) => { test.setTimeout(WARM_TIMEOUT); await warm(playwright, [researchHref(), researchCaseHref(BOARD_CASE), "/api/research/cases"]); }); test("Research lists the cases; a board shows its slips, flags and side panel", async ({ page }) => { await page.goto(researchHref()); const cases = page.getByRole("group", { name: "Cases" }); await expect(cases.locator(`[data-case="${BOARD_CASE}"]`)).toContainText("Fixture board"); await expect(cases.locator(`[data-case="${BOARD_CASE}"]`)).toContainText("3 quotes · 1 section"); await cases.getByRole("link", { name: "Fixture board" }).click(); await expect(page).toHaveURL(new RegExp(`/research/${BOARD_CASE}$`)); await expect(page.getByRole("navigation", { name: "Breadcrumb" }).locator("h1")).toHaveText("Fixture board"); await expect(page.locator("[data-board-meta]")).toHaveText("3 quotes · 1 section · from “lighthouse budget” · Local corpus"); // The rail lights Research. await expect(page.locator('a[aria-current][href="/research"]')).toBeVisible(); const b = board(page); await expect(b.locator("[data-quote]")).toHaveCount(3); await expect(b.locator('[data-quote="q1"] [data-slip]')).toContainText(`“${DRIFTED_QUOTE.was}”`); await expect(b.locator('[data-quote="q1"] [data-cite]')).toContainText("Harbor Radio 80: the council vote · Harbor Radio · 2022-02-11 · 34:04"); await expect(b.locator('[data-section="s1"]')).toContainText("The vote"); await expect(b.locator('[data-quote="q2"] [data-speaker]')).toHaveAttribute("data-speaker", "checked"); await expect(b.locator('[data-quote="q1"] [data-speaker]')).toHaveText("Speaker not checked"); const facts = page.locator("[data-case-facts]"); await expect(facts).toContainText(`.umtool/research/${BOARD_CASE}/`); await expect(facts).toContainText(`c:${BOARD_CASE}`); await expect(page.locator("[data-searched]")).toHaveText("nothing yet"); }); test("pin from the results with p (a new case, named on the way) and from the reader; the search becomes the case's", async ({ page }) => { await searched(page); const first = results(page).locator("[data-lit-line][data-lit]"); await expect(first).toHaveAttribute("data-lit-id", "harbor-radio/hr-2019a|0"); await expect(reader(page).locator("[data-citation]")).toContainText("Harbor Radio 1: the old pier"); await page.keyboard.press("p"); const dialog = page.locator("dialog[data-pin-dialog]"); await expect(dialog).toBeVisible(); await dialog.getByRole("textbox", { name: "New case title" }).fill("Lighthouse case"); await dialog.getByRole("button", { name: "New case and pin" }).click(); await expect(dialog).toBeHidden(); await expect(reader(page).locator("[data-pinned]")).toContainText("Pinned to “Lighthouse case” · 1 quote"); await expect(page.getByRole("combobox", { name: "Board" })).toHaveValue("lighthouse-case"); expect(new URL(page.url()).searchParams.get("case")).toBe("lighthouse-case"); // From the reader: another hit, the reader's Pin to board. await results(page).locator('[data-lit-id="night-desk/nd-2023|0"]').click(); await expect(reader(page).locator("[data-citation]")).toContainText("Night Desk: the keeper @ 6:40"); await reader(page).getByRole("button", { name: "Pin to board" }).click(); await expect(reader(page).locator("[data-pinned]")).toContainText("Pinned to “Lighthouse case” · 2 quotes"); // The same cite again is not a second quote. await page.keyboard.press("p"); await expect(reader(page).locator("[data-pinned]")).toContainText("Already on “Lighthouse case” (q2)"); const doc = caseJson("lighthouse-case"); expect(doc.quotes.map((q: { text: string }) => q.text)).toEqual(["the lighthouse budget was never approved", "the keeper never saw the lighthouse budget"]); expect(doc.quotes[1].cite).toMatchObject({ channel: "night-desk", video: "nd-2023", t: 400, url: "https://archive.example/?v=night-desk%2Fnd-2023&t=400" }); expect(doc.search).toMatchObject({ query: RESEARCH_PHRASE, total: 8, complete: true }); expect(doc.sessions).toEqual([doc.search.session]); expect(doc.scope).toMatchObject({ query: RESEARCH_PHRASE }); // A third, for the board's moves below. await results(page).locator('[data-lit-id="harbor-radio/hr-2021a|0"]').click(); await page.keyboard.press("p"); await expect(reader(page).locator("[data-pinned]")).toContainText("3 quotes"); await reader(page).getByRole("link", { name: "Open board" }).click(); await expect(page).toHaveURL(/\/research\/lighthouse-case$/); await expect(page.locator("[data-searched]")).toHaveText("8 recordings, complete"); await expect(page.locator("[data-read]")).toHaveText("0 of 8"); }); test("sections and order: a, alt+j/k across sections, the section menu; claim, note and speaker saved", async ({ page }) => { await openBoard(page, "lighthouse-case"); const b = board(page); await expect(b.locator("[data-quote]")).toHaveCount(3); await page.locator("body").click(); for (const title of ["Approval", "The keeper"]) { await page.keyboard.press("a"); await page.getByRole("textbox", { name: "Title" }).fill(title); await page.getByRole("button", { name: "Add section" }).click(); await expect(b.locator("[data-section]", { hasText: title })).toBeVisible(); } expect(caseJson("lighthouse-case").sections).toEqual([{ id: "s1", title: "Approval" }, { id: "s2", title: "The keeper" }]); // Light q1 and move it: down past q2, then on into the top of Approval. await b.locator('[data-quote="q1"]').click({ position: { x: 8, y: 8 } }); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); // Two moves pressed at once: the second waits for the first's answer and is // applied after it, never dropped -- q1 goes past q2, then past q3. await page.keyboard.press("Alt+j"); await page.keyboard.press("Alt+j"); await expect.poll(() => caseJson("lighthouse-case").quotes.map((q: { id: string }) => q.id).join(" ")).toBe("q2 q3 q1"); await expect(page.locator("[data-board-busy]")).toHaveCount(0); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); await page.keyboard.press("Alt+j"); await expect.poll(() => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === "q1").section).toBe("s1"); await expect(b.locator('[data-group="s1"] [data-quote="q1"]')).toBeVisible(); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); // And back up: alt+k. await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); await page.keyboard.press("Alt+k"); // The claim (e) pressed while that move is still answering (R5: the list // redraws on the answer, which used to take the field's focus away and send // the typing to the line as commands): the field waits for the redraw, then // takes the focus. await page.keyboard.press("e"); await expect.poll(() => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === "q1").section).toBe(null); await expect(page.locator("[data-board-busy]")).toHaveCount(0); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); // The claim (e) and the note (n), saved on Enter; the speaker check (s). await expect(b.locator('[data-quote="q1"] [data-field="claim"]')).toBeFocused(); await page.keyboard.type("The budget was never approved"); await page.keyboard.press("Enter"); await expect(litId(page)).toBeFocused(); await page.keyboard.press("n"); await page.keyboard.type("Harbor Radio's host"); await page.keyboard.press("Enter"); await page.keyboard.press("s"); await expect(b.locator('[data-quote="q1"] [data-speaker]')).toHaveAttribute("data-speaker", "checked"); await expect.poll(() => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === "q1")).toMatchObject({ claim: "The budget was never approved", note: "Harbor Radio's host", speakerChecked: true, }); // The section menu (m) puts the keeper's quote under The keeper. await b.locator('[data-quote="q2"]').click({ position: { x: 8, y: 8 } }); await page.keyboard.press("m"); await expect(b.locator('[data-quote="q2"] [data-field="section"]')).toBeFocused(); await b.locator('[data-quote="q2"] [data-field="section"]').selectOption({ label: "The keeper" }); await expect(b.locator('[data-group="s2"] [data-quote="q2"]')).toBeVisible(); // A section moves too: The keeper above Approval. await b.locator('[data-section="s2"]').click(); await page.keyboard.press("Alt+k"); await expect.poll(() => caseJson("lighthouse-case").sections.map((s: { id: string }) => s.id).join(" ")).toBe("s2 s1"); }); // THE RACES (root-caused after P6a): every key below is pressed while a board // write is HELD at the network, so the board is settling for certain. Each // key must wait for it and then act on the redrawn board -- not on lines and // fields the answer replaces. On the board as test 102 left it: Unsorted q3, // q1; The keeper q2; Approval. test("keys pressed while a write is held wait for it, then act on the settled board", async ({ page }) => { await openBoard(page, "lighthouse-case"); const b = board(page); await expect(b.locator("[data-quote]")).toHaveCount(3); const busy = page.locator("[data-board-busy]"); const quote = (id: string) => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === id); // Unsorted's order (the case's `quotes` array is the board's order). const order = () => caseJson("lighthouse-case") .quotes.filter((q: { section: string | null }) => q.section === null) .map((q: { id: string }) => q.id) .join(" "); await expect.poll(order).toBe("q3 q1"); await b.locator('[data-quote="q3"]').click({ position: { x: 8, y: 8 } }); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q3"); // 1. A move held; `e`, a claim and Enter typed under it. The claim's letters // are board commands (r renames the case, a adds a section, c copies, v // re-verifies, x removes): none may act; all of it is the claim. let h = await holdNext(page, "PATCH", "/cases/lighthouse-case"); await page.keyboard.press("Alt+j"); await h.seen; await page.keyboard.press("e"); await page.keyboard.type("Recorded at the vote, x-ray"); await page.keyboard.press("Enter"); await expect(busy).toHaveCount(1); await expect(page.locator("dialog[open]")).toHaveCount(0); expect(quote("q3").claim).toBe(""); h.release(); await expect.poll(() => quote("q3").claim).toBe("Recorded at the vote, x-ray"); await expect(busy).toHaveCount(0); await h.done(); expect(order()).toBe("q1 q3"); expect(caseJson("lighthouse-case").title).toBe("Lighthouse case"); await expect(page.locator("dialog[open]")).toHaveCount(0); await expect(b.locator('[data-quote="q3"] [data-field="claim"]')).toHaveValue("Recorded at the vote, x-ray"); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q3"); // 2. A note's save held; `s` twice under it. Each toggle is computed on the // quote as the write before it left it: on, then off -- in that order, // and the view says what the file says. const speaker: boolean[] = []; page.on("request", (r) => { if (r.method() === "PATCH" && r.url().includes("/quotes/q3")) { const body = r.postDataJSON() as { speakerChecked?: boolean }; if (typeof body.speakerChecked === "boolean") speaker.push(body.speakerChecked); } }); h = await holdNext(page, "PATCH", "/quotes/q3"); await page.keyboard.press("n"); await page.keyboard.type("held note"); await page.keyboard.press("Enter"); await h.seen; await page.keyboard.press("s"); await page.keyboard.press("s"); await expect(busy).toHaveCount(1); h.release(); await expect(busy).toHaveCount(0); await h.done(); expect(speaker).toEqual([true, false]); expect(quote("q3")).toMatchObject({ note: "held note", speakerChecked: false }); await expect(b.locator('[data-quote="q3"] [data-speaker]')).toHaveAttribute("data-speaker", "unchecked"); // 3. A move held; `j` under it moves the light on the REDRAWN list: from q3, // put back above q1, to q1 (the old list would have lit what came after // q3 where it was, and the redraw then took the light back). h = await holdNext(page, "PATCH", "/cases/lighthouse-case"); await page.keyboard.press("Alt+k"); await h.seen; await page.keyboard.press("j"); h.release(); await expect.poll(order).toBe("q3 q1"); await expect(busy).toHaveCount(0); await h.done(); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); // 4. A save held; `a`, a title and Enter under it add a section once it has // answered (the dialog's field takes the focus); `x` then Escape under // another leave every quote where it is. await page.keyboard.press("k"); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q3"); h = await holdNext(page, "PATCH", "/quotes/q3"); await page.keyboard.press("s"); await h.seen; await page.keyboard.press("a"); await page.keyboard.type("Held section"); await page.keyboard.press("Enter"); await expect(page.locator("dialog[open]")).toHaveCount(0); h.release(); await expect.poll(() => caseJson("lighthouse-case").sections.map((s: { title: string }) => s.title)).toEqual(["The keeper", "Approval", "Held section"]); await expect(busy).toHaveCount(0); await h.done(); expect(quote("q3").speakerChecked).toBe(true); await b.locator('[data-quote="q3"]').click({ position: { x: 8, y: 8 } }); h = await holdNext(page, "PATCH", "/quotes/q3"); await page.keyboard.press("s"); await h.seen; await page.keyboard.press("x"); await page.keyboard.press("Escape"); h.release(); await expect(busy).toHaveCount(0); await h.done(); await expect(page.locator("dialog[open]")).toHaveCount(0); await expect(b.locator("[data-quote]")).toHaveCount(3); expect(quote("q3").speakerChecked).toBe(false); // Put the board back as the tests below expect it: no extra section, q3's // claim and note cleared. const sections = caseJson("lighthouse-case").sections.filter((s: { title: string }) => s.title !== "Held section"); expect((await page.request.patch("/api/research/cases/lighthouse-case", { data: { sections } })).ok()).toBe(true); expect((await page.request.patch("/api/research/cases/lighthouse-case/quotes/q3", { data: { claim: "", note: "" } })).ok()).toBe(true); expect(order()).toBe("q3 q1"); }); // THE REDRAW GAPS (race 3, after R6.1). A write's answer is applied before it // is drawn (React commits it in a later task), and the commit's passive effects // -- the moved line's refocus, the remounted list's light and j/k listener -- // run later still. A key landing in either gap acted on a list or a focus about // to change: `e` focused the claim, then the deferred refocus put the focus // back on the line, and the claim typed next went nowhere (or ran as board // commands). Under load the gaps are wide; here each is hit for certain, from // inside the page (spec-only hooks): // answer the page's Response.json is wrapped: `e` is dispatched 50 // microtasks after the held move's answer is read -- after the write, // before any task, so before the commit; // commit a MutationObserver sees the remounted list arrive: `e` is // dispatched in its callback -- after the commit, before the passive // effects' task. // Each time the key (`e`, then `n`) must wait, then focus its field, and what // is typed next must be saved whole. async function gapRound(page: Page, hook: "answer" | "commit", key: "e" | "n", text: string, dir: "Alt+j" | "Alt+k") { const h = await holdNext(page, "PATCH", "/cases/lighthouse-case"); await page.keyboard.press(dir); await h.seen; await page.evaluate(([hook, key]) => { const w = window as unknown as { __gap?: string }; const send = () => { const el = (document.activeElement as HTMLElement | null) ?? document.body; el.dispatchEvent(new KeyboardEvent("keydown", { key, code: `Key${key.toUpperCase()}`, bubbles: true, cancelable: true })); w.__gap = "sent"; }; w.__gap = "armed"; if (hook === "answer") { const json = Response.prototype.json; Response.prototype.json = function (this: Response) { const p = json.call(this); if (w.__gap === "armed" && this.url.endsWith("/api/research/cases/lighthouse-case")) { w.__gap = "answered"; Response.prototype.json = json; void p.then(async () => { for (let i = 0; i < 50; i++) await null; send(); }); } return p; }; } else { const root = document.querySelector("[data-board-keys]")!; const mo = new MutationObserver((records) => { const remounted = records.some((r) => [...r.addedNodes].some((n) => n instanceof HTMLElement && n.matches("[data-lit-list]"))); if (!remounted) return; mo.disconnect(); send(); }); mo.observe(root, { childList: true, subtree: true }); } }, [hook, key] as const); h.release(); await page.waitForFunction(() => (window as unknown as { __gap?: string }).__gap === "sent"); await page.keyboard.type(text); await page.keyboard.press("Enter"); await expect(page.locator("[data-board-busy]")).toHaveCount(0); await h.done(); } test("a key in the gap between a write's answer and its redraw, or its redraw and its effects, waits for both", async ({ page }) => { await openBoard(page, "lighthouse-case"); const b = board(page); await expect(b.locator("[data-quote]")).toHaveCount(3); const quote = (id: string) => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === id); const order = () => caseJson("lighthouse-case") .quotes.filter((q: { section: string | null }) => q.section === null) .map((q: { id: string }) => q.id) .join(" "); await expect.poll(order).toBe("q3 q1"); await b.locator('[data-quote="q3"]').click({ position: { x: 8, y: 8 } }); await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q3"); await gapRound(page, "answer", "e", "Recorded in the gap", "Alt+j"); await expect.poll(() => quote("q3").claim).toBe("Recorded in the gap"); expect(order()).toBe("q1 q3"); await expect(litId(page)).toBeFocused(); await gapRound(page, "commit", "n", "Noted after the redraw", "Alt+k"); await expect.poll(() => quote("q3").note).toBe("Noted after the redraw"); expect(quote("q3").claim).toBe("Recorded in the gap"); expect(order()).toBe("q3 q1"); expect(caseJson("lighthouse-case").title).toBe("Lighthouse case"); await expect(page.locator("dialog[open]")).toHaveCount(0); // Back as the tests below expect it. expect((await page.request.patch("/api/research/cases/lighthouse-case/quotes/q3", { data: { claim: "", note: "" } })).ok()).toBe(true); }); test("the export: cited markdown in the house format, copied and downloadable", async ({ page, context, request }) => { const md = await (await request.get("/api/research/cases/lighthouse-case/export.md")).text(); const heads = md.split("\n").filter((l) => l.startsWith("#")); expect(heads[0]).toBe("# Lighthouse case"); expect(heads.at(-1)).toBe("## Coverage"); expect(heads).toContain("## The keeper"); expect(md).toContain( '- The budget was never approved: "the lighthouse budget was never approved" — [Harbor Radio 1: the old pier @ 10:00](https://archive.example/?v=harbor-radio%2Fhr-2019a&t=600)\n Note: Harbor Radio\'s host.', ); expect(md).toContain("Searched for “lighthouse budget”: 8 recordings, complete. Read 0 of 8. 3 pinned."); const dl = await request.get("/api/research/cases/lighthouse-case/export.md?download=1"); expect(dl.headers()["content-disposition"]).toBe('attachment; filename="lighthouse-case.md"'); await context.grantPermissions(["clipboard-read", "clipboard-write"]); await openBoard(page, "lighthouse-case"); await expect(board(page).locator("[data-quote]")).toHaveCount(3); await page.locator("body").click(); await page.keyboard.press("c"); await expect(status(page)).toContainText("Copied the board as cited markdown"); expect(await page.evaluate(() => navigator.clipboard.readText())).toBe(md); }); test("hand-offs: an article's plan (the model and cap, a seeded sweep) and a video's (the cue spans); local-only refused", async ({ page, request }) => { await openBoard(page, "lighthouse-case"); await page.getByRole("button", { name: "Draft an article from this board" }).click(); const art = page.locator('dialog[data-handoff="article"]'); await expect(art).toContainText("lighthouse-case"); await expect(art).toContainText("the board as cited markdown: 3 quotes"); await expect(art).toContainText(/Runs on\s*claude-/); await expect(art.getByRole("button", { name: /^Start the sweep/ })).toBeEnabled(); await art.getByRole("button", { name: "Cancel" }).click(); await expect(art).toBeHidden(); await page.getByRole("button", { name: "Start a video from this board" }).click(); const vid = page.locator('dialog[data-handoff="video"]'); await expect(vid).toContainText("3 — each the cue span of a pinned quote"); // Board order: Unsorted (q3, q1), then The keeper (q2). await expect(vid).toContainText("c00 harbor-radio/hr-2021a 1212–1215.8"); await expect(vid).toContainText("c01 harbor-radio/hr-2019a 600–603.8"); await expect(vid).toContainText("https://archive.example"); await expect(vid.getByRole("button", { name: "Create the project" })).toBeEnabled(); await page.keyboard.press("Escape"); await expect(vid).toBeHidden(); // Nothing was written by a plan. expect(caseJson("lighthouse-case").handoffs).toEqual([]); // A board with a local-only quote never becomes an article. const made = await (await request.post("/api/research/cases", { data: { title: "Local only board" } })).json(); const source = caseJson(BOARD_CASE).scope.source; const pinned = await request.post(`/api/research/cases/${made.case.id}/quotes`, { data: { source, channel: "candace-owens", video: "lo-2025", t: 12 } }); expect(pinned.ok()).toBe(true); const plan = (await (await request.post(`/api/research/cases/${made.case.id}/handoff`, { data: { to: "article" } })).json()).plan; expect(plan.refusals.join(" ")).toContain("local-only channel"); const refused = await request.post(`/api/research/cases/${made.case.id}/handoff`, { data: { to: "article", confirm: true } }); expect(refused.status()).toBe(409); }); test("re-verify: the drifted quote shows the old and the new words, en vs en-orig is flagged, and nothing changes by itself", async ({ page }) => { await openBoard(page, BOARD_CASE); const b = board(page); await expect(b.locator("[data-quote]")).toHaveCount(3); await page.locator("body").click(); await page.keyboard.press("v"); await expect(status(page)).toHaveText("Re-verified 3: 2 as pinned, 1 drifted, 0 missing; en-orig differs at 1", { timeout: 30_000 }); const q1 = b.locator('[data-quote="q1"]'); await expect(q1).toHaveAttribute("data-verify", "drifted"); await expect(q1.locator('[data-flag="drifted"]')).toBeVisible(); await expect(q1.locator("[data-slip]")).toContainText(DRIFTED_QUOTE.was); await expect(q1.locator("[data-now]")).toHaveText(`“${DRIFTED_QUOTE.now}”`); await expect(b.locator('[data-quote="q2"]')).toHaveAttribute("data-verify", "ok"); const q3 = b.locator('[data-quote="q3"]'); await expect(q3.locator('[data-flag="en-orig"]')).toBeVisible(); await expect(q3.locator("[data-en-orig]")).toContainText(`“${EN_REWRITE.orig}”`); expect(caseJson(BOARD_CASE).quotes[0].text).toBe(DRIFTED_QUOTE.was); await expect(page.locator("[data-board-meta]").locator("..")).toContainText("1 drifted or missing"); // Only the operator's word takes the current words; the old are kept. await q1.getByRole("button", { name: "Use the current words" }).click(); await expect(q1.locator("[data-slip]")).toContainText(DRIFTED_QUOTE.now); await expect(q1).toHaveAttribute("data-verify", "ok"); const q = caseJson(BOARD_CASE).quotes[0]; expect(q.text).toBe(DRIFTED_QUOTE.now); expect(q.history[0].text).toBe(DRIFTED_QUOTE.was); }); test("the board fits 1366×768: the side panel and the first quote are on screen, the page does not scroll sideways", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); await openBoard(page, "lighthouse-case"); await expect(page.getByRole("button", { name: "Draft an article from this board" })).toBeInViewport(); await expect(board(page).locator("[data-quote]").first()).toBeInViewport(); expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true); });