Archilyzer · Source

archilyzer

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

commit 7d6971d04ec37b594e0c66242d487ce640dece6a
parent c31d6bb61fe769e96429e743b60b2f3c2ba04631
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 05:04:21 -0400

umtool: e2e board.spec — a case from a pin, pins from results and reader, sections and order, export, re-verify, hand-off plans

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

Diffstat:
Mumtool/components/research/QuoteSlip.tsx | 7++++++-
Aumtool/e2e/board.spec.ts | 254+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 260 insertions(+), 1 deletion(-)

diff --git a/umtool/components/research/QuoteSlip.tsx b/umtool/components/research/QuoteSlip.tsx @@ -43,6 +43,8 @@ function InlineField({ }) { const [v, setV] = useState(value); const ref = useRef<HTMLInputElement>(null); + // Enter saved it already: the blur that follows (focus back to the line) does not again. + const done = useRef(false); useEffect(() => setV(value), [value]); const back = () => ref.current?.closest<HTMLElement>("[data-lit-line]")?.focus({ preventScroll: true }); return ( @@ -55,18 +57,21 @@ function InlineField({ placeholder={placeholder} spellCheck onChange={(e) => setV(e.target.value)} + onFocus={() => (done.current = false)} onBlur={() => { - if (v.trim() !== value.trim()) onSave(v); + if (!done.current && v.trim() !== value.trim()) onSave(v); }} onKeyDown={(e) => { if (e.key === "Enter") { e.preventDefault(); if (v.trim() !== value.trim()) onSave(v); + done.current = true; back(); } else if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); setV(value); + done.current = true; back(); } }} diff --git a/umtool/e2e/board.spec.ts b/umtool/e2e/board.spec.ts @@ -0,0 +1,254 @@ +import { test, expect, type Page } 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]"); + +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 page.goto(researchCaseHref("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"); + await page.keyboard.press("Alt+j"); + await expect.poll(() => caseJson("lighthouse-case").quotes.map((q: { id: string }) => q.id).join(" ")).toBe("q2 q1 q3"); + await expect(litId(page)).toHaveAttribute("data-lit-id", "q:q1"); + 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(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"); + await expect.poll(() => caseJson("lighthouse-case").quotes.find((q: { id: string }) => q.id === "q1").section).toBe(null); + 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 page.keyboard.press("e"); + 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"); +}); + +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 page.goto(researchCaseHref("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 page.goto(researchCaseHref("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 page.goto(researchCaseHref(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 page.goto(researchCaseHref("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); +});