672c988136
# Conflicts: # web/src/app.js # web/src/client.js # web/src/protocol.js # web/test/chat.test.mjs # web/test/repository.test.mjs # web/test/ui-smoke.mjs
3404 lines
172 KiB
JavaScript
3404 lines
172 KiB
JavaScript
// 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] [--scratch]
|
|
//
|
|
// 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.
|
|
//
|
|
// `--scratch` drives ONLY the P5 create-from-template flow (captures 51/52/53)
|
|
// against a scratch server and skips the live suite, which needs the operator's
|
|
// real runs and chat session. The default run never sends a `submit`: the live
|
|
// server's pipeline list is never mutated.
|
|
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")),
|
|
);
|
|
// Scratch mode: only the P5 create-from-template flow runs, against a throwaway
|
|
// server with its own database. The default (live) run sends no submit.
|
|
const scratch = process.argv.includes("--scratch");
|
|
|
|
// 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;
|
|
// The throwaway chat session this run creates for the running-turn capture. It
|
|
// is closed again in cleanup; null once closed (or when none was created).
|
|
let throwawaySessionId = null;
|
|
|
|
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 ?? ""`);
|
|
|
|
// Bring the composer at the foot of the conversation into view before a capture:
|
|
// the transcript above it is scrollable and can be taller than the viewport, so a
|
|
// composer-state screenshot scrolls the page to its very bottom (past the
|
|
// composer, into the trailing padding) rather than just to the composer's edge.
|
|
const showComposer = () =>
|
|
page.evaluate(`new Promise((resolve) => {
|
|
const composer = document.querySelector("#chatComposer");
|
|
if (composer) composer.scrollIntoView({ block: "end" });
|
|
window.scrollTo(0, document.documentElement.scrollHeight);
|
|
requestAnimationFrame(() => requestAnimationFrame(() => resolve(true)));
|
|
})`);
|
|
|
|
// 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`);
|
|
}
|
|
}
|
|
}
|
|
|
|
// --- P5: create a pipeline from a template (scratch server only) -----------
|
|
// The scratch server has no real runs and no live chat, so this is the whole
|
|
// point of a `--scratch` run. It opens a template, opens the create action,
|
|
// captures the blank/disabled dialog, fills a unique name, creates it, captures
|
|
// the success dialog and then the Pipelines list holding the new row. It sends a
|
|
// real validate + submit, but only ever against the scratch database.
|
|
async function runScratchCreate() {
|
|
step("P5: creating a pipeline from a template (scratch server)");
|
|
await ensureConnected();
|
|
await page.clickText("nav.tabs button.tab", "Templates");
|
|
await page.waitForSelector(".cards button.card", { timeout: 25000 });
|
|
await page.click(".cards button.card");
|
|
await page.waitForSelector(".detail .tabstrip", { timeout: 25000 });
|
|
await page.waitForSelector(".template-create-open", { timeout: 15000 });
|
|
|
|
const actionLabel = await text(".template-create-open");
|
|
if (actionLabel !== "Create pipeline from this template") {
|
|
throw new Error(`create action label: ${actionLabel}`);
|
|
}
|
|
await page.click(".template-create-open");
|
|
await page.waitForSelector(".template-create-dialog", { timeout: 15000 });
|
|
|
|
const blank = await page.evaluate(`(() => ({
|
|
title: document.querySelector(".template-create-title")?.textContent ?? "",
|
|
label: document.querySelector(".template-create-label")?.textContent ?? "",
|
|
note: document.querySelector(".template-create-note")?.textContent ?? "",
|
|
confirm: document.querySelector(".template-create-confirm")?.textContent ?? "",
|
|
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
|
|
confirmDisabled: document.querySelector(".template-create-confirm")?.disabled ?? null,
|
|
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
|
|
}))()`);
|
|
if (!blank.title.startsWith("Create from ")) throw new Error(`create dialog title: ${blank.title}`);
|
|
if (blank.label !== "New pipeline name (required)") throw new Error(`create field label: ${blank.label}`);
|
|
if (blank.note !== "Creates a new draft pipeline on the server from this template's source; it is not run.") {
|
|
throw new Error(`create note: ${blank.note}`);
|
|
}
|
|
if (blank.confirm !== "Create") throw new Error(`create confirm: ${blank.confirm}`);
|
|
if (blank.dismiss !== "Cancel") throw new Error(`create dismiss: ${blank.dismiss}`);
|
|
if (blank.confirmDisabled !== true) throw new Error("Create was enabled with a blank name");
|
|
if (blank.fieldDisabled !== false) throw new Error("the name field started disabled");
|
|
console.log(` blank dialog: "${blank.title}" — Create disabled, field enabled, Cancel offered`);
|
|
await shot("51-template-create-dialog.png");
|
|
|
|
const newName = `Scratch create ${Date.now()}`;
|
|
await page.fill(".template-create-name", newName);
|
|
await eventually(
|
|
() => page.evaluate(`!document.querySelector(".template-create-confirm")?.disabled`),
|
|
{ timeout: 5000, what: "Create to enable after a non-blank name" },
|
|
);
|
|
await page.click(".template-create-confirm");
|
|
await page.waitForText(`Created "${newName}". It is in the Pipelines list.`, { timeout: 25000 });
|
|
const success = await page.evaluate(`(() => ({
|
|
text: document.querySelector(".template-create-success")?.textContent ?? "",
|
|
dismiss: document.querySelector(".template-create-cancel")?.textContent ?? "",
|
|
fieldDisabled: document.querySelector(".template-create-name")?.disabled ?? null,
|
|
}))()`);
|
|
if (success.text !== `Created "${newName}". It is in the Pipelines list.`) {
|
|
throw new Error(`create success line: ${success.text}`);
|
|
}
|
|
if (success.dismiss !== "Close") throw new Error(`dismiss after success: ${success.dismiss}`);
|
|
if (success.fieldDisabled !== true) throw new Error("the name field was not locked after a success");
|
|
console.log(` created: ${JSON.stringify(success.text)}; dismiss now reads ${success.dismiss}`);
|
|
await shot("52-template-created.png");
|
|
|
|
// Cancel now reads Close: dismissing it leaves the Templates view, then the
|
|
// refreshed Pipelines list must hold the new row.
|
|
await page.click(".template-create-cancel");
|
|
await eventually(() => page.evaluate(`!document.querySelector(".template-create-dialog")`), {
|
|
timeout: 5000,
|
|
what: "the create dialog to close",
|
|
});
|
|
await page.clickText("nav.tabs button.tab", "Pipelines");
|
|
await page.waitForText(newName, { timeout: 25000 });
|
|
const listed = await page.evaluate(
|
|
`document.querySelector("#pipelineRows")?.textContent.includes(${JSON.stringify(newName)}) ?? false`,
|
|
);
|
|
if (!listed) throw new Error("the created pipeline is not in the Pipelines list");
|
|
console.log(" the created pipeline appears in the scratch server's Pipelines list");
|
|
await shot("53-pipeline-created-list.png");
|
|
}
|
|
|
|
// --- 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}/`);
|
|
|
|
// C5 evidence needs to replay exact `chat_event` frames against the real page
|
|
// (a real live turn is not available on demand without disrupting the operator's
|
|
// server). A tiny WebSocket shim is installed before the page's own scripts on
|
|
// every document from now on: it constructs the real socket and records it on
|
|
// `window`, so the smoke can hand frames to the socket's own `onmessage` and the
|
|
// app folds them through its real path. Every other frame (the subscribe ack, the
|
|
// history reply) still comes from the real server.
|
|
step("installing the WebSocket recorder shim before the page scripts");
|
|
await page.addInitScript(`(() => {
|
|
const Native = window.WebSocket;
|
|
if (!Native || window.__pipelinesSocketShim) return;
|
|
window.__pipelinesSocketShim = true;
|
|
window.__pipelinesSockets = [];
|
|
function Shim(url, protocols) {
|
|
const ws = protocols === undefined ? new Native(url) : new Native(url, protocols);
|
|
window.__pipelinesSockets.push(ws);
|
|
window.__pipelinesSocket = ws;
|
|
return ws;
|
|
}
|
|
Shim.prototype = Native.prototype;
|
|
for (const key of ["CONNECTING", "OPEN", "CLOSING", "CLOSED"]) Shim[key] = Native[key];
|
|
window.WebSocket = Shim;
|
|
})()`);
|
|
|
|
// 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");
|
|
// A scratch server starts with no pipelines at all, so the pipeline row that
|
|
// proves the live list rendered is skipped there; the connection banner is
|
|
// still awaited either way.
|
|
if (!scratch) await page.waitForSelector(".row-title", { timeout: 25000 });
|
|
await page.waitForText("connected", { timeout: 25000 });
|
|
|
|
// Scratch mode runs only the P5 create flow above and skips the live suite,
|
|
// which needs the operator's real pipelines, runs and chat session. The guard
|
|
// below wraps the live steps without reindenting them, keeping this diff
|
|
// reviewable; both branches share this file's cleanup in the `finally`.
|
|
if (scratch) {
|
|
await runScratchCreate();
|
|
console.log("\nUI SMOKE PASS");
|
|
for (const shot of shots) console.log(` ${shot}`);
|
|
}
|
|
|
|
if (!scratch) {
|
|
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 <strong><u>: ${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",
|
|
});
|
|
}
|
|
|
|
// C1/C3/C4/C7/C14: the chat list, its transcript (markdown + the code the live
|
|
// session carries), paging and the close dialog. The one live operator session
|
|
// is never mutated: the close confirm is shown and dismissed with Cancel.
|
|
step("C1/C3/C4/C7/C14: the chat list, transcript, paging and close dialog");
|
|
await ensureConnected();
|
|
await page.clickText("nav.tabs button.tab", "Chat");
|
|
await page.waitForSelector("#chatRows .chat-row", { timeout: 25000 });
|
|
|
|
const chatList = await page.evaluate(`(() => ({
|
|
label: document.querySelector("#chatSearch")?.getAttribute("aria-label") ?? "",
|
|
placeholder: document.querySelector("#chatSearch")?.getAttribute("placeholder") ?? "",
|
|
rows: [...document.querySelectorAll("#chatRows .chat-row")].map((row) => ({
|
|
id: row.dataset.session ?? "",
|
|
title: row.querySelector(".chat-row-title")?.textContent ?? "",
|
|
chips: [...row.querySelectorAll(".chip")].map((chip) => chip.textContent),
|
|
meta: row.querySelector(".chat-row-meta")?.textContent ?? "",
|
|
close: !!row.querySelector(".chat-close"),
|
|
})),
|
|
}))()`);
|
|
if (chatList.label !== "Search chats") throw new Error(`chat search label: ${chatList.label}`);
|
|
if (chatList.placeholder !== "Search chats") throw new Error(`chat search placeholder: ${chatList.placeholder}`);
|
|
if (chatList.rows.length === 0) throw new Error("no chat sessions rendered");
|
|
if (!chatList.rows[0].title) throw new Error("the first chat row has no title");
|
|
if (!chatList.rows[0].chips.includes("Operator")) {
|
|
throw new Error(`chat kind chip: ${chatList.rows[0].chips.join(", ")}`);
|
|
}
|
|
if (!chatList.rows[0].close) throw new Error("the open chat row offers no Close chat action");
|
|
console.log(
|
|
` chat list: ${chatList.rows.length} session(s); "${chatList.rows[0].title}" ` +
|
|
`[${chatList.rows[0].chips.join(", ")}] — ${chatList.rows[0].meta}`,
|
|
);
|
|
await shot("44-chat-sessions.png");
|
|
|
|
// The row's own Close chat… action with NO conversation open: the list offers
|
|
// it on every open row, so the confirm must still appear. Shown and dismissed
|
|
// with Cancel; no chat_close is ever sent for the operator's live session.
|
|
await page.click(`#chatRows .chat-row[data-session="${chatList.rows[0].id}"] .chat-close`);
|
|
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
|
const listClose = await page.evaluate(
|
|
`document.querySelector(".confirm-chat-close .confirm-message")?.textContent ?? ""`,
|
|
);
|
|
if (!listClose.startsWith('Closes "')) {
|
|
throw new Error(`row-level close message with no conversation open: ${listClose}`);
|
|
}
|
|
await page.click(".confirm-chat-close .confirm-dismiss");
|
|
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
|
timeout: 5000,
|
|
what: "the row-level close dialog to close",
|
|
});
|
|
console.log(
|
|
" row-level 'Close chat…' (no conversation open) showed its confirm; dismissed with Cancel",
|
|
);
|
|
|
|
// The narrowed-to-nothing empty state and its Clear search action (the field
|
|
// itself is the narrowing; the list's order is never touched).
|
|
await page.fill("#chatSearch", "zzz-no-such-chat");
|
|
await page.waitForText('No chats match "zzz-no-such-chat".', { timeout: 10000 });
|
|
await shot("50-chat-no-match.png");
|
|
await page.clickText(".chat-rows .empty button", "Clear search");
|
|
await page.waitForSelector("#chatRows .chat-row", { timeout: 10000 });
|
|
const clearedQuery = await page.evaluate(`document.querySelector("#chatSearch")?.value ?? null`);
|
|
if (clearedQuery !== "") {
|
|
throw new Error(`Clear search left the query: ${JSON.stringify(clearedQuery)}`);
|
|
}
|
|
|
|
const expectedSession = "ses_eae413f50ffeLQDExlg8cYnscN";
|
|
const openedId = chatList.rows[0].id;
|
|
if (openedId !== expectedSession) {
|
|
console.log(` -- the live server's first session is ${openedId}, not the expected ${expectedSession}`);
|
|
}
|
|
await page.click(`#chatRows .chat-row[data-session="${openedId}"]`);
|
|
await page.waitForSelector("#chatTranscript", { timeout: 25000 });
|
|
|
|
const transcript = await page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatTranscript");
|
|
if (!el) return null;
|
|
return {
|
|
userBubbles: el.querySelectorAll(".chat-turn-user").length,
|
|
agentBubbles: el.querySelectorAll(".chat-turn-agent").length,
|
|
markdown: el.querySelectorAll(".markdown").length,
|
|
tables: el.querySelectorAll(".md-table").length,
|
|
inlineCode: el.querySelectorAll(".md-code").length,
|
|
codeBlocks: el.querySelectorAll(".md-code-block").length,
|
|
toolChips: [...el.querySelectorAll(".chat-tool-chip")].map((chip) => chip.textContent),
|
|
reasoning: el.querySelectorAll(".chat-reasoning").length,
|
|
client: el.querySelector(".chat-turn-user .chat-client")?.textContent ?? "",
|
|
hasLoadOlder: !!document.querySelector(".chat-load-older"),
|
|
};
|
|
})()`);
|
|
if (!transcript) throw new Error("the opened transcript did not render");
|
|
if (transcript.userBubbles !== 1) throw new Error(`expected one user bubble, got ${transcript.userBubbles}`);
|
|
if (transcript.agentBubbles !== 1) {
|
|
throw new Error(`expected one folded agent turn, got ${transcript.agentBubbles}`);
|
|
}
|
|
if (transcript.markdown === 0) throw new Error("the agent turn rendered no markdown");
|
|
if (transcript.tables === 0) throw new Error("the agent answer rendered no markdown table");
|
|
if (transcript.inlineCode === 0) throw new Error("the agent answer rendered no inline code");
|
|
if (transcript.toolChips.length !== 1) {
|
|
throw new Error(`expected one tool-call chip, got ${transcript.toolChips.length}`);
|
|
}
|
|
console.log(
|
|
` transcript: ${transcript.userBubbles} user + ${transcript.agentBubbles} folded agent turn; ` +
|
|
`markdown ${transcript.tables} table(s), ${transcript.inlineCode} inline code span(s), ` +
|
|
`${transcript.toolChips[0]}; client label "${transcript.client}"`,
|
|
);
|
|
await shot("45-chat-transcript-newest.png");
|
|
|
|
// The top of the conversation, reached by a genuine operator wheel gesture on
|
|
// the transcript (the app's own listener). Only the operator's gesture changes
|
|
// follow intent — a programmatic scrollTo cannot — so this is the only way
|
|
// "Jump to latest" may appear; the control is asserted, not assumed.
|
|
const wheelGesture = await page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatTranscript");
|
|
if (!el) return null;
|
|
el.scrollTop = 0;
|
|
el.dispatchEvent(new WheelEvent("wheel", { deltaY: -240, bubbles: true }));
|
|
return {
|
|
jumpHidden: document.querySelector("#chatJump")?.hidden ?? null,
|
|
top: el.scrollTop,
|
|
};
|
|
})()`);
|
|
if (!wheelGesture || wheelGesture.jumpHidden !== false) {
|
|
throw new Error(`Jump to latest was not offered after a real wheel gesture: ${JSON.stringify(wheelGesture)}`);
|
|
}
|
|
await shot("46-chat-transcript-top.png");
|
|
console.log(
|
|
` after a real wheel gesture (scrollTop ${wheelGesture.top}) 'Jump to latest' is offered at the top`,
|
|
);
|
|
|
|
// The live assistant answer carries markdown but no fenced block: the session's
|
|
// fenced code lives in its reasoning, which the app renders as plain text
|
|
// (Markdown.kt draws reasoning with a plain Text, never the markdown subset).
|
|
if (transcript.reasoning > 0) {
|
|
const expanded = await page.evaluate(`(() => {
|
|
const block = document.querySelector("#chatTranscript .chat-reasoning");
|
|
if (!block) return null;
|
|
block.querySelector(".chat-reasoning-toggle")?.click();
|
|
const body = block.querySelector(".chat-reasoning-body");
|
|
if (!body) return null;
|
|
// Bring the reasoning's own fenced block into view, so the capture shows
|
|
// the code the live session actually carries.
|
|
const fence = String.fromCharCode(96).repeat(3);
|
|
const text = body.textContent ?? "";
|
|
const index = text.indexOf(fence);
|
|
const transcript = document.querySelector("#chatTranscript");
|
|
if (index >= 0 && transcript && body.firstChild && body.firstChild.nodeType === 3) {
|
|
const range = document.createRange();
|
|
range.setStart(body.firstChild, index);
|
|
range.setEnd(body.firstChild, index + fence.length);
|
|
const rect = range.getBoundingClientRect();
|
|
const tRect = transcript.getBoundingClientRect();
|
|
transcript.scrollTop += Math.round(rect.top - tRect.top) - 120;
|
|
}
|
|
return {
|
|
label: block.querySelector(".chat-reasoning-label")?.textContent ?? "",
|
|
hasFence: index >= 0,
|
|
};
|
|
})()`);
|
|
await eventually(
|
|
() =>
|
|
page.evaluate(
|
|
`(() => { const b = document.querySelector("#chatTranscript .chat-reasoning-body"); return !!b && !b.hidden; })()`,
|
|
),
|
|
{ timeout: 5000, what: "the reasoning block to expand" },
|
|
);
|
|
if (expanded) {
|
|
console.log(` reasoning block "${expanded.label}" expanded; carries a fenced block: ${expanded.hasFence}`);
|
|
}
|
|
await shot("47-chat-reasoning-code.png");
|
|
}
|
|
|
|
// C7's code-block path. The live assistant answer carries no fenced block (its
|
|
// fences live in the reasoning transcript, drawn as plain text — capture 47),
|
|
// so exercise the page's own markdown renderer on a labelled sample and capture
|
|
// the rendered <pre> block; the sample is removed again straight after.
|
|
const fence = String.fromCharCode(96).repeat(3);
|
|
const codeSample = `${fence}js\nconst answer = 42;\n${fence}`;
|
|
const codeBlock = await page.evaluate(`(async () => {
|
|
const mod = await import("/src/app.js");
|
|
const node = mod.renderMarkdown(${JSON.stringify(codeSample)});
|
|
node.id = "markdownCodeSample";
|
|
const wrap = document.querySelector(".chat-detail .chat-transcript-wrap");
|
|
if (!wrap || !wrap.parentNode) return null;
|
|
wrap.parentNode.insertBefore(node, wrap);
|
|
return {
|
|
label: node.querySelector(".md-code-label")?.textContent ?? "",
|
|
hasPre: !!node.querySelector("pre.md-pre code"),
|
|
text: node.querySelector("pre.md-pre code")?.textContent ?? "",
|
|
};
|
|
})()`);
|
|
if (!codeBlock || !codeBlock.hasPre) {
|
|
throw new Error("the page's markdown renderer drew no fenced code block");
|
|
}
|
|
if (codeBlock.label !== "js") throw new Error(`code block label: ${codeBlock.label}`);
|
|
console.log(
|
|
` markdown code block (page renderer sample): label "${codeBlock.label}", text ${JSON.stringify(codeBlock.text)}`,
|
|
);
|
|
await shot("47b-chat-markdown-code.png");
|
|
await page.evaluate(`document.querySelector("#markdownCodeSample")?.remove()`);
|
|
|
|
// C6: the turn's reasoning block and its tool-call chip + panel. The live
|
|
// operator session carries one folded agent turn with real reasoning and tool
|
|
// parts, so the chip, the panel and the rows are exercised against live data.
|
|
// Labels, aria names and the C14 scroll-invariance are asserted, not assumed.
|
|
step("C6: the reasoning block and the tool-call chip + panel");
|
|
const reasoningNow = await page.evaluate(`(() => {
|
|
const block = document.querySelector("#chatTranscript .chat-reasoning");
|
|
if (!block) return null;
|
|
const icon = block.querySelector(".chat-reasoning-icon");
|
|
const body = block.querySelector(".chat-reasoning-body");
|
|
return {
|
|
label: block.querySelector(".chat-reasoning-label")?.textContent ?? "",
|
|
aria: icon?.getAttribute("aria-label") ?? "",
|
|
expanded: body ? !body.hidden : false,
|
|
};
|
|
})()`);
|
|
if (!reasoningNow) throw new Error("C6: no reasoning block rendered in the live transcript");
|
|
if (reasoningNow.aria !== "Hide reasoning") {
|
|
throw new Error(`C6: the expanded reasoning chevron should read 'Hide reasoning', got ${reasoningNow.aria}`);
|
|
}
|
|
if (!/^Reasoning( · \d+ steps)?( · \d+[a-z].*)?$/.test(reasoningNow.label)) {
|
|
throw new Error(`C6: settled reasoning label: ${reasoningNow.label}`);
|
|
}
|
|
const reasoningCollapsed = await page.evaluate(`(() => {
|
|
const block = document.querySelector("#chatTranscript .chat-reasoning");
|
|
block.querySelector(".chat-reasoning-toggle").click();
|
|
const el = document.querySelector("#chatTranscript");
|
|
const br = block.getBoundingClientRect();
|
|
el.scrollTop = Math.max(0, el.scrollTop + Math.round(br.top - el.getBoundingClientRect().top) - 60);
|
|
return {
|
|
hidden: block.querySelector(".chat-reasoning-body").hidden,
|
|
aria: block.querySelector(".chat-reasoning-icon").getAttribute("aria-label"),
|
|
expanded: block.querySelector(".chat-reasoning-toggle").getAttribute("aria-expanded"),
|
|
};
|
|
})()`);
|
|
if (!reasoningCollapsed.hidden || reasoningCollapsed.aria !== "Show reasoning" || reasoningCollapsed.expanded !== "false") {
|
|
throw new Error(`C6: collapsing the reasoning block: ${JSON.stringify(reasoningCollapsed)}`);
|
|
}
|
|
console.log(` reasoning block "${reasoningNow.label}" collapsed (chevron "Show reasoning")`);
|
|
await shot("51-chat-reasoning-collapsed.png");
|
|
const expandedReasoning = await page.evaluate(`(() => {
|
|
const block = document.querySelector("#chatTranscript .chat-reasoning");
|
|
block.querySelector(".chat-reasoning-toggle").click();
|
|
const el = document.querySelector("#chatTranscript");
|
|
const br = block.getBoundingClientRect();
|
|
el.scrollTop = Math.max(0, el.scrollTop + Math.round(br.top - el.getBoundingClientRect().top) - 60);
|
|
return {
|
|
hidden: block.querySelector(".chat-reasoning-body").hidden,
|
|
aria: block.querySelector(".chat-reasoning-icon").getAttribute("aria-label"),
|
|
length: block.querySelector(".chat-reasoning-body").textContent.length,
|
|
};
|
|
})()`);
|
|
if (expandedReasoning.hidden || expandedReasoning.aria !== "Hide reasoning" || expandedReasoning.length === 0) {
|
|
throw new Error(`C6: expanding the reasoning block: ${JSON.stringify(expandedReasoning)}`);
|
|
}
|
|
console.log(` reasoning block expanded again (${expandedReasoning.length} chars, chevron "Hide reasoning")`);
|
|
await shot("52-chat-reasoning-expanded.png");
|
|
|
|
// The chip: its count, its screen-reader announcement and its chevron. The
|
|
// count is the number of rows the panel carries, so the two can never disagree.
|
|
const chipInfo = await page.evaluate(`(() => {
|
|
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
|
|
if (!chip) return null;
|
|
chip.scrollIntoView({ block: "center" });
|
|
return {
|
|
text: chip.textContent ?? "",
|
|
aria: chip.getAttribute("aria-label") ?? "",
|
|
chevron: chip.querySelector(".chat-tool-chevron")?.getAttribute("aria-label") ?? "",
|
|
rows: document.querySelectorAll(".chat-tool-panel .chat-tool-row").length,
|
|
};
|
|
})()`);
|
|
if (!chipInfo) throw new Error("C6: no tool-call chip rendered in the live transcript");
|
|
const toolCount = chipInfo.rows;
|
|
const toolLabel = toolCount === 1 ? "1 tool called" : `${toolCount} tools called`;
|
|
const toolAria =
|
|
toolCount === 1 ? "1 tool call, expand for details" : `${toolCount} tool calls, expand for details`;
|
|
if (!chipInfo.text.includes(toolLabel)) {
|
|
throw new Error(`C6: the chip should read "${toolLabel}", got ${JSON.stringify(chipInfo.text)}`);
|
|
}
|
|
if (chipInfo.aria !== toolAria) {
|
|
throw new Error(`C6: chip aria-label ${chipInfo.aria} (expected ${toolAria})`);
|
|
}
|
|
if (chipInfo.chevron !== "Show tool calls") {
|
|
throw new Error(`C6: collapsed chip chevron: ${chipInfo.chevron}`);
|
|
}
|
|
console.log(` tool chip "${toolLabel}" (aria "${chipInfo.aria}", ${toolCount} live row(s))`);
|
|
await shot("53-chat-tool-chip.png");
|
|
|
|
// Open the panel by dispatching the chip's own click (not a synthetic scroll),
|
|
// then assert the header, the close control and the C14 invariant: opening the
|
|
// panel must not move the transcript behind it.
|
|
const scrollBeforePanel = await page.evaluate(
|
|
`Math.round(document.querySelector("#chatTranscript").scrollTop)`,
|
|
);
|
|
const openedPanel = await page.evaluate(`(() => {
|
|
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
|
|
chip.click();
|
|
const panel = document.querySelector(".chat-tool-panel");
|
|
return {
|
|
hidden: panel?.hidden ?? true,
|
|
head: panel?.querySelector(".chat-tool-panel-count")?.textContent ?? "",
|
|
close: panel?.querySelector(".chat-tool-close")?.getAttribute("aria-label") ?? "",
|
|
chevron: chip.querySelector(".chat-tool-chevron")?.getAttribute("aria-label") ?? "",
|
|
rows: panel?.querySelectorAll(".chat-tool-row").length ?? 0,
|
|
};
|
|
})()`);
|
|
if (openedPanel.hidden) throw new Error("C6: the tool panel did not open");
|
|
if (openedPanel.head !== toolLabel) throw new Error(`C6: panel header ${openedPanel.head}`);
|
|
if (openedPanel.close !== "Close tool calls") {
|
|
throw new Error(`C6: panel close control ${openedPanel.close}`);
|
|
}
|
|
if (openedPanel.chevron !== "Hide tool calls") {
|
|
throw new Error(`C6: open chip chevron ${openedPanel.chevron}`);
|
|
}
|
|
if (openedPanel.rows !== toolCount) {
|
|
throw new Error(`C6: the panel lists ${openedPanel.rows} rows, the chip counts ${toolCount}`);
|
|
}
|
|
const scrollAfterOpen = await page.evaluate(
|
|
`Math.round(document.querySelector("#chatTranscript").scrollTop)`,
|
|
);
|
|
if (Math.abs(scrollAfterOpen - scrollBeforePanel) > 2) {
|
|
throw new Error(`C6: opening the tool panel moved the transcript (${scrollBeforePanel} -> ${scrollAfterOpen})`);
|
|
}
|
|
console.log(
|
|
` tool panel open: header "${openedPanel.head}", close "Close tool calls", ${openedPanel.rows} row(s)`,
|
|
);
|
|
|
|
// Expand the first row in place and assert its chevron name, its INPUT and its
|
|
// OUTPUT (the live first call is a settled `read` carrying both).
|
|
const firstToolRow = await page.evaluate(`(() => {
|
|
const panel = document.querySelector(".chat-tool-panel");
|
|
const list = panel.querySelector(".chat-tool-list");
|
|
list.scrollTop = 0;
|
|
const first = () => panel.querySelector(".chat-tool-row-head");
|
|
const name = first().querySelector(".chat-tool-name")?.textContent ?? "";
|
|
const chevronBefore = first().querySelector(".chat-tool-row-chevron")?.getAttribute("aria-label") ?? "";
|
|
first().click();
|
|
const head = first();
|
|
const row = head.closest(".chat-tool-row");
|
|
return {
|
|
name,
|
|
chevronBefore,
|
|
chevronAfter: head.querySelector(".chat-tool-row-chevron")?.getAttribute("aria-label") ?? "",
|
|
sections: [...row.querySelectorAll(".chat-tool-section-label")].map((n) => n.textContent),
|
|
bodies: [...row.querySelectorAll(".chat-tool-section-body")].map((n) => n.textContent),
|
|
};
|
|
})()`);
|
|
if (firstToolRow.chevronBefore !== `Expand ${firstToolRow.name}`) {
|
|
throw new Error(`C6: collapsed row chevron ${firstToolRow.chevronBefore} for ${firstToolRow.name}`);
|
|
}
|
|
if (firstToolRow.chevronAfter !== `Collapse ${firstToolRow.name}`) {
|
|
throw new Error(`C6: expanded row chevron ${firstToolRow.chevronAfter} for ${firstToolRow.name}`);
|
|
}
|
|
if (!firstToolRow.sections.includes("INPUT") || !firstToolRow.sections.includes("OUTPUT")) {
|
|
throw new Error(`C6: first row sections ${JSON.stringify(firstToolRow.sections)}`);
|
|
}
|
|
if (firstToolRow.bodies.some((body) => body.trim() === "")) {
|
|
throw new Error(`C6: a first-row section rendered blank: ${JSON.stringify(firstToolRow.bodies)}`);
|
|
}
|
|
console.log(
|
|
` first row "${firstToolRow.name}": ${firstToolRow.sections.join(" + ")} (chevron "${firstToolRow.chevronAfter}")`,
|
|
);
|
|
await shot("54-chat-tool-panel.png");
|
|
|
|
// Closing it must put the transcript back exactly where it was.
|
|
const closedPanel = await page.evaluate(`(() => {
|
|
document.querySelector(".chat-tool-close").click();
|
|
const panel = document.querySelector(".chat-tool-panel");
|
|
const chip = document.querySelector("#chatTranscript .chat-tool-chip");
|
|
return {
|
|
hidden: panel.hidden,
|
|
chevron: chip.querySelector(".chat-tool-chevron").getAttribute("aria-label"),
|
|
top: Math.round(document.querySelector("#chatTranscript").scrollTop),
|
|
};
|
|
})()`);
|
|
if (!closedPanel.hidden || closedPanel.chevron !== "Show tool calls") {
|
|
throw new Error(`C6: closing the tool panel: ${JSON.stringify(closedPanel)}`);
|
|
}
|
|
if (Math.abs(closedPanel.top - scrollBeforePanel) > 2) {
|
|
throw new Error(`C6: opening/closing the tool panel moved the transcript (${scrollBeforePanel} -> ${closedPanel.top})`);
|
|
}
|
|
console.log(
|
|
` the tool panel left the transcript where it was across open/close (top ${scrollBeforePanel} -> ${closedPanel.top})`,
|
|
);
|
|
|
|
// The live history carries no failed call and no edit-family call, so render
|
|
// both through the page's own row builder (the 47b precedent): a failed row
|
|
// marked "Failed tool call" with an ERROR section, and an edit row with the LCS
|
|
// diff and its true "+N -M" stat. The sample is removed straight after.
|
|
const sampleRows = await page.evaluate(`(async () => {
|
|
const app = await import("/src/app.js");
|
|
const host = document.createElement("div");
|
|
host.id = "chatToolSample";
|
|
host.className = "chat-tool-sample";
|
|
const note = document.createElement("div");
|
|
note.className = "chat-tool-sample-note";
|
|
note.textContent =
|
|
"Page-rendered sample — the live history carries no failed or edit call " +
|
|
"(the chip, panel and rows above are live)";
|
|
host.append(note);
|
|
const failedPart = {
|
|
type: "tool", id: "sample-failed", name: "shell",
|
|
state: { status: "error", input: { command: "false" }, error: { message: "exit status 1" } },
|
|
};
|
|
const failedRow = app.renderToolCallRow(failedPart, { expanded: true });
|
|
host.append(failedRow);
|
|
const editPart = {
|
|
type: "tool", id: "sample-edit", name: "edit",
|
|
state: {
|
|
status: "completed",
|
|
input: { filePath: "web/src/chat.js", oldString: "const a = 1;\\nconst b = 2;", newString: "const a = 1;\\nconst b = 3;\\nconst c = 4;" },
|
|
content: [{ type: "text", text: "applied" }],
|
|
},
|
|
time: { created: 1, ran: 2, completed: 103 },
|
|
};
|
|
const editRow = app.renderToolCallRow(editPart, { expanded: true });
|
|
host.append(editRow);
|
|
document.body.append(host);
|
|
return {
|
|
failedAria: failedRow.querySelector('.chat-tool-icon[aria-label="Failed tool call"]') ? "Failed tool call" : "",
|
|
failedSections: [...failedRow.querySelectorAll(".chat-tool-section-label")].map((n) => n.textContent),
|
|
editStat: editRow.querySelector(".chat-tool-stat")?.textContent ?? "",
|
|
diffLines: [...editRow.querySelectorAll(".chat-tool-diff-line")].map((n) => ({ cls: n.className, text: n.textContent })),
|
|
};
|
|
})()`);
|
|
if (!sampleRows) throw new Error("C6: could not render the page-rendered tool-row samples");
|
|
if (sampleRows.failedAria !== "Failed tool call") {
|
|
throw new Error(`C6: the failed row is not marked 'Failed tool call': ${JSON.stringify(sampleRows)}`);
|
|
}
|
|
if (!sampleRows.failedSections.includes("INPUT") || !sampleRows.failedSections.includes("ERROR")) {
|
|
throw new Error(`C6: failed row sections ${JSON.stringify(sampleRows.failedSections)}`);
|
|
}
|
|
if (sampleRows.editStat !== "+2 -1") {
|
|
throw new Error(`C6: edit diff stat ${sampleRows.editStat}`);
|
|
}
|
|
if (
|
|
!sampleRows.diffLines.some((line) => line.cls.includes("diff-remove") && line.text === "- const b = 2;") ||
|
|
!sampleRows.diffLines.some((line) => line.cls.includes("diff-add") && line.text === "+ const b = 3;")
|
|
) {
|
|
throw new Error(`C6: the edit diff lines: ${JSON.stringify(sampleRows.diffLines)}`);
|
|
}
|
|
console.log(
|
|
` page-rendered samples: failed row "Failed tool call" (${sampleRows.failedSections.join(" + ")}), ` +
|
|
`edit row stat ${sampleRows.editStat} with ${sampleRows.diffLines.length} diff line(s)`,
|
|
);
|
|
await shot("55-chat-edit-diff-sample.png");
|
|
await page.evaluate(`document.querySelector("#chatToolSample")?.remove()`);
|
|
|
|
if (transcript.hasLoadOlder) {
|
|
// The control was present in capture 45. Press it and capture the honest
|
|
// result: the live session's own cursor returns an empty older page, so the
|
|
// control disappears (the prepend path itself is unit-tested).
|
|
await page.evaluate(`document.querySelector(".chat-load-older")?.click()`);
|
|
await eventually(() => page.evaluate(`!document.querySelector(".chat-load-older")`), {
|
|
timeout: 15000,
|
|
what: "the empty older history page to settle",
|
|
});
|
|
await shot("48-chat-load-older-empty.png");
|
|
console.log(
|
|
" 'Load older messages' was shown while has_more (capture 45); the server's own next_cursor returned an empty older page and the control disappeared",
|
|
);
|
|
} else {
|
|
console.log(" -- no 'Load older messages' control: the server did not report has_more");
|
|
}
|
|
|
|
// The close confirm: shown, then dismissed with Cancel. The operator's only
|
|
// live session is never mutated, so no chat_close is sent. The transcript is
|
|
// mid-scroll (following false), so this also asserts the C14 fix: opening and
|
|
// dismissing the dialog must not move the operator's view.
|
|
const beforeDialog = await page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatTranscript");
|
|
return {
|
|
top: el ? Math.round(el.scrollTop) : null,
|
|
jumpHidden: document.querySelector("#chatJump")?.hidden ?? null,
|
|
};
|
|
})()`);
|
|
if (!beforeDialog || beforeDialog.top == null || beforeDialog.top === 0) {
|
|
throw new Error(`the transcript was not mid-scroll before the dialog: ${JSON.stringify(beforeDialog)}`);
|
|
}
|
|
await page.click(`#chatRows .chat-row[data-session="${openedId}"] .chat-close`);
|
|
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
|
const closeDialog = await page.evaluate(`(() => ({
|
|
title: document.querySelector(".confirm-chat-close .confirm-title")?.textContent ?? "",
|
|
message: document.querySelector(".confirm-chat-close .confirm-message")?.textContent ?? "",
|
|
confirm: document.querySelector(".confirm-chat-close .confirm-accept")?.textContent ?? "",
|
|
dismiss: document.querySelector(".confirm-chat-close .confirm-dismiss")?.textContent ?? "",
|
|
}))()`);
|
|
if (closeDialog.title !== "Close chat?") throw new Error(`close title: ${closeDialog.title}`);
|
|
if (!closeDialog.message.startsWith("Closes \"")) throw new Error(`close message: ${closeDialog.message}`);
|
|
if (!closeDialog.message.includes("marks it closed on every device")) {
|
|
throw new Error(`close message: ${closeDialog.message}`);
|
|
}
|
|
if (!closeDialog.message.includes("Nothing is deleted")) {
|
|
throw new Error(`close message: ${closeDialog.message}`);
|
|
}
|
|
if (closeDialog.confirm !== "Close chat") throw new Error(`close confirm: ${closeDialog.confirm}`);
|
|
if (closeDialog.dismiss !== "Cancel") throw new Error(`close dismiss: ${closeDialog.dismiss}`);
|
|
const whileDialog = await page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatTranscript");
|
|
return {
|
|
top: el ? Math.round(el.scrollTop) : null,
|
|
jumpHidden: document.querySelector("#chatJump")?.hidden ?? null,
|
|
};
|
|
})()`);
|
|
if (Math.abs((whileDialog.top ?? -1) - beforeDialog.top) > 2 || whileDialog.jumpHidden !== false) {
|
|
throw new Error(
|
|
`opening the close dialog moved the transcript: ${JSON.stringify(beforeDialog)} -> ${JSON.stringify(whileDialog)}`,
|
|
);
|
|
}
|
|
console.log(` close dialog (shown, NOT executed): "${closeDialog.title}" — ${closeDialog.message}`);
|
|
console.log(` the transcript stayed put across the dialog (top ${beforeDialog.top} -> ${whileDialog.top})`);
|
|
await shot("49-chat-close-confirm.png");
|
|
await page.click(".confirm-chat-close .confirm-dismiss");
|
|
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
|
timeout: 5000,
|
|
what: "the close dialog to close",
|
|
});
|
|
const afterDialog = await page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatTranscript");
|
|
return el ? Math.round(el.scrollTop) : null;
|
|
})()`);
|
|
if (afterDialog == null || Math.abs(afterDialog - beforeDialog.top) > 2) {
|
|
throw new Error(`dismissing the close dialog moved the transcript: ${beforeDialog.top} -> ${afterDialog}`);
|
|
}
|
|
console.log(
|
|
" the mutating confirm was NOT executed: no chat_close was sent for the operator's live session " +
|
|
`${openedId}`,
|
|
);
|
|
|
|
// C8/C9: the composer — its draft, the slash-command palette, an unknown-command
|
|
// notice, the attachment chips and the Stop control while a turn is running. No
|
|
// prompt is ever sent to the operator's live session: the running-turn capture
|
|
// uses a freshly created throwaway session (via `/new`), which is closed again
|
|
// in cleanup. Every other state is reached by driving the composer without
|
|
// submitting.
|
|
step("C8/C9: the composer, slash commands and attachments");
|
|
await ensureConnected();
|
|
await page.waitForSelector("#chatInput", { timeout: 15000 });
|
|
|
|
// (a) A draft: the placeholder, Send present and enabled, Stop absent.
|
|
await page.fill("#chatInput", "A draft from the smoke");
|
|
const draftState = await page.evaluate(`(() => ({
|
|
placeholder: document.querySelector("#chatInput")?.getAttribute("placeholder") ?? "",
|
|
send: !!document.querySelector("#chatSend"),
|
|
sendDisabled: document.querySelector("#chatSend")?.disabled ?? null,
|
|
sendLabel: document.querySelector("#chatSend")?.getAttribute("aria-label") ?? "",
|
|
stop: !!document.querySelector("#chatStop"),
|
|
}))()`);
|
|
if (draftState.placeholder !== "Message the agent… or / for commands") {
|
|
throw new Error(`composer placeholder: ${draftState.placeholder}`);
|
|
}
|
|
if (!draftState.send || draftState.sendDisabled !== false || draftState.sendLabel !== "Send") {
|
|
throw new Error(`composer Send control: ${JSON.stringify(draftState)}`);
|
|
}
|
|
if (draftState.stop) throw new Error("the composer shows Stop while no turn is running");
|
|
console.log(` composer draft: placeholder "${draftState.placeholder}", Send enabled, no Stop`);
|
|
await showComposer();
|
|
await shot("56-chat-composer-draft.png");
|
|
|
|
// (b) The command palette for a bare "/": all five commands, the first selected.
|
|
await page.fill("#chatInput", "/");
|
|
await page.waitForSelector(".chat-command-palette .chat-command-row", { timeout: 10000 });
|
|
const palette = await page.evaluate(`(() => ({
|
|
hidden: document.querySelector(".chat-command-palette")?.hidden ?? null,
|
|
rows: [...document.querySelectorAll(".chat-command-palette .chat-command-row")].map((row) => ({
|
|
name: row.querySelector(".chat-command-name")?.textContent ?? "",
|
|
summary: row.querySelector(".chat-command-summary")?.textContent ?? "",
|
|
selected: row.getAttribute("aria-selected"),
|
|
})),
|
|
}))()`);
|
|
const expectedCommands = [
|
|
["/new", "Start a fresh session in this directory"],
|
|
["/close", "Finish this session for every client, keeping its history"],
|
|
["/rename", "Rename this session on this device"],
|
|
["/stop", "Stop the turn that is running"],
|
|
["/help", "List every command"],
|
|
];
|
|
if (palette.hidden || palette.rows.length !== expectedCommands.length) {
|
|
throw new Error(`command palette: ${JSON.stringify(palette)}`);
|
|
}
|
|
palette.rows.forEach((row, index) => {
|
|
if (row.name !== expectedCommands[index][0] || row.summary !== expectedCommands[index][1]) {
|
|
throw new Error(`palette row ${index}: ${JSON.stringify(row)}`);
|
|
}
|
|
if (row.selected !== (index === 0 ? "true" : "false")) {
|
|
throw new Error(`palette row ${index} selected: ${row.selected}`);
|
|
}
|
|
});
|
|
console.log(` command palette: ${palette.rows.map((row) => row.name).join(" ")}`);
|
|
await showComposer();
|
|
await shot("57-chat-command-palette.png");
|
|
|
|
// Up/Down move the highlight; Enter runs the highlighted row.
|
|
const highlight = await page.evaluate(`(() => {
|
|
const input = document.querySelector("#chatInput");
|
|
const key = (name) => input.dispatchEvent(new KeyboardEvent("keydown", { key: name, bubbles: true, cancelable: true }));
|
|
key("ArrowDown");
|
|
key("ArrowDown");
|
|
return [...document.querySelectorAll(".chat-command-palette .chat-command-row")].map((row) => row.getAttribute("aria-selected"));
|
|
})()`);
|
|
if (highlight[2] !== "true" || highlight[0] !== "false") {
|
|
throw new Error(`ArrowDown did not move the highlight: ${JSON.stringify(highlight)}`);
|
|
}
|
|
console.log(" ArrowDown moved the highlighted command row (Enter runs it)");
|
|
await showComposer();
|
|
await shot("58-chat-command-palette-selected.png");
|
|
|
|
// Type a prefix that narrows the list case-insensitively.
|
|
await page.fill("#chatInput", "/ST");
|
|
const narrowedCommands = await page.evaluate(
|
|
`[...document.querySelectorAll(".chat-command-palette .chat-command-row .chat-command-name")].map((n) => n.textContent)`,
|
|
);
|
|
if (narrowedCommands.length !== 1 || narrowedCommands[0] !== "/stop") {
|
|
throw new Error(`prefix filter: ${JSON.stringify(narrowedCommands)}`);
|
|
}
|
|
|
|
// (c) An unknown command: its notice with the exact wording and the offer, then
|
|
// Cancel. The composer is driven without submitting, so no prompt is sent.
|
|
await page.fill("#chatInput", "/nope");
|
|
await page.evaluate(
|
|
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
|
);
|
|
await page.waitForSelector(".chat-command-notice-failed", { timeout: 10000 });
|
|
const notice = await page.evaluate(`(() => {
|
|
const node = document.querySelector(".chat-command-notice-failed");
|
|
node.scrollIntoView({ block: "center" });
|
|
return {
|
|
label: node.querySelector(".chat-command-notice-label")?.textContent ?? "",
|
|
glyph: node.querySelector(".chat-command-notice-glyph")?.textContent ?? "",
|
|
text: node.querySelector(".chat-command-notice-text")?.textContent ?? "",
|
|
buttons: [...node.querySelectorAll(".chat-command-notice-actions button")].map((b) => b.textContent),
|
|
draft: document.querySelector("#chatInput")?.value ?? null,
|
|
send: !!document.querySelector("#chatSend"),
|
|
stop: !!document.querySelector("#chatStop"),
|
|
};
|
|
})()`);
|
|
if (notice.label !== "Command failed") throw new Error(`notice label: ${notice.label}`);
|
|
if (
|
|
notice.text !==
|
|
"“/nope” is not a command, so nothing was sent to the agent. Send it as a message, or cancel."
|
|
) {
|
|
throw new Error(`unknown-command notice text: ${notice.text}`);
|
|
}
|
|
if (notice.buttons.join("|") !== "Send as message|Cancel") {
|
|
throw new Error(`unknown-command offer buttons: ${JSON.stringify(notice.buttons)}`);
|
|
}
|
|
if (notice.draft !== "") throw new Error(`the command did not consume the draft: ${JSON.stringify(notice.draft)}`);
|
|
console.log(` unknown command: "${notice.text}" (offer: ${notice.buttons.join(" / ")})`);
|
|
await shot("59-chat-command-unknown.png");
|
|
await page.clickText(".chat-command-notice-failed button", "Cancel");
|
|
await eventually(() => page.evaluate(`!document.querySelector(".chat-command-notice-failed")`), {
|
|
timeout: 5000,
|
|
what: "the unknown-command notice to be dismissed",
|
|
});
|
|
|
|
// (d) Attachment chips: a small file with its size, and a file over the 25 MiB
|
|
// limit with its error. Driving the real file input (a DataTransfer) exercises
|
|
// the page's own resolve path; nothing is sent. An unreadable-file error cannot
|
|
// be produced through a browser file picker, so that branch is unit-tested only
|
|
// and stated in PARITY.md.
|
|
await page.fill("#chatInput", "see the attachment");
|
|
const attached = await page.evaluate(`(() => {
|
|
const input = document.querySelector("#chatFileInput");
|
|
if (!input) return false;
|
|
const transfer = new DataTransfer();
|
|
transfer.items.add(new File(["hello"], "notes.txt", { type: "text/plain" }));
|
|
transfer.items.add(new File([new Uint8Array(${26 * 1024 * 1024})], "huge.bin", { type: "application/octet-stream" }));
|
|
input.files = transfer.files;
|
|
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
return true;
|
|
})()`);
|
|
if (!attached) throw new Error("the composer has no file input");
|
|
await page.waitForSelector(".chat-attachment-chip", { timeout: 10000 });
|
|
const chips = await page.evaluate(`(() => {
|
|
document.querySelector("#chatComposer")?.scrollIntoView({ block: "end" });
|
|
return {
|
|
chips: [...document.querySelectorAll(".chat-attachment-chip")].map((chip) => ({
|
|
name: chip.querySelector(".chat-attachment-name")?.textContent ?? "",
|
|
meta: chip.querySelector(".chat-attachment-meta")?.textContent ?? "",
|
|
error: chip.querySelector(".chat-attachment-error")?.textContent ?? "",
|
|
failed: chip.classList.contains("chat-attachment-chip-failed"),
|
|
remove: chip.querySelector(".chat-attachment-remove")?.getAttribute("aria-label") ?? "",
|
|
})),
|
|
sendDisabled: document.querySelector("#chatSend")?.disabled ?? null,
|
|
};
|
|
})()`);
|
|
if (chips.chips.length !== 2) throw new Error(`attachment chips: ${JSON.stringify(chips)}`);
|
|
if (chips.chips[0].name !== "notes.txt" || chips.chips[0].meta !== "5 B" || chips.chips[0].failed) {
|
|
throw new Error(`small attachment chip: ${JSON.stringify(chips.chips[0])}`);
|
|
}
|
|
if (chips.chips[0].remove !== "Remove notes.txt") {
|
|
throw new Error(`attachment remove label: ${chips.chips[0].remove}`);
|
|
}
|
|
if (
|
|
!chips.chips[1].failed ||
|
|
chips.chips[1].error !== '"huge.bin" is too large (25.0 MiB limit).'
|
|
) {
|
|
throw new Error(`oversized attachment chip: ${JSON.stringify(chips.chips[1])}`);
|
|
}
|
|
if (chips.sendDisabled !== true) {
|
|
throw new Error("a failed attachment must block sending");
|
|
}
|
|
console.log(
|
|
` attachment chips: "${chips.chips[0].name}" (${chips.chips[0].meta}) + a failed ` +
|
|
`"${chips.chips[1].name}" (${chips.chips[1].error}); Send disabled`,
|
|
);
|
|
await showComposer();
|
|
await shot("60-chat-attachment-chips.png");
|
|
|
|
// Removing the failed chip unblocks Send (the draft is non-blank).
|
|
await page.evaluate(
|
|
`document.querySelectorAll(".chat-attachment-chip")[1]?.querySelector(".chat-attachment-remove")?.click()`,
|
|
);
|
|
await eventually(
|
|
() => page.evaluate(`document.querySelectorAll(".chat-attachment-chip").length === 1`),
|
|
{ timeout: 5000, what: "the failed attachment to be removed" },
|
|
);
|
|
const afterRemove = await page.evaluate(`(() => ({
|
|
sendDisabled: document.querySelector("#chatSend")?.disabled ?? null,
|
|
chips: document.querySelectorAll(".chat-attachment-chip").length,
|
|
}))()`);
|
|
if (afterRemove.sendDisabled !== false) {
|
|
throw new Error(`Send should be enabled after removing the failed chip: ${JSON.stringify(afterRemove)}`);
|
|
}
|
|
console.log(" removing the failed attachment re-enabled Send");
|
|
await showComposer();
|
|
await shot("61-chat-attachment-removed.png");
|
|
await page.evaluate(
|
|
`document.querySelector(".chat-attachment-remove")?.click()`,
|
|
);
|
|
await eventually(() => page.evaluate(`document.querySelectorAll(".chat-attachment-chip").length === 0`), {
|
|
timeout: 5000,
|
|
what: "the last attachment to be removed",
|
|
});
|
|
await page.fill("#chatInput", "");
|
|
|
|
// (e) `/new` creates a fresh throwaway session (C2's chat_create, sent directly
|
|
// until C2 lands) and opens it. The operator's session is left untouched.
|
|
await page.fill("#chatInput", "/new");
|
|
await page.evaluate(
|
|
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
|
);
|
|
const throwawayId = await eventually(
|
|
async () => {
|
|
const id = await page.evaluate(`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`);
|
|
return id && id !== openedId ? id : false;
|
|
},
|
|
{ timeout: 25000, what: "the new throwaway session to open" },
|
|
);
|
|
await page.waitForSelector("#chatInput", { timeout: 10000 });
|
|
const throwawayTitle = await page.evaluate(`document.querySelector(".chat-bar-title")?.textContent ?? ""`);
|
|
if (throwawayTitle !== "New chat") throw new Error(`new session title: ${throwawayTitle}`);
|
|
throwawaySessionId = throwawayId;
|
|
const startedNotice = await page.evaluate(
|
|
`document.querySelector(".chat-command-notice .chat-command-notice-text")?.textContent ?? ""`,
|
|
);
|
|
if (!startedNotice.startsWith("Started a new session “")) {
|
|
throw new Error(`/new notice: ${startedNotice}`);
|
|
}
|
|
console.log(` /new opened throwaway session ${throwawayId} ("${throwawayTitle}") — ${startedNotice}`);
|
|
await showComposer();
|
|
await shot("62-chat-new-session.png");
|
|
|
|
// A real prompt to the throwaway session turns the Send control into Stop.
|
|
await page.fill("#chatInput", "Reply with exactly one word: hi");
|
|
await page.evaluate(
|
|
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
|
);
|
|
await page.waitForSelector("#chatStop", { timeout: 20000 });
|
|
const running = await page.evaluate(`(() => ({
|
|
stopLabel: document.querySelector("#chatStop")?.getAttribute("aria-label") ?? "",
|
|
stopTitle: document.querySelector("#chatStop")?.getAttribute("title") ?? "",
|
|
send: !!document.querySelector("#chatSend"),
|
|
draft: document.querySelector("#chatInput")?.value ?? null,
|
|
}))()`);
|
|
if (running.stopLabel !== "Stop" || running.stopTitle !== "Stop" || running.send) {
|
|
throw new Error(`the Stop control: ${JSON.stringify(running)}`);
|
|
}
|
|
if (running.draft !== "") throw new Error(`the sent draft was not cleared: ${JSON.stringify(running.draft)}`);
|
|
console.log(" a real prompt to the throwaway session turned Send into the Stop control");
|
|
await showComposer();
|
|
await shot("63-chat-composer-stop.png");
|
|
|
|
// The Stop control must really interrupt (chat_interrupt), not fall through the
|
|
// inert submit path: click it and observe the page's own interrupting notice,
|
|
// with no Action failed dialog. The throwaway turn is the only one stopped.
|
|
await page.click("#chatStop");
|
|
const stopNotice = await eventually(
|
|
async () => {
|
|
const notices = await page.evaluate(
|
|
`[...document.querySelectorAll(".chat-command-notice:not(.chat-command-notice-failed) .chat-command-notice-text")].map((node) => node.textContent)`,
|
|
);
|
|
return notices.includes("Stopping the running turn…") ? "Stopping the running turn…" : false;
|
|
},
|
|
{ timeout: 15000, what: "the interrupt notice after clicking Stop" },
|
|
);
|
|
const stopFailed = await page.evaluate(
|
|
`document.querySelector(".action-failed .action-failed-message")?.textContent ?? ""`,
|
|
);
|
|
if (stopFailed !== "") throw new Error(`clicking Stop failed: ${stopFailed}`);
|
|
console.log(` clicking Stop sent chat_interrupt: "${stopNotice}"`);
|
|
await showComposer();
|
|
await shot("63b-chat-stop-interrupt.png");
|
|
|
|
// Cleanup: `/close` the throwaway through the C3 confirm. It is the only session
|
|
// this stage mutates and it is closed again (any in-flight turn is stopped).
|
|
await page.fill("#chatInput", "/close");
|
|
await page.evaluate(
|
|
`document.querySelector("#chatInput").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }))`,
|
|
);
|
|
await page.waitForSelector(".confirm-chat-close", { timeout: 15000 });
|
|
const throwawayClose = await page.evaluate(
|
|
`document.querySelector(".confirm-chat-close .confirm-message")?.textContent ?? ""`,
|
|
);
|
|
if (!throwawayClose.startsWith("Closes ")) {
|
|
throw new Error(`throwaway close message: ${throwawayClose}`);
|
|
}
|
|
await page.click(".confirm-chat-close .confirm-accept");
|
|
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
|
timeout: 15000,
|
|
what: "the throwaway close dialog to close",
|
|
});
|
|
await eventually(
|
|
() =>
|
|
page.evaluate(
|
|
`!!document.querySelector('.chat-row[data-session="${throwawayId}"] .chat-closed-chip')`,
|
|
),
|
|
{ timeout: 15000, what: "the throwaway session to show as closed" },
|
|
);
|
|
const closedRow = await page.evaluate(`(() => {
|
|
const row = document.querySelector('.chat-row[data-session="${throwawayId}"]');
|
|
row?.scrollIntoView({ block: "center" });
|
|
return {
|
|
closed: !!row?.querySelector(".chat-closed-chip"),
|
|
hasClose: !!row?.querySelector(".chat-close"),
|
|
hasReopen: !!row?.querySelector(".chat-reopen"),
|
|
};
|
|
})()`);
|
|
// Closing finishes the session: the conversation leaves the pane (back to the
|
|
// list with the select hint) and no row stays selected, as Android's
|
|
// finishSession does.
|
|
const afterThrowawayClose = await page.evaluate(`(() => ({
|
|
selected: !!document.querySelector(".chat-row.selected"),
|
|
hint: document.querySelector(".chat-detail .empty .muted")?.textContent ?? "",
|
|
composer: !!document.querySelector("#chatComposer"),
|
|
}))()`);
|
|
if (
|
|
afterThrowawayClose.selected ||
|
|
afterThrowawayClose.composer ||
|
|
afterThrowawayClose.hint !== "Select a chat to open it."
|
|
) {
|
|
throw new Error(`/close did not leave the conversation: ${JSON.stringify(afterThrowawayClose)}`);
|
|
}
|
|
console.log(` /close closed the throwaway session ${throwawayId} (${JSON.stringify(closedRow)}) and left the pane`);
|
|
await shot("64-chat-throwaway-closed.png");
|
|
throwawaySessionId = null;
|
|
|
|
// C5: the shared live stream. A real live turn needs a prompt the operator's
|
|
// server may not be running, so the real page is subscribed to the real
|
|
// session and then exact `chat_event` frames are replayed through the socket's
|
|
// own `onmessage` (see the shim installed before the page's scripts). The
|
|
// subscribe ack and every history reply are real server traffic; only the
|
|
// frames replayed below are synthetic, and this log says so explicitly.
|
|
step("C5: the live stream — subscribe, replayed chat_event frames, stream state");
|
|
await ensureConnected();
|
|
await page.evaluate(`document.querySelector("#chatJump")?.click()`);
|
|
|
|
const chatBadge = () =>
|
|
page.evaluate(
|
|
`document.querySelector(".chat-context .live-badge .live-word")?.textContent ?? ""`,
|
|
);
|
|
const chatLive = await chatBadge();
|
|
if (chatLive !== "live") {
|
|
throw new Error(`chat stream badge should read "live" while subscribed, got ${JSON.stringify(chatLive)}`);
|
|
}
|
|
console.log(` chat stream badge while subscribed: "${chatLive}" (real chat_subscribe ack + real history)`);
|
|
|
|
const sessionId = openedId;
|
|
const replayFrames = (frames) =>
|
|
page.evaluate(`(() => {
|
|
const ws = window.__pipelinesSocket;
|
|
if (!ws || typeof ws.onmessage !== "function") return false;
|
|
for (const frame of ${JSON.stringify(frames)}) {
|
|
ws.onmessage({ data: JSON.stringify({ type: "chat_event", chat_event: frame }) });
|
|
}
|
|
return true;
|
|
})()`);
|
|
const agentCount = () => page.evaluate(`document.querySelectorAll("#chatTranscript .chat-turn-agent").length`);
|
|
const indicator = () =>
|
|
page.evaluate(`(() => {
|
|
const el = document.querySelector("#chatRunning");
|
|
if (!el) return null;
|
|
return {
|
|
spinner: !!el.querySelector(".spinner"),
|
|
label: el.querySelector(".chat-running-label")?.textContent ?? "",
|
|
elapsed: el.querySelector(".chat-running-elapsed")?.textContent ?? "",
|
|
tools: [...el.querySelectorAll(".chat-running-tool")].map((line) => ({
|
|
text: line.querySelector(".chat-running-tool-text")?.textContent ?? "",
|
|
long: line.querySelector(".chat-tool-long")?.textContent ?? "",
|
|
longTinted: line.classList.contains("chat-running-tool-long"),
|
|
})),
|
|
};
|
|
})()`);
|
|
|
|
const applyFrames = async (frames, label) => {
|
|
const ok = await replayFrames(frames);
|
|
if (!ok) throw new Error(`C5: the socket shim did not expose the live socket to replay ${label}`);
|
|
await eventually(() => page.evaluate(`!!document.querySelector("#chatTranscript")`), {
|
|
what: "the transcript to render",
|
|
});
|
|
};
|
|
|
|
const agentBefore = await agentCount();
|
|
const sessionFrame = (extra) => ({ session_id: sessionId, ...extra });
|
|
|
|
// 1. Reasoning and text deltas on one assistant message id: the answer grows
|
|
// inside the existing agent bubble.
|
|
await applyFrames(
|
|
[
|
|
sessionFrame({ message_id: "cap-live-1", kind: "reasoning", part: { id: "cap-live-1#reasoning#0" }, delta: "Planning the live capture." }),
|
|
sessionFrame({ message_id: "cap-live-1", kind: "text", part: { id: "cap-live-1#text#0" }, delta: "The live turn is " }),
|
|
sessionFrame({ message_id: "cap-live-1", kind: "text", part: { id: "cap-live-1#text#0" }, delta: "growing." }),
|
|
],
|
|
"the reasoning/text deltas",
|
|
);
|
|
const liveTurn = await page.evaluate(`(() => {
|
|
const transcript = document.querySelector("#chatTranscript");
|
|
const bubbles = [...transcript.querySelectorAll(".chat-turn-agent")];
|
|
return {
|
|
agents: bubbles.length,
|
|
answers: bubbles.filter((b) => b.textContent.includes("The live turn is growing.")).length,
|
|
reasoning: bubbles.some((b) => b.textContent.includes("Planning the live capture.")),
|
|
};
|
|
})()`);
|
|
console.log(
|
|
` replayed 3 frames (reasoning + 2 text deltas) → ${liveTurn.answers} agent bubble carries ` +
|
|
`"The live turn is growing." + reasoning (transcript agent bubbles ${agentBefore} -> ${liveTurn.agents})`,
|
|
);
|
|
if (liveTurn.answers !== 1 || !liveTurn.reasoning || liveTurn.agents !== agentBefore) {
|
|
throw new Error(`C5: the replayed deltas did not grow one agent bubble: ${JSON.stringify(liveTurn)}`);
|
|
}
|
|
await shot("56-chat-live-turn.png");
|
|
|
|
// 2. A running tool: the indicator's headline is `Running a tool…` with a
|
|
// running-tool line and a live `· {elapsed}`.
|
|
await applyFrames(
|
|
[sessionFrame({ message_id: "cap-live-1", kind: "tool", part: { type: "tool", id: "cap-tool-1", name: "shell", state: { status: "running", input: { command: "npm run build" } } } })],
|
|
"the running tool",
|
|
);
|
|
await new Promise((resolve) => setTimeout(resolve, 1300));
|
|
const runningIndicator = await indicator();
|
|
if (
|
|
!runningIndicator ||
|
|
!runningIndicator.spinner ||
|
|
runningIndicator.label !== "Running a tool…" ||
|
|
!/^· \d/.test(runningIndicator.elapsed) ||
|
|
runningIndicator.tools.length < 1
|
|
) {
|
|
throw new Error(`C5: the running indicator is wrong: ${JSON.stringify(runningIndicator)}`);
|
|
}
|
|
console.log(
|
|
` running indicator: spinner=${runningIndicator.spinner}, "${runningIndicator.label}", "${runningIndicator.elapsed}", ` +
|
|
`${runningIndicator.tools.length} running-tool line(s) — "${runningIndicator.tools[0].text}"`,
|
|
);
|
|
await shot("57-chat-running.png");
|
|
|
|
// 3. A second running tool that started 61 s ago (protocol `time.ran`): the
|
|
// `· long` mark, tinted with the error hue. Two assistant message ids are in
|
|
// play now and the turn is still one bubble.
|
|
await applyFrames(
|
|
[
|
|
sessionFrame({
|
|
message_id: "cap-live-2",
|
|
kind: "reasoning",
|
|
part: { id: "cap-live-2#reasoning#0" },
|
|
delta: "Streaming the second step.",
|
|
}),
|
|
sessionFrame({
|
|
message_id: "cap-live-2",
|
|
kind: "tool",
|
|
part: { type: "tool", id: "cap-tool-2", name: "shell", state: { status: "running", input: { command: "npm run long" } }, time: { ran: Date.now() - 61000 } },
|
|
}),
|
|
],
|
|
"the long-running tool",
|
|
);
|
|
const longCall = await indicator();
|
|
const longLine = longCall?.tools.find((line) => line.long !== "");
|
|
if (!longLine || !longLine.longTinted || !longLine.long.includes("long")) {
|
|
throw new Error(`C5: no tinted long-running tool line: ${JSON.stringify(longCall)}`);
|
|
}
|
|
const agentsWithTwoIds = await agentCount();
|
|
console.log(` long-call line: "${longLine.text}${longLine.long}" tinted=${longLine.longTinted}`);
|
|
if (agentsWithTwoIds !== agentBefore) {
|
|
throw new Error(`C5: two assistant message ids fragmented the live turn into ${agentsWithTwoIds} bubbles`);
|
|
}
|
|
await shot("58-chat-long-call.png");
|
|
|
|
// 4. Finish the tools and end the step: the indicator disappears and the same
|
|
// single agent bubble stands, settled.
|
|
await applyFrames(
|
|
[
|
|
sessionFrame({ message_id: "cap-live-1", kind: "tool", part: { type: "tool", id: "cap-tool-1", state: { status: "completed", content: [{ type: "text", text: "build ok" }] } } }),
|
|
sessionFrame({ message_id: "cap-live-2", kind: "tool", part: { type: "tool", id: "cap-tool-2", state: { status: "completed", content: [{ type: "text", text: "long ok" }] } } }),
|
|
sessionFrame({ message_id: "cap-live-2", kind: "step", step: { status: "ended" } }),
|
|
],
|
|
"the completed tools and the ended step",
|
|
);
|
|
const settled = await page.evaluate(`(() => {
|
|
const transcript = document.querySelector("#chatTranscript");
|
|
return {
|
|
indicator: !!document.querySelector("#chatRunning"),
|
|
agents: transcript.querySelectorAll(".chat-turn-agent").length,
|
|
answers: [...transcript.querySelectorAll(".chat-turn-agent")].filter((b) => b.textContent.includes("The live turn is growing.")).length,
|
|
};
|
|
})()`);
|
|
if (settled.indicator) throw new Error("C5: the running indicator survived the ended step");
|
|
if (settled.agents !== agentBefore || settled.answers !== 1) {
|
|
throw new Error(`C5: the settled turn is not the same single agent bubble: ${JSON.stringify(settled)}`);
|
|
}
|
|
console.log(
|
|
` after the tools completed and the step ended: no indicator, still ${settled.agents} agent bubble ` +
|
|
`carrying the live answer (unchanged from ${agentBefore})`,
|
|
);
|
|
await shot("59-chat-settled.png");
|
|
|
|
// The stream-state words. Dropping the socket unexpectedly reads `reconnecting`
|
|
// while the client comes back; the reconnect re-subscribes the open chat and
|
|
// refreshes its history wholesale, so the replayed turn above is gone — which is
|
|
// exactly the promised wholesale replacement.
|
|
await page.evaluate(`window.__pipelinesSocket && window.__pipelinesSocket.close(4000, "smoke drop")`);
|
|
await eventually(
|
|
() => page.evaluate(`document.querySelector(".chat-context .live-badge .live-word")?.textContent === "reconnecting"`),
|
|
{ timeout: 10000, what: "the chat badge to read reconnecting" },
|
|
);
|
|
console.log(` chat stream badge after an unexpected drop: "${await chatBadge()}"`);
|
|
await ensureConnected(30000);
|
|
await eventually(
|
|
() => page.evaluate(`document.querySelector(".chat-context .live-badge .live-word")?.textContent === "live"`),
|
|
{ timeout: 30000, what: "the chat badge to return to live after reconnect" },
|
|
);
|
|
// The badge turns live as soon as the subscription is re-attached; the history
|
|
// refresh that replaces the conversation follows it, so wait for the replayed
|
|
// marker to actually disappear rather than racing the fetch.
|
|
await eventually(
|
|
() =>
|
|
page.evaluate(
|
|
`!document.querySelector("#chatTranscript")?.textContent?.includes("The live turn is growing.")`,
|
|
),
|
|
{ timeout: 20000, what: "the reconnect to replace the conversation with fresh history" },
|
|
);
|
|
console.log(
|
|
' after reconnect: chat badge "live" again and history replaced the replayed turn wholesale (marker gone)',
|
|
);
|
|
|
|
// The third word: disconnecting entirely reads `not live`.
|
|
await page.click("#connectBtn");
|
|
await eventually(
|
|
() => page.evaluate(`document.querySelector(".chat-context .live-badge .live-word")?.textContent === "not live"`),
|
|
{ timeout: 15000, what: "the chat badge to read not live while idle" },
|
|
);
|
|
console.log(` chat stream badge after Disconnect: "${await chatBadge()}"`);
|
|
|
|
console.log(
|
|
" NOTE: the chat_subscribe ack and every chat_history reply above came from the real server; only the chat_event frames were replayed",
|
|
);
|
|
|
|
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 {
|
|
// Best-effort cleanup of the throwaway session this run created: if the run
|
|
// failed before its `/close` step, close it now so it is never left open.
|
|
if (throwawaySessionId && page) {
|
|
try {
|
|
await page.evaluate(`(async () => {
|
|
const input = document.querySelector("#chatInput");
|
|
if (!input) return;
|
|
input.value = "/close";
|
|
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true, cancelable: true }));
|
|
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
document.querySelector(".confirm-chat-close .confirm-accept")?.click();
|
|
})()`);
|
|
await eventually(() => page.evaluate(`!document.querySelector(".confirm-chat-close")`), {
|
|
timeout: 8000,
|
|
what: "the cleanup close to finish",
|
|
}).catch(() => {});
|
|
console.log(` cleanup: closed the throwaway session ${throwawaySessionId}`);
|
|
} catch {
|
|
// the page may already be gone; the failure above is the real signal
|
|
}
|
|
}
|
|
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);
|