// Live browser check for the web client: serve the page, open it in headless // Chrome, connect to a running Pipelines server through the page's own proxy, // and capture what actually rendered. // // node test/ui-smoke.mjs [--port 8091] [--pipelines 127.0.0.1:8080] [--out DIR] // // This is the UI evidence a review stage produces: real screenshots of the // rendered client, not a claim. It needs a running Pipelines server (the live one // or a scratch one) and the installed Chrome; it has no npm dependencies. import { spawn } from "node:child_process"; import { mkdir, rm } from "node:fs/promises"; import net from "node:net"; import { tmpdir } from "node:os"; import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { eventually, launchChrome } from "./browser.mjs"; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); /** A port that is bound and immediately released, so nothing listens on it. */ async function freePort() { return new Promise((resolvePort) => { const server = net.createServer(); server.listen(0, "127.0.0.1", () => { const { port: bound } = server.address(); server.close(() => resolvePort(bound)); }); }); } function flag(argv, name, fallback) { const i = argv.indexOf(name); return i !== -1 && argv[i + 1] ? argv[i + 1] : fallback; } const port = Number(flag(process.argv, "--port", process.env.WEB_UI_PORT ?? 8091)); const pipelines = flag(process.argv, "--pipelines", process.env.PIPELINES_TARGET ?? "127.0.0.1:8080"); const out = resolve( flag(process.argv, "--out", process.env.WEB_UI_OUT ?? join(tmpdir(), "pipelines-web-ui")), ); // The page must connect through its own proxy (the server rejects a cross-origin // upgrade), but serve.mjs only proxies /connect — not /artifacts. Point the URL // field at the real Pipelines server after connecting so artifact tiles and the // viewer resolve to real files; that is exactly the URL a correctly configured // page would carry. const artifactServerUrl = `ws://${pipelines}/connect`; const shots = []; let serve = null; let browser = null; let page = null; let failed = false; function step(label) { console.log(`• ${label}`); } async function shot(name) { const path = `${out}/${name}`; shots.push(await page.screenshot(path)); console.log(` capture ${path}`); return path; } const text = (selector) => page.evaluate(`document.querySelector(${JSON.stringify(selector)})?.textContent ?? ""`); // The shared live server can drop a long-lived socket while the earlier screens // are captured (observed as a spurious 1006 mid-run). A capture step must not // depend on an unasserted connection, so this nudges the page's own recovery — // its `online` handler resets the backoff — and waits for the green banner // before the step reads anything. async function ensureConnected(timeout = 25000) { const ok = await page.evaluate( `document.querySelector(".conn-banner")?.classList.contains("conn-ok") ?? false`, ); if (!ok) await page.evaluate(`window.dispatchEvent(new Event("online"))`); await page.waitForSelector(".conn-banner.conn-ok", { timeout }); } // Open a run's detail. The connection is asserted first, and if the socket drops // between steps the page's reconnect does not replay the detail request, so the // click is retried once after re-establishing the connection. async function openRunDetail(runId) { const row = `.list.runs .run-row-meta[data-run-id="${runId}"]`; for (let attempt = 0; attempt < 2; attempt += 1) { await ensureConnected(); try { await page.waitForSelector(row, { timeout: 20000 }); await page.click(row); await page.waitForSelector(".detail .detail-tabs", { timeout: 20000 }); // The tabstrip already exists from the previously opened run, so it is not // proof this run's detail loaded. Wait for this run's own identity line // (`run {id} · …`) before returning, or the next assertion can read the // previous run's actions. await eventually( () => page.evaluate( `document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${runId} ") ?? false`, ), { timeout: 20000, what: `run ${runId}'s detail to load` }, ); return; } catch (error) { if (attempt === 1) throw error; console.log(` retrying run ${runId} after a dropped connection`); } } } // --- Omni-search (S1/S2) --------------------------------------------------- // The page's own search UI drives every one of the helpers below; nothing is // stubbed. `searchTargets` opens the panel (if it is not already open), types the // query, applies the kind filter and returns the `data-target` of every row of // that kind once one has rendered. async function searchTargets(query, kind) { await ensureConnected(); if (!(await page.evaluate(`!!document.querySelector("#searchInput")`))) { await page.click("#searchToggle"); await page.waitForSelector("#searchInput", { timeout: 15000 }); } await page.fill("#searchInput", query); await page.evaluate(`(() => { const select = document.querySelector("#searchKind"); select.value = ${JSON.stringify(kind)}; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); await eventually( () => page.evaluate( `[...document.querySelectorAll("#searchResults .search-row")].some((r) => r.dataset.kind === ${JSON.stringify(kind)})`, ), { timeout: 25000, what: `a ${kind} search result` }, ); return page.evaluate( `[...document.querySelectorAll("#searchResults .search-row")] .filter((r) => r.dataset.kind === ${JSON.stringify(kind)}) .map((r) => r.dataset.target ?? "")`, ); } /** * Click one search row by its exact data-target; routing closes the panel. The * lookup and the click happen in one evaluate so a reply landing between them * cannot replace the row first. This drives the row's own click handler, exactly * as a mouse click would. */ async function clickSearchTarget(target) { return page.evaluate(`(() => { const row = [...document.querySelectorAll("#searchResults .search-row")] .find((r) => (r.dataset.target ?? "") === ${JSON.stringify(target)}); if (!row) return false; row.click(); return true; })()`); } /** * Route candidate rows of `kind` until the expected destination renders (routing * always closes the panel, so each attempt reopens and re-queries). Live data can * change between runs, so up to `attempts` rows are tried before giving up; * returns the target that landed or null. */ async function routeSearchKind(query, kind, landed, attempts = 4) { const targets = await searchTargets(query, kind); for (const target of targets.slice(0, attempts)) { await searchTargets(query, kind); if (!(await clickSearchTarget(target))) continue; if (await landed()) return target; await page.evaluate(`document.querySelector(".stage-pane-back")?.click()`); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, }).catch(() => {}); } return null; } // The mounted graph's current transform, read back so the pan/zoom clamp checks // assert the real rendered state rather than a claim. const graphState = () => page.evaluate(`(() => { const content = document.querySelector(".graph-content"); const viewport = document.querySelector(".graph-viewport"); if (!content || !viewport) return null; const m = /translate\\(([-0-9.]+)px, ([-0-9.]+)px\\) scale\\(([-0-9.]+)\\)/.exec( content.style.transform, ); if (!m) return null; return { tx: Number(m[1]), ty: Number(m[2]), scale: Number(m[3]), width: parseFloat(content.style.width), height: parseFloat(content.style.height), viewportWidth: viewport.clientWidth, viewportHeight: viewport.clientHeight, }; })()`); // Dispatch real wheel events at the viewport centre (the page handler is // `{ passive: false }` and prevents default, so a synthetic event exercises the // same clamp path a user gesture does). const wheel = (deltaY, times) => page.evaluate(`(() => { const viewport = document.querySelector(".graph-viewport"); const r = viewport.getBoundingClientRect(); for (let i = 0; i < ${times}; i += 1) { viewport.dispatchEvent(new WheelEvent("wheel", { bubbles: true, cancelable: true, deltaY: ${deltaY}, clientX: r.left + r.width / 2, clientY: r.top + r.height / 2, })); } return true; })()`); // Dispatch a real pointer drag across the viewport. const drag = (dx, dy) => page.evaluate(`(() => { const viewport = document.querySelector(".graph-viewport"); const r = viewport.getBoundingClientRect(); const fire = (type, x, y) => viewport.dispatchEvent(new PointerEvent(type, { bubbles: true, cancelable: true, pointerId: 7, button: 0, buttons: type === "pointerup" ? 0 : 1, clientX: x, clientY: y, })); const startX = r.left + r.width / 2; const startY = r.top + r.height / 2; fire("pointerdown", startX, startY); for (let i = 1; i <= 20; i += 1) { fire("pointermove", startX + (${dx} * i) / 20, startY + (${dy} * i) / 20); } fire("pointerup", startX + ${dx}, startY + ${dy}); return true; })()`); try { await mkdir(out, { recursive: true }); step(`serving web/ on 127.0.0.1:${port} (proxy /connect -> ${pipelines})`); serve = spawn(process.execPath, ["serve.mjs", "--port", String(port), "--pipelines", pipelines], { cwd: ROOT, stdio: ["ignore", "pipe", "pipe"], }); let serveLog = ""; serve.stdout.on("data", (chunk) => (serveLog += chunk.toString())); serve.stderr.on("data", (chunk) => (serveLog += chunk.toString())); await eventually( async () => { if (serve.exitCode != null) throw new Error(`serve.mjs exited: ${serveLog.trim().slice(-300)}`); const res = await fetch(`http://127.0.0.1:${port}/`).catch(() => null); return res?.ok; }, { what: "the page to be served" }, ); step("launching headless Chrome"); browser = await launchChrome({ width: 1440, height: 900 }); page = await browser.openPage(`http://127.0.0.1:${port}/`); // Deterministic dismissals: the attention set is read from localStorage once at // boot, so clear the key and reload before connecting so the surface derives // from an empty set regardless of any stale profile state. step("clearing the attention storage key before connecting"); await page.evaluate(`localStorage.removeItem("pipelines.web.attention.v1")`); await page.evaluate(`location.reload()`); await page.waitForSelector("#url", { timeout: 15000 }); step("connecting the page to the server through its own proxy"); await page.fill("#url", `ws://127.0.0.1:${port}/connect`); await page.click("#connectBtn"); await page.waitForSelector(".row-title", { timeout: 25000 }); await page.waitForText("connected", { timeout: 25000 }); const pipelineCount = await page.evaluate( `document.querySelectorAll("#pipelineRows button.row").length`, ); if (!pipelineCount) throw new Error("connected but no pipelines rendered"); console.log(` pipelines rendered: ${pipelineCount}`); // 1. The list with its filter menu open: the name field, the Runs section, the // Last run status multi-select and the Clear filters reset (P1 + P2). step("capturing the pipeline list with the filter menu open"); await page.click("#filterToggle"); await page.waitForSelector(".filter-panel"); await shot("01-pipelines-controls.png"); // 2. The sort menu, and exercising it changes the ordering (P2). step("capturing and exercising the sort menu"); await page.click("#sortToggle"); await page.waitForSelector(".sort-panel"); await shot("02-pipelines-sort.png"); await page.clickText(".sort-panel .sort-option", "Name A\u2013Z"); const sorted = await text("#sortToggle"); if (!sorted.includes("Name A\u2013Z")) throw new Error(`sort did not apply: ${sorted}`); await page.click("#sortToggle"); await page.waitForSelector(".sort-panel"); await page.clickText(".sort-panel button", "Reset"); const reset = await text("#sortToggle"); if (!reset.includes("Server order")) throw new Error(`sort reset failed: ${reset}`); // 3. The name facet narrows live; an unmatched name shows the name-only empty state. step("narrowing by name and capturing the name-only empty state"); await page.click("#filterToggle"); await page.waitForSelector(".filter-panel"); await page.fill("#pipelineNameFilter", "Android"); const narrowed = await page.evaluate( `document.querySelectorAll("#pipelineRows button.row").length`, ); if (!narrowed || narrowed >= pipelineCount) { throw new Error(`name filter did not narrow (${narrowed} of ${pipelineCount})`); } console.log(` name filter narrowed ${pipelineCount} -> ${narrowed}`); await page.fill("#pipelineNameFilter", "zzz-no-such-pipeline"); await page.waitForText('No pipelines match "zzz-no-such-pipeline".'); await shot("03-pipelines-empty-name.png"); await page.click(".empty button"); await page.waitForSelector("#pipelineRows button.row"); // 4. A run facet with no matches shows the general empty state and a reset. step("capturing the run-facet empty state"); await page.click("#status-interrupted"); await page.waitForText("No pipelines match the current filters."); await shot("04-pipelines-empty-filters.png"); await page.click(".empty button"); await page.waitForSelector("#pipelineRows button.row"); await page.click("#filterToggle"); // 5. Pipeline detail: Summary (name, subtitle, content hash, created/updated). // Prefer a multi-stage pipeline so the Graph tab below has a real layout to // render; fall back to whatever the server lists first. step("opening a multi-stage pipeline detail (Summary)"); const openedPipeline = await page.evaluate(`(() => { const rows = [...document.querySelectorAll("#pipelineRows button.row")]; const wanted = rows.find((row) => row.textContent.includes("Plan and land")) ?? rows[0]; if (!wanted) return null; wanted.setAttribute("data-test-click", "1"); return wanted.textContent.includes("Plan and land") ? "Plan and land" : "first row"; })()`); if (!openedPipeline) throw new Error("no pipeline row to open"); console.log(` opened pipeline: ${openedPipeline}`); await page.click("[data-test-click='1']"); await page.evaluate( `document.querySelector("[data-test-click='1']")?.removeAttribute("data-test-click")`, ); await page.waitForSelector(".detail h2"); await page.waitForSelector(".monospace"); await page.evaluate(`document.querySelector(".detail")?.scrollIntoView({ block: "start" })`); await shot("05-pipeline-summary.png"); // 6. The Versions section is collapsed by default; expanding shows its rows. step("expanding the Versions section"); await page.click(".section-toggle"); await page.waitForSelector(".versions-list"); await page.evaluate(`document.querySelector(".versions-list")?.scrollIntoView({ block: "start" })`); await shot("06-pipeline-summary-versions.png"); // 7. Source tab: the rendered pipeline source in a monospace block. step("opening the Source tab"); await page.clickText(".detail-tabs button", "Source"); await page.waitForSelector(".source-code"); await page.evaluate(`document.querySelector(".detail")?.scrollIntoView({ block: "start" })`); await shot("07-pipeline-source.png"); // 8. Graph tab (P6): the guidance note plus the rendered workflow graph — // stage nodes in declaration order, labelled outcome edges, the success and // failure terminals — then an opened definition pane, the zoom/pan clamps and // the expanded panel. Every assertion below is a real behaviour of the page. step("opening the Graph tab: the rendered workflow graph (P6)"); await page.clickText(".detail-tabs button", "Graph"); await page.waitForSelector(".graph-note"); await page.waitForSelector(".graph-viewport"); await page.waitForSelector(".graph-node"); // Auto-fit runs on the first layout (after the host is attached), so wait for // the whole graph to sit inside the viewport before asserting. await eventually( async () => { const current = await graphState(); if (!current || !(current.scale > 0)) return false; const scaledWidth = current.width * current.scale; const scaledHeight = current.height * current.scale; return ( current.tx >= -0.5 && current.ty >= -0.5 && current.tx + scaledWidth <= current.viewportWidth + 0.5 && current.ty + scaledHeight <= current.viewportHeight + 0.5 ); }, { what: "the graph to be auto-fitted into the viewport" }, ); const note = await text(".graph-note"); if (!note.includes("Mouse wheel to zoom, drag to pan, click a stage for details.")) { throw new Error(`unexpected graph guidance note: ${note}`); } const graphCounts = await page.evaluate(`(() => ({ nodes: document.querySelectorAll(".graph-node").length, stages: document.querySelectorAll(".graph-node:not([class*='terminal'])").length, edges: document.querySelectorAll(".graph-edge-path").length, labels: [...document.querySelectorAll(".graph-edge-label")].map((n) => n.textContent), failure: !!document.querySelector(".graph-node-terminal-failure"), success: !!document.querySelector(".graph-node-terminal-success"), }))()`); if (!graphCounts.stages || !graphCounts.edges || !graphCounts.labels.length) { throw new Error(`the graph did not render nodes/edges/labels: ${JSON.stringify(graphCounts)}`); } if (!graphCounts.failure || !graphCounts.success) { throw new Error(`the graph is missing a terminal: ${JSON.stringify(graphCounts)}`); } const fitted = await graphState(); if (!(fitted && fitted.scale > 0 && fitted.scale <= 1 + 1e-6)) { throw new Error(`the graph was not auto-fitted: ${JSON.stringify(fitted)}`); } console.log( ` graph: ${graphCounts.stages} stages, ${graphCounts.edges} edges, ` + `${graphCounts.nodes} nodes, labels ${graphCounts.labels.join(",")}; fitted at ${fitted.scale.toFixed(2)}`, ); await shot("08-pipeline-graph.png"); // Clicking empty space must do nothing; clicking a stage opens its pane. step("checking empty-space click and opening a stage's definition pane"); await page.evaluate(`document.querySelector(".graph-viewport")?.click()`); const paneOnEmpty = await page.evaluate( `(() => { const p = document.querySelector(".graph-pane"); return !!p && !p.hidden; })()`, ); if (paneOnEmpty) throw new Error("clicking empty space opened the stage pane"); await page.click(".graph-node-model"); await page.waitForSelector(".graph-pane:not([hidden])"); const pane = await page.evaluate(`(() => { const p = document.querySelector(".graph-pane"); return { text: p.textContent, key: document.querySelector(".graph-node-model")?.dataset.key ?? "", type: document.querySelector(".graph-type-chip")?.textContent ?? "", fields: document.querySelectorAll(".graph-pane .graph-field").length, }; })()`); if (!pane.key || !pane.text.includes(pane.key)) { throw new Error(`the pane did not name the stage key (${pane.key}): ${pane.text.slice(0, 120)}`); } if (!pane.type) throw new Error("the pane did not show the stage type"); if (!pane.text.includes("Stage definition") || !pane.fields) { throw new Error(`the pane has no Stage definition fields: ${pane.text.slice(0, 120)}`); } await page.rect(".graph-pane"); await shot("08a-pipeline-graph-stage-pane.png"); console.log(` stage pane: ${pane.key} (${pane.type}), ${pane.fields} definition field(s)`); // Wheel zoom clamps to [0.3, 3.0]; a drag can never leave an empty viewport. step("exercising wheel-zoom clamps, drag clamping and Fit"); await wheel(400, 60); const zoomedOut = await graphState(); if (!(Math.abs(zoomedOut.scale - 0.3) < 1e-6)) { throw new Error(`zoom-out was not clamped to 0.3: ${zoomedOut.scale}`); } await wheel(-400, 60); const zoomedIn = await graphState(); if (!(Math.abs(zoomedIn.scale - 3.0) < 1e-6)) { throw new Error(`zoom-in was not clamped to 3.0: ${zoomedIn.scale}`); } await drag(4000, 3000); const panned = await graphState(); const visibleX = Math.min(panned.tx + panned.width * panned.scale, panned.viewportWidth) - Math.max(panned.tx, 0); const visibleY = Math.min(panned.ty + panned.height * panned.scale, panned.viewportHeight) - Math.max(panned.ty, 0); if (visibleX < 39.5 || visibleY < 39.5) { throw new Error(`panning left an empty viewport: visible ${visibleX}x${visibleY}`); } await page.clickText(".graph-control", "Fit graph to view"); const refitted = await graphState(); if (!(refitted.scale >= 0.3 && refitted.scale <= 1 + 1e-6)) { throw new Error(`Fit did not re-fit the graph: ${refitted.scale}`); } console.log( ` zoom clamp 0.3..3.0 ok; after a 4000x3000 drag the viewport still shows ` + `${Math.round(visibleX)}x${Math.round(visibleY)}px; Fit re-fitted to ${refitted.scale.toFixed(2)}`, ); step("expanding the graph panel"); await page.clickText(".graph-control", "Expand graph"); await page.waitForText("Collapse graph"); const expandedHeight = await page.evaluate( `document.querySelector(".graph-viewport").clientHeight`, ); await page.rect(".graph-viewport"); await shot("08b-pipeline-graph-expanded.png"); console.log(` expanded graph viewport height: ${expandedHeight}px`); await page.clickText(".graph-control", "Collapse graph"); step("checking a node with no stage shows the app's empty pane message"); const noDetails = await page.evaluate(`(async () => { const { mount } = await import("/src/graph.js"); const host = document.createElement("div"); host.style.cssText = "position:fixed;left:-2400px;top:0;width:600px;height:300px"; document.body.append(host); const graph = { stages: [{ key: "alpha", type: "model", edges: { success: "#success" } }] }; const handle = mount(host, graph, {}); host.querySelector(".graph-node-terminal-failure").click(); const text = host.querySelector(".graph-pane").textContent; handle.unmount(); const emptyAfterUnmount = host.childElementCount === 0; host.remove(); return { text, emptyAfterUnmount }; })()`); if (!noDetails.text.includes("No details recorded for this node.")) { throw new Error(`a stage-less node did not show the empty message: ${noDetails.text}`); } if (!noDetails.emptyAfterUnmount) throw new Error("unmount left the graph DOM behind"); console.log(" a node with no stage reads: No details recorded for this node."); step("switching to Runs: day-grouped list + usage roll-up"); await ensureConnected(); await page.clickText("nav.tabs button.tab", "Runs"); await page.waitForSelector(".list.runs .day-header", { timeout: 25000 }); await page.waitForSelector(".metrics .metric", { timeout: 25000 }); const usageLabels = await page.evaluate( `[...document.querySelectorAll(".metrics .metric-label")].map((n) => n.textContent)`, ); for (const label of ["Total", "Succeeded", "Failed", "Canceled", "Interrupted", "Active"]) { if (!usageLabels.includes(label)) throw new Error(`usage metric missing: ${label}`); } const dayHeaders = await page.evaluate( `[...document.querySelectorAll(".list.runs .day-header")].map((n) => n.textContent)`, ); if (!dayHeaders.length) throw new Error("no day header rendered"); if (!dayHeaders.includes("Today")) { throw new Error(`the list does not start with Today: ${dayHeaders.join(" | ")}`); } const fullDateHeader = dayHeaders.find((label) => /^\d{1,2} \w{3} \d{4}$/.test(label)); if (!fullDateHeader) throw new Error(`no full-date day header: ${dayHeaders.join(" | ")}`); shots.push(await page.screenshot(`${out}/09-runs-day-groups.png`)); console.log(` usage: ${usageLabels.join(", ")}`); console.log(` day headers: ${dayHeaders.slice(0, 3).join(" | ")}`); // --------------------------------------------------------------------- // R15: the attention / "Needs you" surface. The bell lives in the top bar on // every view; its badge, the sheet's rows and the dismissal identities all // come from the pure src/attention.js model. The live server currently has // failed runs and no run parked in `waiting`, so the sheet is exercised with // real failed entries and that live-data limitation is reported below. The // decision path (open without dismissing) is unit-tested. // --------------------------------------------------------------------- step("checking the attention bell + badge"); await page.waitForSelector("#attentionBell", { timeout: 15000 }); const bell = await page.evaluate(`(() => { const b = document.querySelector("#attentionBell"); const badge = b.querySelector(".attention-badge"); return { label: b.getAttribute("aria-label"), hasBadge: !!badge, count: badge ? badge.textContent : null, dataCount: badge ? badge.dataset.count : null, }; })()`); const attentionCount = Number(bell.dataCount ?? 0); if (!(attentionCount > 0)) { throw new Error(`no attention entries on the live server: ${JSON.stringify(bell)}`); } if (bell.label !== `Notifications, ${attentionCount} needing attention`) { throw new Error(`the bell's accessible name is wrong: ${bell.label}`); } if (!bell.hasBadge || bell.count !== String(attentionCount)) { throw new Error(`the badge is wrong: ${JSON.stringify(bell)}`); } if (await page.evaluate(`!!document.querySelector(".attention-sheet")`)) { throw new Error("the sheet was already open before the bell was clicked"); } console.log(` bell: aria-label="${bell.label}", badge=${bell.count}`); shots.push(await page.screenshot(`${out}/35-attention-bell.png`)); step("opening the Needs you sheet"); await page.click("#attentionBell"); await page.waitForSelector(".attention-sheet", { timeout: 15000 }); const sheet = await page.evaluate(`(() => { const rows = [...document.querySelectorAll(".attention-sheet .attention-row")]; return { title: document.querySelector(".attention-sheet-title")?.textContent ?? "", clearAll: document.querySelector(".attention-clear")?.textContent ?? null, empty: document.querySelector(".attention-empty")?.textContent ?? null, focused: document.activeElement?.className ?? "", rows: rows.map((row) => { const open = row.querySelector(".attention-row-open"); const dismiss = row.querySelector(".attention-dismiss"); return { runId: Number(open?.dataset.runId), kind: open?.dataset.kind ?? "", label: open?.querySelector(".attention-label")?.textContent ?? "", desc: open?.querySelector(".attention-desc")?.textContent ?? "", icon: open?.querySelector(".attention-icon")?.textContent ?? "", dismissName: dismiss?.getAttribute("aria-label") ?? "", }; }), }; })()`); if (sheet.title !== "Needs you") throw new Error(`the sheet title is wrong: ${sheet.title}`); if (sheet.empty !== null) throw new Error(`a non-empty sheet showed the empty copy: ${sheet.empty}`); if (sheet.clearAll !== "Clear all") throw new Error(`Clear all is missing: ${sheet.clearAll}`); if (sheet.rows.length !== attentionCount) { throw new Error(`the sheet drew ${sheet.rows.length} rows for a badge of ${attentionCount}`); } if (!sheet.focused.includes("attention-sheet-close")) { throw new Error(`focus did not move into the sheet on open: ${sheet.focused}`); } const kindRanks = { decision: 0, failed: 1 }; let lastKindRank = -1; for (const row of sheet.rows) { if (!row.icon) throw new Error(`row ${row.runId} has no status icon`); if (!row.label) throw new Error(`row ${row.runId} has no primary label`); if (!row.desc.includes(" · ")) throw new Error(`row ${row.runId} description is wrong: ${row.desc}`); if (row.dismissName !== "Dismiss") { throw new Error(`row ${row.runId}'s trailing control is not named Dismiss: ${row.dismissName}`); } const rank = kindRanks[row.kind]; if (rank == null) throw new Error(`row ${row.runId} has an unknown kind ${row.kind}`); if (rank < lastKindRank) throw new Error(`the rows are out of kind order at run ${row.runId}`); lastKindRank = rank; } const firstRow = sheet.rows[0]; const kindName = (kind) => (kind === "decision" ? "Decision" : "Failed"); console.log( ` sheet: ${sheet.rows.length} row(s); first ${firstRow.runId} (${firstRow.kind}) ` + `"${firstRow.label}" — ${firstRow.desc}`, ); if (!sheet.rows.some((row) => row.kind === "decision")) { console.log( " -- no `waiting` run exists on the live server; the sheet used real failed runs " + "and the decision path (open without dismissing) is covered by unit tests", ); } shots.push(await page.screenshot(`${out}/36-attention-sheet.png`)); step("dismissing one entry individually"); await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-dismiss").click()`); await eventually( async () => (await page.evaluate(`document.querySelectorAll(".attention-sheet .attention-row").length`)) === attentionCount - 1, { what: "the individual dismissal to land" }, ); const afterDismiss = await page.evaluate(`(() => ({ rows: document.querySelectorAll(".attention-sheet .attention-row").length, badge: document.querySelector("#attentionBell .attention-badge")?.dataset.count ?? null, stored: localStorage.getItem("pipelines.web.attention.v1"), }))()`); if (afterDismiss.rows !== attentionCount - 1) { throw new Error(`the sheet still shows ${afterDismiss.rows} rows after one dismissal`); } if (Number(afterDismiss.badge) !== attentionCount - 1) { throw new Error(`the badge did not follow the dismissal: ${afterDismiss.badge}`); } if (!String(afterDismiss.stored).includes(`${firstRow.runId}:${kindName(firstRow.kind)}`)) { throw new Error(`the dismissed identity was not persisted: ${afterDismiss.stored}`); } console.log( ` dismissed ${firstRow.runId}:${kindName(firstRow.kind)}; rows ${attentionCount} -> ` + `${afterDismiss.rows}, stored ${afterDismiss.stored}`, ); shots.push(await page.screenshot(`${out}/37-attention-dismissed.png`)); step("opening a Failed row: it opens the run and persists its dismissal"); const rowToOpen = await page.evaluate(`(() => { const open = document.querySelector(".attention-sheet .attention-row .attention-row-open"); return { runId: Number(open.dataset.runId), kind: open.dataset.kind }; })()`); if (rowToOpen.kind !== "failed") { throw new Error(`expected a Failed row to open, got ${rowToOpen.kind}`); } await page.evaluate(`document.querySelector(".attention-sheet .attention-row .attention-row-open").click()`); await eventually( async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), { what: "the sheet to close on row activation" }, ); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); const openedIdentity = await page.evaluate( `document.querySelector(".run-identity")?.textContent ?? ""`, ); if (!openedIdentity.startsWith(`run ${rowToOpen.runId} ·`)) { throw new Error(`row ${rowToOpen.runId} did not open its run: ${openedIdentity}`); } const storedAfterOpen = await page.evaluate(`localStorage.getItem("pipelines.web.attention.v1")`); if (!String(storedAfterOpen).includes(`${rowToOpen.runId}:Failed`)) { throw new Error(`opening a Failed row did not persist its dismissal: ${storedAfterOpen}`); } console.log(` opened run ${rowToOpen.runId}; ${rowToOpen.runId}:Failed now persisted`); step("reopening the sheet and clearing all"); await page.click("#attentionBell"); await page.waitForSelector(".attention-sheet", { timeout: 15000 }); const beforeClear = await page.evaluate( `document.querySelectorAll(".attention-sheet .attention-row").length`, ); if (beforeClear !== attentionCount - 2) { throw new Error(`expected ${attentionCount - 2} rows before Clear all, got ${beforeClear}`); } await page.evaluate(`document.querySelector(".attention-sheet .attention-clear").click()`); await eventually( async () => (await page.evaluate(`document.querySelector(".attention-empty")?.textContent ?? ""`)) === "Nothing needs you right now.", { what: "the empty attention state after Clear all" }, ); const cleared = await page.evaluate(`(() => ({ empty: document.querySelector(".attention-empty")?.textContent ?? "", rows: document.querySelectorAll(".attention-sheet .attention-row").length, clearAll: !!document.querySelector(".attention-clear"), badge: !!document.querySelector("#attentionBell .attention-badge"), label: document.querySelector("#attentionBell").getAttribute("aria-label"), badges: document.querySelectorAll(".attention-badge").length, }))()`); if (cleared.empty !== "Nothing needs you right now.") { throw new Error(`the empty copy is wrong: ${cleared.empty}`); } if (cleared.rows !== 0) throw new Error(`the cleared sheet still shows ${cleared.rows} rows`); if (cleared.clearAll) throw new Error("Clear all is still offered on the empty sheet"); if (cleared.badge || cleared.badges !== 0) throw new Error("the badge is still visible after Clear all"); if (cleared.label !== "Notifications") { throw new Error(`the emptied bell is named wrong: ${cleared.label}`); } console.log(` after Clear all: "${cleared.empty}", no Clear all, bell aria-label="${cleared.label}"`); shots.push(await page.screenshot(`${out}/38-attention-cleared.png`)); step("closing the sheet with Escape returns focus to the bell"); await page.evaluate( `document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`, ); await eventually( async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), { what: "Escape to close the attention sheet" }, ); const focusAfterEscape = await page.evaluate(`document.activeElement?.id ?? ""`); if (focusAfterEscape !== "attentionBell") { throw new Error(`Escape did not return focus to the bell: ${focusAfterEscape}`); } console.log(" Escape closed the sheet and focus returned to #attentionBell"); step("closing the sheet with a backdrop click"); await page.click("#attentionBell"); await page.waitForSelector(".attention-sheet", { timeout: 15000 }); await page.evaluate(`document.querySelector(".attention-sheet").click()`); await eventually( async () => !(await page.evaluate(`!!document.querySelector(".attention-sheet")`)), { what: "the backdrop click to close the attention sheet" }, ); console.log(" backdrop click closed the sheet"); step(`scrolling the list to the older day group (${fullDateHeader})`); const scrolledTo = await page.evaluate(`(() => { const scroll = document.querySelector(".run-scroll"); const header = [...document.querySelectorAll(".list.runs .day-header")] .find((n) => /^\\d{1,2} \\w{3} \\d{4}$/.test(n.textContent)); if (!scroll || !header) return null; scroll.scrollTop += header.getBoundingClientRect().top - scroll.getBoundingClientRect().top; return header.textContent; })()`); if (!scrolledTo) throw new Error("could not scroll to the older day group"); shots.push(await page.screenshot(`${out}/10-runs-older-day-group.png`)); console.log(` scrolled to: ${scrolledTo}`); step("opening the filter menu: it must stay in the viewport and be reachable"); await page.click("#runFilterBtn"); await page.waitForSelector("#runFilterMenu"); const menuLabels = await page.evaluate( `[...document.querySelectorAll("#runFilterMenu .filter-check span")].map((n) => n.textContent)`, ); for (const label of [ "queued", "running", "waiting", "succeeded", "failed", "canceled", "interrupted", "Any pipeline", "Any time", "Today", "Last 7 days", "Last 30 days", ]) { if (!menuLabels.includes(label)) throw new Error(`filter menu missing: ${label}`); } const menuActions = await page.evaluate( `[...document.querySelectorAll("#runFilterMenu .menu-actions button")].map((n) => n.textContent)`, ); for (const label of ["Clear filters", "Done"]) { if (!menuActions.includes(label)) throw new Error(`filter menu action missing: ${label}`); } // The gate is reachability, not DOM presence: with a busy history the menu is // taller than the viewport, so it must be bounded and scroll its own box rather // than being clipped by an ancestor with no way for a user to reach the actions. const reach = await page.evaluate(`(() => { const menu = document.querySelector("#runFilterMenu"); const overflowY = getComputedStyle(menu).overflowY; const rect = menu.getBoundingClientRect(); menu.scrollTop = menu.scrollHeight; const actions = menu.querySelector(".menu-actions").getBoundingClientRect(); return { overflowY, height: Math.round(rect.height), viewport: window.innerHeight, fitsViewport: rect.height <= window.innerHeight && rect.bottom <= window.innerHeight + 1, actionsReachable: actions.bottom <= window.innerHeight + 1 && actions.top >= -1, }; })()`); if (reach.overflowY !== "auto" && reach.overflowY !== "scroll") { throw new Error(`the filter menu does not scroll its own box: overflow-y=${reach.overflowY}`); } if (!reach.fitsViewport) { throw new Error(`the filter menu overflows the viewport: ${JSON.stringify(reach)}`); } if (!reach.actionsReachable) { throw new Error(`the filter menu actions are unreachable: ${JSON.stringify(reach)}`); } shots.push(await page.screenshot(`${out}/11-runs-filter-menu.png`)); console.log(` filter menu ${reach.height}px tall in a ${reach.viewport}px viewport; actions reachable`); step("applying a status filter"); await page.evaluate( `document.querySelector('#runFilterMenu input[data-status="failed"]').click()`, ); const filterLabel = await page.evaluate(`document.querySelector("#runFilterBtn").textContent`); if (!filterLabel.includes("(1)")) { throw new Error(`filter control is missing the active count: ${filterLabel}`); } await page.click("#runFilterBtn"); // close the menu so the list is unobstructed const filteredChips = await page.evaluate( `[...document.querySelectorAll(".list.runs .run-row .run-row-head .chip")].map((n) => n.textContent)`, ); if (!filteredChips.length) throw new Error("the status filter produced no rows"); if (!filteredChips.every((chip) => chip === "failed")) { throw new Error(`filtered rows are not all failed: ${filteredChips.join(",")}`); } shots.push(await page.screenshot(`${out}/12-runs-filtered.png`)); console.log(` filtered rows: ${filteredChips.length}, all failed`); step("filtering to a state with no runs: the filtered-empty state + Clear filters"); await page.click("#runFilterBtn"); await page.waitForSelector("#runFilterMenu"); await page.evaluate( `document.querySelector('#runFilterMenu input[data-status="failed"]').click()`, ); await page.evaluate( `document.querySelector('#runFilterMenu input[data-status="interrupted"]').click()`, ); await page.click("#runFilterBtn"); // close the menu to see the list await page.waitForSelector(".list.runs .empty-state"); const emptyMessage = await page.evaluate( `document.querySelector(".list.runs .empty-state span")?.textContent ?? ""`, ); if (emptyMessage !== "No runs match the current filters.") { throw new Error(`unexpected filtered-empty message: ${emptyMessage}`); } const clearAction = await page.evaluate( `document.querySelector(".list.runs .empty-state button")?.textContent ?? null`, ); if (clearAction !== "Clear filters") { throw new Error(`the filtered-empty state should offer Clear filters, got: ${clearAction}`); } shots.push(await page.screenshot(`${out}/13-runs-filtered-empty.png`)); console.log(` empty state: ${emptyMessage} (+ ${clearAction})`); step("clearing the filters from the empty state and changing the sort"); await ensureConnected(); await page.click(".list.runs .empty-state button"); await page.waitForSelector(".list.runs .day-header", { timeout: 25000 }); const resetLabel = await page.evaluate(`document.querySelector("#runFilterBtn").textContent`); if (resetLabel.includes("(")) throw new Error(`Clear filters did not reset the count: ${resetLabel}`); await page.click("#runSortBtn"); await page.waitForSelector("#runSortMenu"); const sortItems = await page.evaluate( `[...document.querySelectorAll("#runSortMenu .menu-item")].map((n) => n.textContent)`, ); for (const label of [ "Newest first", "Oldest first", "Longest duration", "Shortest duration", "Pipeline name", "Status", "Reset", ]) { if (!sortItems.includes(label)) throw new Error(`sort menu missing: ${label}`); } shots.push(await page.screenshot(`${out}/14-runs-sort-menu.png`)); await page.clickText("#runSortMenu .menu-item", "Pipeline name"); const sortLabel = await page.evaluate(`document.querySelector("#runSortBtn").textContent`); if (!sortLabel.includes("Pipeline name")) { throw new Error(`the sort control did not change: ${sortLabel}`); } await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); shots.push(await page.screenshot(`${out}/15-runs-sorted.png`)); console.log(` sort control now: ${sortLabel}`); step("opening a run detail"); await page.click(".list.runs .run-row"); await page.waitForSelector(".detail h2", { timeout: 25000 }); await shot("16-run-detail.png"); step("opening the Templates gallery"); await page.clickText("nav.tabs button.tab", "Templates"); await page.waitForSelector(".cards button.card", { timeout: 25000 }); shots.push(await page.screenshot(`${out}/17-templates-gallery.png`)); const templateCount = await page.evaluate(`document.querySelectorAll(".cards button.card").length`); console.log(` templates rendered: ${templateCount}`); step("opening a template detail (Summary)"); await page.click(".cards button.card"); await page.waitForSelector(".detail .tabstrip", { timeout: 25000 }); await page.waitForText("Key", { timeout: 25000 }); shots.push(await page.screenshot(`${out}/18-template-detail-summary.png`)); step("opening the template Source tab"); await page.clickText(".detail .tabstrip button.minitab", "Source"); await page.waitForText("Definition source", { timeout: 25000 }); shots.push(await page.screenshot(`${out}/19-template-source.png`)); // Artifact URLs resolve against whatever the URL field holds. Point it at the // real server (the socket stays on the proxy, see the note above) so the tiles // and the viewer load real files rather than proxying a path serve.mjs does // not forward. step("returning to Runs and opening run 430 (Summary tab)"); await page.fill("#url", artifactServerUrl); await page.clickText("nav.tabs button.tab", "Runs"); await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); await openRunDetail(430); // The run-detail tabs, in the app's order (Summary / Graph / Input / Output / // Timeline; the Graph body is R5 and now rendered). const runTabs = await page.evaluate( `[...document.querySelectorAll(".detail .detail-tabs .detail-tab")].map((n) => n.textContent)`, ); if ( JSON.stringify(runTabs) !== JSON.stringify(["Summary", "Graph", "Input", "Output", "Timeline"]) ) { throw new Error(`run tabs are wrong: ${runTabs.join(",")}`); } console.log(` run tabs: ${runTabs.join(" / ")}`); // The run identity line, in the exact recorded/completed vocabulary. const identity = await page.evaluate(`document.querySelector(".run-identity")?.textContent ?? ""`); if (!/^run 430 · \d+ recorded visits? · \d+ completed visits?$/.test(identity)) { throw new Error(`run identity line is wrong: ${identity}`); } const runTitle = await page.evaluate( `document.querySelector(".run-detail-title")?.textContent ?? ""`, ); console.log(` summary: ${runTitle} — ${identity}`); shots.push(await page.screenshot(`${out}/20-run-430-summary.png`)); // The run-level artifacts gallery (R8), collapsed by default in Summary. step("expanding run 430's summary artifacts section (R8)"); await page.clickText(".run-detail .section-toggle", "Artifacts"); await page.waitForSelector(".run-detail .artifact-gallery .artifact-tile", { timeout: 25000 }); const runTiles = await page.evaluate( `document.querySelectorAll(".run-detail .artifact-gallery .artifact-tile").length`, ); console.log(` run 430 run-level gallery tiles: ${runTiles}`); if (runTiles !== 18) throw new Error(`expected 18 run-level artifact tiles, got ${runTiles}`); await page.rect(".run-detail .artifact-gallery"); shots.push(await page.screenshot(`${out}/04-run-430-artifacts.png`)); step("opening an image artifact in the full-screen viewer"); await page.click(".run-detail .artifact-gallery .artifact-tile img"); await page.waitForSelector(".artifact-viewer", { timeout: 15000 }); await page.waitForText("Close viewer", { timeout: 15000 }); const position = await page.evaluate( `document.querySelector(".viewer-position")?.textContent ?? ""`, ); console.log(` viewer position: ${position}`); // Best effort: give the full-resolution image a moment to decode. await eventually( () => page.evaluate( `(() => { const i = document.querySelector(".viewer-image"); return !!i && i.complete && i.naturalWidth > 0; })()`, ), { timeout: 8000, what: "the viewer image" }, ).catch(() => console.log(" (viewer image still loading)")); shots.push(await page.screenshot(`${out}/05-artifact-viewer.png`)); await page.click(".viewer-close"); await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), { timeout: 5000, what: "the viewer to close", }); // R6: one collapsed field section per recorded input/output entry. step("opening the Input tab and expanding a field section"); await page.clickText(".detail .detail-tabs .detail-tab", "Input"); await page.waitForSelector(".detail .run-tab-body .collapsible .section-toggle", { timeout: 15000 }); const inputEmpty = await page.evaluate( `document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`, ); if (inputEmpty !== "") throw new Error(`run 430 input unexpectedly empty: ${inputEmpty}`); await page.click(".detail .run-tab-body .collapsible .section-toggle"); await page.waitForSelector(".detail .run-tab-body .field-block", { timeout: 15000 }); const inputTitles = await page.evaluate( `[...document.querySelectorAll(".detail .run-tab-body .section-title")].map((n) => n.textContent)`, ); console.log(` input fields: ${inputTitles.join(", ")}`); shots.push(await page.screenshot(`${out}/21-run-430-input.png`)); step("opening the Output tab and expanding a field section"); await page.clickText(".detail .detail-tabs .detail-tab", "Output"); await page.waitForSelector(".detail .run-tab-body .collapsible .section-toggle", { timeout: 15000 }); await page.click(".detail .run-tab-body .collapsible .section-toggle"); await page.waitForSelector(".detail .run-tab-body .field-block", { timeout: 15000 }); const outputTitles = await page.evaluate( `[...document.querySelectorAll(".detail .run-tab-body .section-title")].map((n) => n.textContent)`, ); console.log(` output fields: ${outputTitles.join(", ")}`); shots.push(await page.screenshot(`${out}/22-run-430-output.png`)); // R7: one compact row per visit, in step order. step("opening the Timeline tab"); await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); await page.waitForSelector(".detail .timeline-row", { timeout: 15000 }); const timelineRows = await page.evaluate( `[...document.querySelectorAll(".detail .timeline-row .timeline-title")].map((n) => n.textContent)`, ); console.log(` timeline: ${timelineRows.join(" | ")}`); if (timelineRows.length !== 3) throw new Error(`expected 3 timeline rows, got ${timelineRows.length}`); if (timelineRows[0] !== "reviewer · visit 3") { throw new Error(`first timeline row is wrong: ${timelineRows[0]}`); } shots.push(await page.screenshot(`${out}/23-run-430-timeline.png`)); // R3: the stage pane: headline rows, Verdict block and the visit's gallery. step("opening the ui_reviewer stage pane: headline, Verdict and its artifact gallery"); await page.click('.detail .timeline-row[data-stage-key="ui_reviewer"]'); await page.waitForSelector(".stage-pane", { timeout: 15000 }); await page.waitForText("Verdict", { timeout: 15000 }); const headline = await page.evaluate( `[...document.querySelectorAll(".stage-pane-body > .kv-row > .kv-key")].map((n) => n.textContent)`, ); console.log(` pane headline: ${headline.join(", ")}`); for (const label of ["Status", "Outcome", "Duration", "Visit", "Target", "Session"]) { if (!headline.includes(label)) throw new Error(`stage pane headline missing: ${label}`); } const verdictTitle = await page.evaluate( `document.querySelector(".stage-pane .verdict-title")?.textContent ?? ""`, ); const verdictOption = await page.evaluate( `document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? ""`, ); if (verdictTitle !== "Verdict") throw new Error(`verdict heading is wrong: ${verdictTitle}`); console.log(` verdict: ${verdictTitle} — ${verdictOption}`); await page.clickText(".stage-pane .section-toggle", "Artifacts"); await page.waitForSelector(".stage-pane .artifact-tile", { timeout: 15000 }); const paneTiles = await page.evaluate(`document.querySelectorAll(".stage-pane .artifact-tile").length`); console.log(` ui_reviewer visit 2 pane tiles: ${paneTiles}`); shots.push(await page.screenshot(`${out}/24-run-430-stage-artifacts.png`)); // Escape closes the pane and returns focus to the timeline row that opened it. step("closing the pane with Escape returns focus to the timeline row"); await page.evaluate( `document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`, ); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the stage pane to close on Escape", }); const restored = await page.evaluate( `(() => { const el = document.activeElement; return el ? el.getAttribute("data-stage-key") ?? "" : ""; })()`, ); if (restored !== "ui_reviewer") throw new Error(`focus did not return to the timeline row: ${restored}`); console.log(` focus returned to timeline row: ${restored}`); // R9: the visit's exported session file, opened from the pane's Session section. step("opening the reviewer stage pane and its Session export link (R9)"); await page.click('.detail .timeline-row[data-stage-key="reviewer"]'); await page.waitForSelector(".stage-pane", { timeout: 15000 }); await page.clickText(".stage-pane .section-toggle", "Session"); await page.waitForSelector(".stage-pane .session-link", { timeout: 15000 }); const sessionHref = await page.evaluate( `document.querySelector(".stage-pane .session-link")?.getAttribute("href") ?? ""`, ); if (!/session\.html$/.test(sessionHref)) { throw new Error(`the session export link did not resolve: ${sessionHref}`); } console.log(` session export link: ${sessionHref}`); shots.push(await page.screenshot(`${out}/06-session-export-link.png`)); await page.click(".stage-pane-back"); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the stage pane to close on Back", }); // The verdict-bearing stage pane on the failed run 440. step("opening run 440 and capturing its verdict-bearing stage pane"); await openRunDetail(440); await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); await page.waitForSelector(".detail .timeline-row", { timeout: 15000 }); await page.click(".detail .timeline-row"); await page.waitForSelector(".stage-pane", { timeout: 15000 }); await page.waitForText("Verdict", { timeout: 15000 }); const verdict440 = await page.evaluate( `document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? ""`, ); console.log(` run 440 verdict: ${verdict440}`); shots.push(await page.screenshot(`${out}/25-run-440-verdict.png`)); await page.evaluate( `document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`, ); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the run 440 pane to close", }); // The Timeline empty state, on a run that recorded no visits (R7). step("opening run 428: the Timeline empty state"); await openRunDetail(428); await page.clickText(".detail .detail-tabs .detail-tab", "Timeline"); await page.waitForSelector(".detail .run-tab-body .run-empty", { timeout: 15000 }); const emptyTimeline = await page.evaluate( `document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`, ); if (emptyTimeline !== "No visits recorded.") { throw new Error(`timeline empty state is wrong: ${emptyTimeline}`); } console.log(` timeline empty state: ${emptyTimeline}`); shots.push(await page.screenshot(`${out}/26-run-428-timeline-empty.png`)); // R5: the run-detail Graph tab — the shared workflow graph in run mode. Run 438 // is a finished run with several visits and the full outcome set: its graph // shows the Executed / Not executed legend, solid executed nodes and arrowed // executed routes, and dashed untaken routes. Clicking a stage opens the // existing visit pane (with its Verdict) at that stage's latest visit. Run 440 // shows the hollow, dashed nodes for the stages the failed run never reached. step("opening run 438 and capturing its Graph tab (R5)"); await page.click('.list.runs .run-row-meta[data-run-id="438"]'); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); await page.clickText(".detail .detail-tabs .detail-tab", "Graph"); await page.waitForSelector(".run-detail .graph-note", { timeout: 15000 }); const runGraphNote = await text(".run-detail .graph-note"); if (!runGraphNote.includes("pulses with its elapsed time")) { throw new Error(`unexpected run graph note: ${runGraphNote}`); } await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 }); await eventually(async () => { const current = await graphState(); return current != null && current.scale > 0; }, { what: "the run graph to lay out" }); const legend = await page.evaluate( `[...document.querySelectorAll(".run-detail .graph-legend .graph-legend-label")].map((n) => n.textContent)`, ); if (JSON.stringify(legend) !== JSON.stringify(["Executed", "Not executed"])) { throw new Error(`the run graph legend is wrong: ${JSON.stringify(legend)}`); } const graph438 = await page.evaluate(`(() => ({ executedNodes: document.querySelectorAll(".run-detail .graph-node.executed").length, notExecutedNodes: document.querySelectorAll(".run-detail .graph-node.not-executed").length, executedEdges: document.querySelectorAll(".run-detail .graph-edge-path.executed").length, notExecutedEdges: document.querySelectorAll(".run-detail .graph-edge-path.not-executed").length, arrowedEdges: document.querySelectorAll('.run-detail .graph-edge-path[marker-end]').length, active: document.querySelectorAll(".run-detail .graph-node.active").length, }))()`); if (!graph438.executedNodes || !graph438.executedEdges || !graph438.notExecutedEdges) { throw new Error(`run 438 should show executed stages and both executed/untaken routes: ${JSON.stringify(graph438)}`); } if (graph438.arrowedEdges !== graph438.executedEdges) { throw new Error(`only executed routes carry an arrowhead: ${JSON.stringify(graph438)}`); } if (graph438.active !== 0) { throw new Error(`a finished run must have no active halo: ${JSON.stringify(graph438)}`); } console.log( ` run 438 graph: ${graph438.executedNodes} executed / ${graph438.notExecutedNodes} not-executed nodes, ` + `${graph438.executedEdges} arrowed / ${graph438.notExecutedEdges} dashed routes, legend ${legend.join("/")}`, ); await page.rect(".run-detail .graph-viewport"); shots.push(await page.screenshot(`${out}/28-run-438-graph.png`)); step("opening a stage's visit pane from the run 438 graph"); await page.evaluate( `document.querySelector('.run-detail .graph-node[data-key="ui_reviewer"]').click()`, ); await page.waitForSelector(".stage-pane", { timeout: 15000 }); await page.waitForText("Verdict", { timeout: 15000 }); const graphPane = await page.evaluate(`(() => ({ title: document.querySelector(".stage-pane-title")?.textContent ?? "", verdict: document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? "", }))()`); if (graphPane.title !== "ui_reviewer") { throw new Error(`the graph-opened pane named the wrong stage: ${graphPane.title}`); } if (!graphPane.verdict) throw new Error("the graph-opened pane did not show a verdict"); console.log(` graph-opened pane: ${graphPane.title} — verdict ${graphPane.verdict}`); await page.rect(".stage-pane-sheet"); shots.push(await page.screenshot(`${out}/29-run-438-graph-pane.png`)); await page.click(".stage-pane-back"); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the graph stage pane to close", }); step("opening run 440 to capture the hollow, not-executed stages (R5)"); await page.click('.list.runs .run-row-meta[data-run-id="440"]'); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); await page.clickText(".detail .detail-tabs .detail-tab", "Graph"); await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 }); const graph440 = await page.evaluate(`(() => ({ executedNodes: document.querySelectorAll(".run-detail .graph-node.executed").length, notExecutedNodes: document.querySelectorAll(".run-detail .graph-node.not-executed").length, hollow: [...document.querySelectorAll(".run-detail .graph-node.not-executed")].every( (n) => getComputedStyle(n).borderStyle === "dashed", ), }))()`); if (!graph440.executedNodes || !graph440.notExecutedNodes) { throw new Error(`run 440 should show visited and unvisited stages: ${JSON.stringify(graph440)}`); } if (!graph440.hollow) { throw new Error(`an unvisited node is not hollow/dashed: ${JSON.stringify(graph440)}`); } console.log(` run 440 graph: ${graph440.executedNodes} executed / ${graph440.notExecutedNodes} not-executed (dashed) nodes`); await page.rect(".run-detail .graph-viewport"); shots.push(await page.screenshot(`${out}/30-run-440-graph.png`)); // R5: a live run's Graph tab — the current stage carries the pulsing halo and // a ticking elapsed badge; a finished run (above) carries neither. Best effort: // the run may stop before we look, so skip rather than fail if none is running. step("opening a live run's Graph tab (R5: halo + elapsed badge)"); const liveRunId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); if (liveRunId == null) { console.log(" -- no running run available; skipped the live graph halo capture"); } else { await page.click(`.list.runs .run-row-meta[data-run-id="${liveRunId}"]`); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); await page.clickText(".detail .detail-tabs .detail-tab", "Graph"); await page.waitForSelector(".run-detail .graph-node", { timeout: 15000 }); const live = await eventually( async () => page.evaluate(`(() => { const active = document.querySelector(".run-detail .graph-node.active"); if (!active) return null; return { activeKey: active.dataset.key ?? "", pulsing: active.classList.contains("pulsing"), badge: active.querySelector(".graph-elapsed")?.textContent ?? "", }; })()`), { timeout: 15000, what: "the live run's active stage" }, ); if (!live.badge) throw new Error(`the active stage showed no elapsed badge: ${JSON.stringify(live)}`); console.log(` live run ${liveRunId}: active stage ${live.activeKey} (pulsing=${live.pulsing}), badge ${live.badge}`); await page.rect(".run-detail .graph-viewport"); shots.push(await page.screenshot(`${out}/31-run-live-graph.png`)); } // The Output empty state, on the running run that has not produced output yet. step("opening the Output tab on a run with no output recorded"); const runningId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); if (runningId == null) { console.log(" -- no running run available; skipped the output empty state"); } else { await openRunDetail(runningId); await page.clickText(".detail .detail-tabs .detail-tab", "Output"); await page.waitForSelector(".detail .run-tab-body .run-empty", { timeout: 15000 }); const emptyOutput = await page.evaluate( `document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`, ); if (emptyOutput !== "No output recorded.") { throw new Error(`output empty state is wrong: ${emptyOutput}`); } console.log(` output empty state (run ${runningId}): ${emptyOutput}`); shots.push(await page.screenshot(`${out}/27-run-output-empty.png`)); } // T5: the connected connection banner, the server build line and the live // badge. The banner is in normal flow under the header, so scroll to the top. step("capturing the connected banner, server build and live badge (T5)"); await page.clickText("nav.tabs button.tab", "Runs"); await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); // Assert the connection before this capture rather than trusting a long-lived // socket that may have dropped while the earlier screens were captured. await ensureConnected(); await page.evaluate(`window.scrollTo(0, 0)`); const connectedText = await text(".conn-banner .conn-banner-text"); if (!connectedText.includes("Connected")) throw new Error(`connected banner text: ${connectedText}`); const buildLabel = await text(".conn-banner .conn-build"); if (!buildLabel.startsWith("Server build ")) throw new Error(`missing server build line: ${buildLabel}`); const live = await page.evaluate(`(() => { const badge = document.querySelector(".list.runs .live-badge"); return badge ? { text: badge.textContent.trim(), cls: badge.className } : null; })()`); if (!live) throw new Error("no live badge rendered in the runs list"); console.log(` banner: ${connectedText} — ${buildLabel}; badge: ${live.text} (${live.cls})`); await shot("28-connected-banner.png"); // T3/T4: the disconnected banner with the retry message. Point the page at a // closed port, disconnect, then use the Reconnect control beside the URL field // (T3) and let the attempt fail: a failed reconnect is expected here and must // not fail the run. step("capturing the disconnected banner with the retry message (T3/T4)"); const closedPort = await freePort(); await page.fill("#url", `ws://127.0.0.1:${closedPort}/connect`); await page.click("#connectBtn"); // currently connected: this Disconnects await page.waitForSelector("#reconnectBtn", { timeout: 15000 }); const idleText = await text(".conn-banner .conn-banner-text"); if (idleText !== "Not connected. Enter the server URL in Settings, then connect.") { throw new Error(`idle banner text: ${idleText}`); } await page.click("#reconnectBtn"); // immediate reconnect to the closed port await page.waitForSelector(".conn-banner.conn-error", { timeout: 15000 }); await page.waitForText("retrying with backoff", { timeout: 15000 }); const disconnectedText = await text(".conn-banner .conn-banner-text"); if (!/^Disconnected: .+ · retrying with backoff$/.test(disconnectedText)) { throw new Error(`disconnected banner text: ${disconnectedText}`); } // The banner text is ConnectionBanner.kt verbatim (no attempt); the retry // attempt is the header state badge's job, so the capture must show it there. const badgeText = await text("#stateBadge"); if (!/disconnected .+ \(attempt \d+, retrying\)/.test(badgeText)) { throw new Error(`disconnected state badge does not name the attempt: ${badgeText}`); } console.log(` disconnected banner: ${disconnectedText}`); console.log(` disconnected badge: ${badgeText}`); await shot("29-disconnected-banner.png"); // T4: return-to-foreground recovery. Point back at the live server and let the // page's own `online` handler drive the socket back without a Reconnect click. // The decision itself (foregroundAction) is unit-tested in // test/connection.test.mjs; this proves the rendered recovery in the browser. step("recovering via the browser's online event and capturing the banner (T4)"); await page.fill("#url", `ws://127.0.0.1:${port}/connect`); const foregroundText = await text(".conn-banner .conn-banner-text"); if (!foregroundText.startsWith("Disconnected:")) { throw new Error(`expected a disconnected state before the online event: ${foregroundText}`); } await page.evaluate(`window.dispatchEvent(new Event("online"))`); await page.waitForSelector(".conn-banner.conn-ok", { timeout: 25000 }); await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); await page.evaluate(`window.scrollTo(0, 0)`); const recoveredText = await text(".conn-banner .conn-banner-text"); if (!recoveredText.includes("Connected")) throw new Error(`recovered banner text: ${recoveredText}`); console.log(` recovered banner after window online: ${recoveredText}`); await shot("30-reconnect-recovered.png"); // R4: the run Summary's collapsible Changes section and its rendered/raw diff // viewer. Run 438 changed 22 unique files across 6 steps with every capture // partial, so the header/row count are asserted against each other rather than // against a hardcoded total. const changesToggle = () => page.evaluate(`(() => { const t = [...document.querySelectorAll(".run-detail .collapsible .section-toggle")] .find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? "")); if (!t) return null; return { title: t.querySelector(".section-title")?.textContent ?? "", expanded: t.getAttribute("aria-expanded"), rows: t.parentElement?.querySelectorAll(".change-row").length ?? 0, }; })()`); const expandChanges = async () => { const marked = await page.evaluate(`(() => { const t = [...document.querySelectorAll(".run-detail .collapsible .section-toggle")] .find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? "")); if (!t) return false; t.scrollIntoView({ block: "center" }); t.setAttribute("data-test-changes-toggle", "1"); return true; })()`); if (!marked) throw new Error("no Changes section toggle rendered"); await page.click("[data-test-changes-toggle='1']"); await page.evaluate( `document.querySelector("[data-test-changes-toggle='1']")?.removeAttribute("data-test-changes-toggle")`, ); await page.waitForSelector(".run-detail .changes-list .change-row", { timeout: 15000 }); }; const closeChangeViewer = async (how) => { if (how === "escape") { await page.evaluate( `document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`, ); } else if (how === "backdrop") { await page.evaluate(`document.querySelector(".change-viewer").click()`); } else { await page.click(".change-viewer-close"); } await eventually(() => page.evaluate(`!document.querySelector(".change-viewer")`), { timeout: 5000, what: `the diff viewer to close (${how})`, }); }; step("opening run 438: the collapsed Changes section (R4)"); await page.click('.list.runs .run-row-meta[data-run-id="438"]'); await page.waitForText("run 438 ·", { timeout: 25000 }); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); const collapsed = await changesToggle(); if (!collapsed) throw new Error("run 438's Summary rendered no Changes section"); if (collapsed.expanded !== "false") { throw new Error(`the Changes section is not collapsed on first render: ${collapsed.expanded}`); } if (collapsed.rows !== 0) throw new Error(`a collapsed Changes section drew ${collapsed.rows} row(s)`); const changesCount = Number((/^(\d+) files? changed/.exec(collapsed.title) ?? [])[1] ?? 0); if (!changesCount) throw new Error(`the Changes header has no file count: ${collapsed.title}`); if (!collapsed.title.includes("partial capture")) { throw new Error(`run 438's Changes header should note the partial capture: ${collapsed.title}`); } console.log(` collapsed changes header: ${collapsed.title}`); shots.push(await page.screenshot(`${out}/28-run-438-changes-collapsed.png`)); step("expanding the Changes section: the observed-file rows"); await expandChanges(); const expanded = await page.evaluate(`(() => ({ summary: document.querySelector(".run-detail .changes-summary")?.textContent ?? "", note: document.querySelector(".run-detail .changes-note")?.textContent ?? "", rows: document.querySelectorAll(".run-detail .changes-list .change-row").length, kinds: [...document.querySelectorAll(".run-detail .changes-list .change-kind")].map((n) => n.textContent), expanded: [...document.querySelectorAll(".run-detail .collapsible .section-toggle")] .find((n) => /\\d+ files? changed/.test(n.querySelector(".section-title")?.textContent ?? "")) ?.getAttribute("aria-expanded"), }))()`); if (expanded.expanded !== "true") throw new Error("the Changes section did not expand"); if (expanded.rows !== changesCount) { throw new Error(`the Changes section drew ${expanded.rows} rows for a header count of ${changesCount}`); } if (!expanded.note.startsWith("Partial capture: some changes may be missing.")) { throw new Error(`the partial-capture note is missing: ${expanded.note}`); } console.log(` expanded: ${expanded.summary} — ${expanded.rows} row(s)`); console.log(` note: ${expanded.note}`); console.log(` kinds: ${[...new Set(expanded.kinds)].join(", ")}`); await page.evaluate(`document.querySelector(".run-detail .changes-list .change-row")?.scrollIntoView({ block: "center" })`); shots.push(await page.screenshot(`${out}/29-run-438-changes-expanded.png`)); step("opening the rendered diff viewer on the first changed file"); await page.click(".run-detail .changes-list .change-row"); await page.waitForSelector(".change-viewer", { timeout: 15000 }); const rendered = await page.evaluate(`(() => ({ kind: document.querySelector(".change-viewer .change-kind")?.textContent ?? "", path: document.querySelector(".change-viewer-path")?.textContent ?? "", position: document.querySelector(".change-viewer-position")?.textContent ?? "", renderedActive: document.querySelector('.change-form[data-form="rendered"]')?.classList.contains("active") ?? false, renderedDisabled: document.querySelector('.change-form[data-form="rendered"]')?.disabled ?? null, rawDisabled: document.querySelector('.change-form[data-form="raw"]')?.disabled ?? null, hunks: document.querySelectorAll(".change-viewer .change-hunk").length, lines: document.querySelectorAll(".change-viewer .change-line").length, gutter: document.querySelector(".change-viewer .change-gutter")?.textContent ?? "", adds: document.querySelectorAll(".change-viewer .change-text.diff-add").length, removes: document.querySelectorAll(".change-viewer .change-text.diff-remove").length, prevDisabled: document.querySelector('.change-page[data-page="prev"]')?.disabled ?? null, }))()`); if (!rendered.renderedActive || rendered.renderedDisabled !== true) { throw new Error(`Rendered is not the default selected form: ${JSON.stringify(rendered)}`); } if (!rendered.path || !rendered.position.includes("of ")) { throw new Error(`the viewer did not identify its file: ${JSON.stringify(rendered)}`); } if (!rendered.hunks || !rendered.lines) { throw new Error(`the rendered viewer drew no hunks/lines: ${JSON.stringify(rendered)}`); } if (rendered.gutter.trim() === "") throw new Error("the rendered viewer drew no gutter numbers"); if (rendered.prevDisabled !== true) throw new Error("Previous should be disabled on the first file"); console.log( ` rendered: ${rendered.kind} ${rendered.path} — ${rendered.position}; ` + `${rendered.hunks} hunk(s), ${rendered.lines} line(s), ${rendered.adds}+/${rendered.removes}-`, ); shots.push(await page.screenshot(`${out}/30-run-438-changes-diff-rendered.png`)); step("switching the diff viewer to the Raw patch"); await page.evaluate(`document.querySelector('.change-form[data-form="raw"]').click()`); await page.waitForSelector(".change-viewer .change-raw", { timeout: 15000 }); const raw = await page.evaluate(`(() => ({ rawActive: document.querySelector('.change-form[data-form="raw"]')?.classList.contains("active") ?? false, renderedDisabled: document.querySelector('.change-form[data-form="rendered"]')?.disabled ?? null, text: document.querySelector(".change-viewer .change-raw")?.textContent ?? "", }))()`); if (!raw.rawActive) throw new Error("Raw patch did not become the selected form"); if (!raw.text.includes("@@")) { throw new Error(`the raw patch does not look like a unified diff: ${raw.text.slice(0, 80)}`); } console.log(` raw patch: ${raw.text.split("\n")[0]} (${raw.text.length} chars)`); shots.push(await page.screenshot(`${out}/31-run-438-changes-diff-raw.png`)); step("paging between files: Next to the last, then Previous"); await page.evaluate(`document.querySelector('.change-page[data-page="next"]').click()`); await eventually( async () => (await page.evaluate(`document.querySelector(".change-viewer-position")?.textContent ?? ""`)).startsWith("2 of "), { what: "the viewer to page to file 2" }, ); await page.evaluate(`(() => { for (let i = 0; i < 500; i += 1) { const next = document.querySelector('.change-page[data-page="next"]'); if (!next || next.disabled) break; next.click(); } })()`); const last = await page.evaluate(`(() => ({ position: document.querySelector(".change-viewer-position")?.textContent ?? "", nextDisabled: document.querySelector('.change-page[data-page="next"]')?.disabled ?? null, prevDisabled: document.querySelector('.change-page[data-page="prev"]')?.disabled ?? null, }))()`); if (last.nextDisabled !== true) throw new Error("Next is not disabled on the last file"); if (!last.position.startsWith(`${changesCount} of `)) { throw new Error(`the viewer did not reach the last file: ${last.position}`); } console.log(` paged to the last file: ${last.position}`); await page.evaluate(`document.querySelector('.change-page[data-page="prev"]').click()`); await eventually( async () => (await page.evaluate(`document.querySelector(".change-viewer-position")?.textContent ?? ""`)).startsWith(`${changesCount - 1} of `), { what: "the viewer to page back" }, ); step("closing the diff viewer with Escape returns focus to the row"); await closeChangeViewer("escape"); const restoredFocus = await page.evaluate( `document.activeElement?.getAttribute?.("data-change-index") ?? ""`, ); // The viewer was paged back one file just before closing, so focus returns to // that row (index changesCount - 2). if (restoredFocus !== String(changesCount - 2)) { throw new Error(`focus did not return to the opened row: ${restoredFocus}`); } console.log(` focus returned to change row ${restoredFocus}`); step("reopening and closing the diff viewer by a backdrop click"); await page.click(".run-detail .changes-list .change-row"); await page.waitForSelector(".change-viewer", { timeout: 15000 }); await closeChangeViewer("backdrop"); // A binary capture: the honest message in place of a diff, and Raw disabled. step("opening a binary capture (run 442): the honest message and a disabled Raw patch"); await page.click('.list.runs .run-row-meta[data-run-id="442"]'); await page.waitForText("run 442 ·", { timeout: 25000 }); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); await expandChanges(); await page.click(".run-detail .changes-list .change-row"); await page.waitForSelector(".change-viewer .change-honest", { timeout: 15000 }); const binary = await page.evaluate(`(() => ({ message: document.querySelector(".change-viewer .change-honest")?.textContent ?? "", rawDisabled: document.querySelector('.change-form[data-form="raw"]')?.disabled ?? null, hunks: document.querySelectorAll(".change-viewer .change-hunk").length, }))()`); if ( binary.message !== "This is a binary file: the server recorded the change but has no textual diff to show." ) { throw new Error(`the binary message is wrong: ${binary.message}`); } if (binary.rawDisabled !== true) throw new Error("Raw patch should be disabled for a binary file"); if (binary.hunks !== 0) throw new Error("a binary file must not render a fabricated diff"); console.log(` binary: ${binary.message}`); shots.push(await page.screenshot(`${out}/32-run-442-changes-binary.png`)); await closeChangeViewer("close"); // A truncated capture: the truncation reason, still no fabricated diff. step("opening a truncated capture (run 450): the truncation reason"); await page.click('.list.runs .run-row-meta[data-run-id="450"]'); await page.waitForText("run 450 ·", { timeout: 25000 }); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); await expandChanges(); const openedTruncated = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".run-detail .changes-list .change-row")] .find((n) => (n.querySelector(".change-meta")?.textContent ?? "").includes("truncated")); if (!row) return false; row.click(); return true; })()`); if (!openedTruncated) throw new Error("run 450's Changes list showed no truncated row"); await page.waitForSelector(".change-viewer .change-honest", { timeout: 15000 }); const truncated = await page.evaluate( `document.querySelector(".change-viewer .change-honest")?.textContent ?? ""`, ); if ( truncated !== "The server truncated this file's patch at its capture limit; no diff text was recorded." ) { throw new Error(`the truncation reason is wrong: ${truncated}`); } console.log(` truncated: ${truncated}`); shots.push(await page.screenshot(`${out}/33-run-450-changes-truncated.png`)); await closeChangeViewer("close"); // A still-running run: its Changes header must be one of the two valid shapes // for an in-flight capture (the empty `Changes · …` variant, or a file-count // header), never a fabricated complete diff. Its live state decides which, so // the probe accepts either rather than pinning one. step("opening a running run's Changes header"); const pendingRunId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")] .find((n) => n.querySelector(".chip-running")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); if (pendingRunId == null) { console.log(" -- no running run available; skipped the pending Changes header"); } else { await page.click(`.list.runs .run-row-meta[data-run-id="${pendingRunId}"]`); await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 }); const pendingToggle = await page.evaluate(`(() => { // A running run's Changes header has one of two valid shapes: the // empty-capture form (Changes · capture pending / partial capture / // capture incomplete) before any step has recorded files, or the // file-count form ({N} file(s) changed · ±stat · …) once one has. Which // one appears depends on how far the live capture has progressed, so the // probe accepts either rather than assuming the empty variant. return [...document.querySelectorAll(".run-detail .collapsible .section-toggle .section-title")] .map((n) => n.textContent ?? "") .find((t) => /^Changes · /.test(t) || /^\\d+ files? changed/.test(t)) ?? ""; })()`); if (!/^Changes · /.test(pendingToggle) && !/^\d+ files? changed/.test(pendingToggle)) { throw new Error(`a running run's Changes header is wrong: ${pendingToggle}`); } console.log(` running run ${pendingRunId} changes header: ${pendingToggle}`); shots.push(await page.screenshot(`${out}/34-run-${pendingRunId}-changes-pending.png`)); } // S1/S2: omni-search over the real server. The panel is opened from the top // bar; the query is typed through the page's own field, the flat result list // and its controls are asserted, a kind filter is applied and captured, and one // result of each kind is routed to its real destination. Every capture below is // a real screenshot of the rendered page. step("opening omni-search from the top bar (S1)"); await ensureConnected(); await page.clickText("nav.tabs button.tab", "Runs"); await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); const viewSnapshot = () => page.evaluate(`(() => ({ tab: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "", detail: document.querySelector("#content .detail h2")?.textContent ?? "", }))()`); const beforeOpen = await viewSnapshot(); await page.click("#searchToggle"); await page.waitForSelector("#searchInput", { timeout: 15000 }); const chrome = await page.evaluate(`(() => { const input = document.querySelector("#searchInput"); return { placeholder: input?.getAttribute("placeholder") ?? "", autofocused: document.activeElement === input, close: document.querySelector("#searchClose")?.textContent ?? "", }; })()`); if (chrome.placeholder !== "Search pipelines, runs and artifacts") { throw new Error(`search placeholder is wrong: ${chrome.placeholder}`); } if (!chrome.autofocused) throw new Error("the search field was not autofocused on open"); if (chrome.close !== "Close search") throw new Error(`the close control is wrong: ${chrome.close}`); const afterOpen = await viewSnapshot(); if (afterOpen.tab !== beforeOpen.tab || afterOpen.detail !== beforeOpen.detail) { throw new Error(`opening search changed the view: ${JSON.stringify({ beforeOpen, afterOpen })}`); } console.log( ` field autofocused, placeholder "${chrome.placeholder}", "${chrome.close}" present; view stayed ${afterOpen.tab}`, ); const SEARCH_QUERY = "plan"; step(`running a real query ("${SEARCH_QUERY}") and capturing the flat result list (S1)`); await page.fill("#searchInput", SEARCH_QUERY); await page.waitForSelector("#searchResults .search-row", { timeout: 25000 }); const list = await page.evaluate(`(() => ({ kinds: [...document.querySelectorAll("#searchKind option")].map((o) => o.textContent), sorts: [...document.querySelectorAll("#searchSort option")].map((o) => o.textContent), kindValue: document.querySelector("#searchKind")?.value ?? "", sortValue: document.querySelector("#searchSort")?.value ?? "", summary: document.querySelector("#searchSummary")?.textContent ?? "", clear: document.querySelector("#searchClearFilter")?.textContent ?? "", rows: document.querySelectorAll("#searchResults .search-row").length, headers: document.querySelectorAll("#searchResults h1, #searchResults h2, #searchResults h3").length, kindsPresent: [...new Set([...document.querySelectorAll("#searchResults .search-row")].map((r) => r.dataset.kind))], matchedSpans: document.querySelectorAll("#searchResults .search-match").length, }))()`); if ( JSON.stringify(list.kinds) !== JSON.stringify(["All kinds", "Pipelines", "Runs", "Steps", "Fields", "Artifacts", "Versions"]) ) { throw new Error(`kind options are wrong: ${list.kinds.join(",")}`); } if (JSON.stringify(list.sorts) !== JSON.stringify(["Relevance", "Newest first", "Name"])) { throw new Error(`sort options are wrong: ${list.sorts.join(",")}`); } if (list.kindValue !== "" || list.sortValue !== "relevance") { throw new Error(`the default controls are wrong: kind=${list.kindValue} sort=${list.sortValue}`); } if (list.summary !== "All kinds · Relevance") throw new Error(`the summary line is wrong: ${list.summary}`); if (list.clear !== "Clear filter") throw new Error(`the reset control is wrong: ${list.clear}`); if (!list.rows) throw new Error("the query rendered no result rows"); if (list.headers !== 0) throw new Error("the result list carries grouping headers, not a flat list"); if (list.kindsPresent.length < 2) { throw new Error(`the query returned only ${list.kindsPresent.join(",")}, expected a mixed list`); } console.log( ` ${list.rows} flat rows across ${list.kindsPresent.join(",")}; summary "${list.summary}"; ` + `${list.matchedSpans} emphasised snippet span(s)`, ); await page.rect("#searchPanel"); await shot("01-search-results.png"); step("applying a kind filter and capturing it (S1)"); await page.evaluate(`(() => { const select = document.querySelector("#searchKind"); select.value = "pipeline"; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); await eventually( () => page.evaluate(`(() => { const rows = [...document.querySelectorAll("#searchResults .search-row")]; return rows.length > 0 && rows.every((r) => r.dataset.kind === "pipeline"); })()`), { timeout: 25000, what: "the kind filter to narrow the list to pipelines" }, ); const filteredSummary = await text("#searchSummary"); if (filteredSummary !== "Pipelines · Relevance") { throw new Error(`the filtered summary is wrong: ${filteredSummary}`); } const filteredRows = await page.evaluate(`document.querySelectorAll("#searchResults .search-row").length`); console.log(` Pipelines filter: ${filteredRows} row(s), summary "${filteredSummary}"`); await page.rect("#searchPanel"); await shot("02-search-kind-filter.png"); step("Clear filter returns the kind to All kinds"); await page.click("#searchClearFilter"); await eventually(async () => (await text("#searchSummary")) === "All kinds · Relevance", { timeout: 15000, what: "Clear filter to reset the kind", }); console.log(' Clear filter reset the kind to "All kinds"'); step("a Fields filter emphasises the matched snippet in the page, never as markup (S1)"); await page.evaluate(`(() => { const select = document.querySelector("#searchKind"); select.value = "field"; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); await eventually( () => page.evaluate(`!!document.querySelector("#searchResults .search-row .search-match")`), { timeout: 25000, what: "an emphasised snippet span" }, ); const emphasis = await page.evaluate(`(() => { const node = document.querySelector("#searchResults .search-row .search-match"); return { tag: node?.tagName ?? "", inner: node?.firstElementChild?.tagName ?? "", text: node?.textContent ?? "", kind: node?.closest(".search-row")?.dataset.kind ?? "", }; })()`); if (emphasis.tag !== "STRONG" || emphasis.inner !== "U") { throw new Error(`the matched span is not : ${JSON.stringify(emphasis)}`); } if (!emphasis.text) throw new Error("the emphasised span carries no text"); if (emphasis.kind !== "field") throw new Error(`the emphasis is not on a field hit: ${emphasis.kind}`); console.log(` matched snippet emphasised as <${emphasis.tag}><${emphasis.inner}>: "${emphasis.text}"`); // Back to every kind for the routing steps. await page.evaluate(`(() => { const select = document.querySelector("#searchKind"); select.value = ""; select.dispatchEvent(new Event("change", { bubbles: true })); })()`); await eventually(() => page.evaluate(`!!document.querySelector("#searchResults .search-row")`), { timeout: 25000, what: "the unfiltered list", }); step("routing a pipeline hit to its detail (S2)"); const pipelineTarget = await routeSearchKind(SEARCH_QUERY, "pipeline", async () => { await page.waitForSelector("#content .detail h2", { timeout: 25000 }); await page.waitForSelector("#content .detail .monospace", { timeout: 25000 }); return true; }); if (!pipelineTarget) throw new Error("no pipeline result routed to a pipeline detail"); const pipelineView = await page.evaluate(`(() => ({ active: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "", title: document.querySelector("#content .detail h2")?.textContent ?? "", searchOpen: !!document.querySelector("#searchInput"), }))()`); if (!pipelineView.active.startsWith("Pipelines")) { throw new Error(`a pipeline hit landed on ${pipelineView.active}`); } if (!pipelineView.title) throw new Error("the routed pipeline detail has no heading"); if (pipelineView.searchOpen) throw new Error("selecting a result did not close the search panel"); console.log(` ${pipelineTarget} -> Pipelines detail "${pipelineView.title}"`); await page.rect("#content .detail"); await shot("03-search-route-pipeline.png"); step("routing a run hit to its detail (S2)"); const runTarget = await routeSearchKind(SEARCH_QUERY, "run", async () => { await eventually( () => page.evaluate(`(() => { const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? ""; return tab.startsWith("Runs") && !!document.querySelector("#content .detail .detail-tabs"); })()`), { timeout: 25000, what: "the routed run detail" }, ); return true; }); if (!runTarget) throw new Error("no run result routed to a run detail"); const runView = await page.evaluate(`(() => ({ active: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "", title: document.querySelector("#content .detail h2")?.textContent ?? "", tabs: [...document.querySelectorAll("#content .detail .detail-tabs .detail-tab")].map((n) => n.textContent), }))()`); if (!runView.active.startsWith("Runs")) throw new Error(`a run hit landed on ${runView.active}`); if (!runView.tabs.includes("Summary")) throw new Error(`the routed run detail has no tabs: ${runView.tabs}`); console.log(` ${runTarget} -> Runs detail "${runView.title}" (${runView.tabs.join("/")})`); await page.rect("#content .detail"); await shot("04-search-route-run.png"); step("routing a field hit to the run-detail tab holding the match (S2)"); const fieldTargets = await searchTargets(SEARCH_QUERY, "field"); let fieldRoute = null; for (const target of fieldTargets.slice(0, 4)) { // data-target is run:{id}:{sequence}:{matchedField}. const matchedField = target.split(":")[3] ?? ""; const expectedTab = matchedField === "input" ? "Input" : matchedField === "output" ? "Output" : "Summary"; await searchTargets(SEARCH_QUERY, "field"); if (!(await clickSearchTarget(target))) continue; const landed = await eventually( () => page.evaluate(`(() => { const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? ""; const active = document.querySelector("#content .detail .detail-tabs .detail-tab.active")?.textContent ?? ""; return tab.startsWith("Runs") && active === ${JSON.stringify(expectedTab)}; })()`), { timeout: 25000, what: `the ${expectedTab} run-detail tab` }, ) .then(() => true) .catch(() => false); if (landed) { fieldRoute = { target, matchedField, expectedTab }; break; } } if (!fieldRoute) throw new Error("no field result opened the run-detail tab holding its match"); console.log(` ${fieldRoute.target} (matched_field ${fieldRoute.matchedField}) -> ${fieldRoute.expectedTab} tab`); await page.rect("#content .detail"); await shot("05-search-route-field.png"); step("routing a step hit to the visit's stage pane (S2)"); const stepTarget = await routeSearchKind(SEARCH_QUERY, "step", async () => { await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), { timeout: 20000, what: "the routed visit stage pane", }); return true; }); if (!stepTarget) throw new Error("no step result opened a visit stage pane"); const stepPane = await page.evaluate(`(() => ({ title: document.querySelector(".stage-pane-title")?.textContent ?? "", tab: document.querySelector("nav.tabs button.tab.active")?.textContent ?? "", }))()`); if (!stepPane.title) throw new Error("the routed stage pane named no stage"); if (!stepPane.tab.startsWith("Runs")) throw new Error(`the step route landed on ${stepPane.tab}`); console.log(` ${stepTarget} -> run stage pane "${stepPane.title}"`); await page.rect(".stage-pane-sheet"); await shot("06-search-route-step.png"); await page.click(".stage-pane-back"); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the step stage pane to close", }); step("routing an artifact hit to the same visit pane (S2)"); const artifactTarget = await routeSearchKind(SEARCH_QUERY, "artifact", async () => { await eventually(() => page.evaluate(`!!document.querySelector(".stage-pane")`), { timeout: 20000, what: "the routed artifact visit pane", }); return true; }); if (artifactTarget) { const artifactPane = await page.evaluate( `document.querySelector(".stage-pane-title")?.textContent ?? ""`, ); console.log(` ${artifactTarget} -> run stage pane "${artifactPane}"`); await page.rect(".stage-pane-sheet"); await shot("07-search-route-artifact.png"); await page.click(".stage-pane-back"); await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), { timeout: 5000, what: "the artifact stage pane to close", }); } else { console.log(" -- no artifact hit routed to a visit pane; skipped the artifact capture"); } step("routing a version hit to its pipeline detail (S2)"); const versionTarget = await routeSearchKind(SEARCH_QUERY, "version", async () => { await eventually( () => page.evaluate(`(() => { const tab = document.querySelector("nav.tabs button.tab.active")?.textContent ?? ""; return tab.startsWith("Pipelines") && !!document.querySelector("#content .detail h2"); })()`), { timeout: 25000, what: "the pipeline detail for the version" }, ); return true; }); if (versionTarget) { const versionTitle = await text("#content .detail h2"); console.log(` ${versionTarget} -> Pipelines detail "${versionTitle}"`); await page.rect("#content .detail"); await shot("08-search-route-version.png"); } else { console.log(" -- no version hit routed; skipped the version capture"); } step("Closing search clears the query and leaves the view intact (S1)"); await searchTargets("release", "field"); const beforeClose = await viewSnapshot(); await page.click("#searchClose"); await eventually(() => page.evaluate(`!document.querySelector("#searchInput")`), { timeout: 10000, what: "the search panel to close", }); const afterClose = await viewSnapshot(); if (afterClose.tab !== beforeClose.tab || afterClose.detail !== beforeClose.detail) { throw new Error(`closing search changed the view: ${JSON.stringify({ beforeClose, afterClose })}`); } await page.click("#searchToggle"); await page.waitForSelector("#searchInput", { timeout: 15000 }); const reopenedQuery = await page.evaluate(`document.querySelector("#searchInput")?.value ?? ""`); if (reopenedQuery !== "") throw new Error(`closing search did not clear the query: "${reopenedQuery}"`); await page.evaluate( `document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`, ); await eventually(() => page.evaluate(`!document.querySelector("#searchInput")`), { timeout: 10000, what: "Escape to close the search", }); console.log(" Close search cleared the query and kept the view; Escape also closed the field"); // R13/R14: the run-level actions on run 440 (failed, not executing). The // Retry action is offered; Cancel is not. The Retry confirm and its secondary // Restart-from-start confirm are captured and dismissed with Keep — no run is // started here. The rename field is captured pre-filled, then a blank rename is // actually sent: the live server refuses it without mutating anything, so the // shared Action-failed dialog shows the server's own reason. step("R13/R14: run 440 (failed) — Retry eligibility, restart confirm and the rename field"); // The search block above leaves the routed detail (a Pipelines detail) on // screen; R13/R14 needs the Runs list rendered before it can open run 440. await page.clickText("nav.tabs button.tab", "Runs"); await page.waitForSelector(".list.runs .run-row", { timeout: 25000 }); await openRunDetail(440); const actions440 = await page.evaluate(`(() => ({ retry: !!document.querySelector(".run-detail .run-actions .retry-run"), cancel: !!document.querySelector(".run-detail .run-actions .cancel-run"), }))()`); if (!actions440.retry) throw new Error("run 440 (failed, not executing) offered no Retry action"); if (actions440.cancel) throw new Error("run 440 (not executing) must not offer a Cancel action"); shots.push(await page.screenshot(`${out}/35-run-440-run-actions.png`)); step("R13: the Retry confirm — resume is the default, Restart from start is secondary"); await page.click(".run-detail .run-actions .retry-run"); await page.waitForSelector(".confirm-dialog.confirm-retry", { timeout: 15000 }); const retryDialog = await page.evaluate(`(() => ({ title: document.querySelector(".confirm-retry .confirm-title")?.textContent ?? "", message: document.querySelector(".confirm-retry .confirm-message")?.textContent ?? "", confirm: document.querySelector(".confirm-retry .confirm-accept")?.textContent ?? "", dismiss: document.querySelector(".confirm-retry .confirm-dismiss")?.textContent ?? "", secondary: document.querySelector(".confirm-retry .confirm-secondary")?.textContent ?? "", }))()`); if (retryDialog.title !== "Retry run 440?") throw new Error(`retry title: ${retryDialog.title}`); if (retryDialog.message !== "Only failed runs can be retried. The server starts a new run from the same input.") { throw new Error(`retry message: ${retryDialog.message}`); } if (retryDialog.confirm !== "Retry") throw new Error(`retry confirm: ${retryDialog.confirm}`); if (retryDialog.dismiss !== "Keep") throw new Error(`retry dismiss: ${retryDialog.dismiss}`); if (retryDialog.secondary !== "Restart from start") { throw new Error(`retry secondary: ${retryDialog.secondary}`); } console.log(` retry dialog: "${retryDialog.title}" — ${retryDialog.message}`); shots.push(await page.screenshot(`${out}/36-run-440-retry-confirm.png`)); step("R13: the Restart-from-start confirm states the whole-pipeline replay"); await page.click(".confirm-retry .confirm-secondary"); await page.waitForSelector(".confirm-dialog.confirm-restart", { timeout: 15000 }); const restartDialog = await page.evaluate(`(() => ({ title: document.querySelector(".confirm-restart .confirm-title")?.textContent ?? "", message: document.querySelector(".confirm-restart .confirm-message")?.textContent ?? "", confirm: document.querySelector(".confirm-restart .confirm-accept")?.textContent ?? "", dismiss: document.querySelector(".confirm-restart .confirm-dismiss")?.textContent ?? "", }))()`); if (restartDialog.title !== "Restart run 440?") throw new Error(`restart title: ${restartDialog.title}`); if (!restartDialog.message.includes("replays the whole pipeline")) { throw new Error(`restart message does not state the whole-pipeline replay: ${restartDialog.message}`); } if (!restartDialog.message.includes("instead of resuming the failed stage")) { throw new Error(`restart message does not contrast with resume: ${restartDialog.message}`); } if (restartDialog.confirm !== "Restart from start") { throw new Error(`restart confirm: ${restartDialog.confirm}`); } if (restartDialog.dismiss !== "Keep") throw new Error(`restart dismiss: ${restartDialog.dismiss}`); console.log(` restart dialog: "${restartDialog.title}" — ${restartDialog.message}`); shots.push(await page.screenshot(`${out}/37-run-440-restart-confirm.png`)); step("R13: dismissing the dialog with Keep sends nothing"); await page.click(".confirm-restart .confirm-dismiss"); await eventually(() => page.evaluate(`!document.querySelector(".confirm-dialog")`), { timeout: 5000, what: "the confirm dialog to close", }); step("R14: the rename field is pre-filled with the current title"); await page.click(".run-detail .rename-open"); await page.waitForSelector(".run-detail .rename-input", { timeout: 15000 }); const renameValue = await page.evaluate( `document.querySelector(".run-detail .rename-input")?.value ?? ""`, ); if (!renameValue) throw new Error("the rename field was not pre-filled with the current title"); console.log(` rename field pre-filled with: ${JSON.stringify(renameValue)}`); shots.push(await page.screenshot(`${out}/38-run-440-rename-field.png`)); step("Action failed: a refused rename shows the server's exact reason"); await page.fill(".run-detail .rename-input", ""); await page.click(".run-detail .rename-save"); await page.waitForSelector(".action-failed", { timeout: 15000 }); const actionFailed = await page.evaluate(`(() => ({ title: document.querySelector(".action-failed .action-failed-title")?.textContent ?? "", message: document.querySelector(".action-failed .action-failed-message")?.textContent ?? "", ok: document.querySelector(".action-failed .action-failed-ok")?.textContent ?? "", }))()`); if (actionFailed.title !== "Action failed") throw new Error(`action-failed title: ${actionFailed.title}`); if (actionFailed.ok !== "OK") throw new Error(`action-failed ok: ${actionFailed.ok}`); if (actionFailed.message !== "a title with usable text is required") { throw new Error(`action-failed message is not the server's own reason: ${actionFailed.message}`); } console.log(` action failed: "${actionFailed.title}" — ${actionFailed.message}`); shots.push(await page.screenshot(`${out}/39-run-440-action-failed.png`)); await page.click(".action-failed .action-failed-ok"); await eventually(() => page.evaluate(`!document.querySelector(".action-failed")`), { timeout: 5000, what: "the Action-failed dialog to close", }); // Leave the rename field without changing anything. await page.click(".run-detail .rename-cancel"); // R12: the Cancel confirm on an executing run. Shown and dismissed with Keep — // no cancel_run is sent (a real cancel is unsafe against a shared live run). step("R12: the Cancel confirm on an executing run (shown, not executed)"); const cancelRunId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); if (cancelRunId == null) { console.log(" -- no executing run available; skipped the Cancel confirm capture"); } else { await openRunDetail(cancelRunId); const cancelOffered = await page.evaluate( `!!document.querySelector(".run-detail .run-actions .cancel-run")`, ); if (!cancelOffered) { console.log(` -- run ${cancelRunId} stopped before the Cancel action could be shown`); } else { await page.click(".run-detail .run-actions .cancel-run"); await page.waitForSelector(".confirm-dialog.confirm-cancel", { timeout: 15000 }); const cancelDialog = await page.evaluate(`(() => ({ title: document.querySelector(".confirm-cancel .confirm-title")?.textContent ?? "", message: document.querySelector(".confirm-cancel .confirm-message")?.textContent ?? "", confirm: document.querySelector(".confirm-cancel .confirm-accept")?.textContent ?? "", dismiss: document.querySelector(".confirm-cancel .confirm-dismiss")?.textContent ?? "", }))()`); if (cancelDialog.title !== `Cancel run ${cancelRunId}?`) { throw new Error(`cancel title: ${cancelDialog.title}`); } if (cancelDialog.message !== "This asks the server to stop the active run.") { throw new Error(`cancel message: ${cancelDialog.message}`); } if (cancelDialog.confirm !== "Cancel run") throw new Error(`cancel confirm: ${cancelDialog.confirm}`); if (cancelDialog.dismiss !== "Keep") throw new Error(`cancel dismiss: ${cancelDialog.dismiss}`); console.log(` cancel dialog (run ${cancelRunId}, not executed): "${cancelDialog.title}" — ${cancelDialog.message}`); shots.push(await page.screenshot(`${out}/40-run-${cancelRunId}-cancel-confirm.png`)); await page.click(".confirm-cancel .confirm-dismiss"); await eventually(() => page.evaluate(`!document.querySelector(".confirm-dialog")`), { timeout: 5000, what: "the Cancel dialog to close", }); } } // R11: the decision card/sheet, only when the live server actually has a run // waiting on a person with recorded options. There is normally none (a human // stage blocks a run until a person answers), so this stays a best-effort // capture rather than a failure; the model is unit-tested in actions.test.mjs. step("R11: the human-decision card/sheet (only when a waiting run is present)"); const waitingRunId = await page.evaluate(`(() => { const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-waiting")); const meta = row?.querySelector(".run-row-meta[data-run-id]"); return meta ? Number(meta.getAttribute("data-run-id")) : null; })()`); if (waitingRunId == null) { console.log(" -- no waiting run available; skipped the decision card/sheet capture (R11 stays partial)"); } else { await openRunDetail(waitingRunId); await page.waitForSelector(".run-detail .decision-card", { timeout: 15000 }); const cardText = await page.evaluate(`(() => ({ title: document.querySelector(".decision-card .decision-card-title")?.textContent ?? "", meta: document.querySelector(".decision-card .decision-card-meta")?.textContent ?? "", action: document.querySelector(".decision-card .decision-open")?.textContent ?? "", }))()`); if (cardText.title !== "Waiting for your decision") throw new Error(`card title: ${cardText.title}`); if (cardText.action !== "Decide") throw new Error(`card action: ${cardText.action}`); console.log(` decision card (run ${waitingRunId}): ${cardText.title} — ${cardText.meta}`); shots.push(await page.screenshot(`${out}/41-run-${waitingRunId}-decision-card.png`)); await page.click(".decision-card .decision-open"); await page.waitForSelector(".decision-sheet .decision-option", { timeout: 15000 }); const sheet = await page.evaluate(`(() => ({ title: document.querySelector(".decision-sheet-title")?.textContent ?? "", meta: document.querySelector(".decision-sheet-meta")?.textContent ?? "", label: document.querySelector(".decision-field-label")?.textContent ?? "", options: [...document.querySelectorAll(".decision-sheet .decision-option-key")].map((n) => n.textContent), confirmDisabled: document.querySelector(".decision-confirm")?.disabled ?? null, }))()`); if (sheet.label !== "Feedback (optional)") throw new Error(`sheet feedback label: ${sheet.label}`); if (sheet.confirmDisabled !== true) { throw new Error("Confirm decision must be disabled until an option is selected"); } console.log(` decision sheet (run ${waitingRunId}): ${sheet.title} — ${sheet.meta}; options ${sheet.options.join(", ")}`); shots.push(await page.screenshot(`${out}/42-run-${waitingRunId}-decision-sheet.png`)); // Selecting an option enables the confirm but sends nothing. await page.click(".decision-sheet .decision-option"); await eventually( () => page.evaluate(`document.querySelector(".decision-confirm")?.disabled === false`), { timeout: 5000, what: "the confirm to enable after selecting an option" }, ); shots.push(await page.screenshot(`${out}/43-run-${waitingRunId}-decision-selected.png`)); // Dismiss with Cancel: no decide_run is sent for a real waiting run here. await page.click(".decision-sheet .decision-cancel"); await eventually(() => page.evaluate(`!document.querySelector(".decision-sheet")`), { timeout: 5000, what: "the decision sheet to close", }); } console.log("\nUI SMOKE PASS"); for (const shot of shots) console.log(` ${shot}`); } catch (error) { failed = true; console.error(`\nUI SMOKE FAIL: ${error.message}`); if (page) { try { shots.push(await page.screenshot(`${out}/failure.png`)); console.error(` failure capture: ${shots.at(-1)}`); console.error((await page.text()).split("\n").slice(0, 25).join("\n")); } catch { // the page may be gone; the error above is the real signal } } } finally { await page?.close().catch(() => {}); await browser?.close().catch(() => {}); serve?.kill("SIGTERM"); await eventually(async () => serve?.exitCode != null, { timeout: 5000, what: "serve exit" }).catch( () => {}, ); if (!failed) await rm(`${out}/failure.png`, { force: true }).catch(() => {}); } process.exit(failed ? 1 : 0);