Merge branch 'main' into web-decide-live
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
// Compare two ui-smoke capture directories.
|
||||
//
|
||||
// node test/capture-manifest.mjs DIR # manifest: name, bytes, sha256
|
||||
// node test/capture-manifest.mjs --compare BEFORE AFTER
|
||||
//
|
||||
// A refactor that must not change behaviour has to produce the SAME capture set:
|
||||
// every screen the check drove before must still be captured after. Pixel bytes
|
||||
// legitimately drift on a live server (durations, "x minutes ago", run counts), so
|
||||
// the gate is the SET, with the differing files listed for a human to inspect:
|
||||
//
|
||||
// exit 0 same capture set (drift printed for review)
|
||||
// exit 1 a capture is missing or unexpected (a screen stopped being driven)
|
||||
//
|
||||
// Zero dependencies, no server needed.
|
||||
import { createHash } from "node:crypto";
|
||||
import { readdir, readFile, stat } from "node:fs/promises";
|
||||
import { basename, resolve } from "node:path";
|
||||
|
||||
async function manifest(directory) {
|
||||
const dir = resolve(directory);
|
||||
const entries = await readdir(dir).catch(() => {
|
||||
throw new Error(`no such capture directory: ${dir}`);
|
||||
});
|
||||
const files = entries.filter((name) => name.toLowerCase().endsWith(".png")).sort();
|
||||
const rows = [];
|
||||
for (const name of files) {
|
||||
const path = `${dir}/${name}`;
|
||||
const info = await stat(path);
|
||||
const bytes = await readFile(path);
|
||||
rows.push({
|
||||
name,
|
||||
bytes: info.size,
|
||||
sha: createHash("sha256").update(bytes).digest("hex").slice(0, 16),
|
||||
});
|
||||
}
|
||||
return { dir, rows };
|
||||
}
|
||||
|
||||
function printManifest({ dir, rows }) {
|
||||
console.log(`# ${dir} — ${rows.length} capture(s)`);
|
||||
for (const row of rows) console.log(`${row.name}\t${row.bytes}\t${row.sha}`);
|
||||
}
|
||||
|
||||
async function compare(beforeDir, afterDir) {
|
||||
const before = await manifest(beforeDir);
|
||||
const after = await manifest(afterDir);
|
||||
const beforeNames = new Set(before.rows.map((row) => row.name));
|
||||
const afterNames = new Set(after.rows.map((row) => row.name));
|
||||
const missing = [...beforeNames].filter((name) => !afterNames.has(name)).sort();
|
||||
const extra = [...afterNames].filter((name) => !beforeNames.has(name)).sort();
|
||||
const beforeByName = new Map(before.rows.map((row) => [row.name, row]));
|
||||
const drift = [];
|
||||
for (const row of after.rows) {
|
||||
const prior = beforeByName.get(row.name);
|
||||
if (!prior || prior.sha === row.sha) continue;
|
||||
drift.push({ name: row.name, before: prior.bytes, after: row.bytes, delta: row.bytes - prior.bytes });
|
||||
}
|
||||
console.log(`before: ${before.dir} — ${before.rows.length} capture(s)`);
|
||||
console.log(`after: ${after.dir} — ${after.rows.length} capture(s)`);
|
||||
console.log(`same set: ${missing.length === 0 && extra.length === 0 ? "yes" : "NO"}`);
|
||||
if (missing.length) console.log(`missing after: ${missing.join(", ")}`);
|
||||
if (extra.length) console.log(`unexpected after: ${extra.join(", ")}`);
|
||||
console.log(
|
||||
`pixel drift: ${drift.length} capture(s)` +
|
||||
(drift.length ? " — inspect these for real visual changes:" : ""),
|
||||
);
|
||||
for (const row of drift) console.log(` ${row.name} ${row.before} -> ${row.after} bytes (${row.delta >= 0 ? "+" : ""}${row.delta})`);
|
||||
if (missing.length || extra.length) process.exitCode = 1;
|
||||
}
|
||||
|
||||
import { pathToFileURL } from "node:url";
|
||||
const runAsScript =
|
||||
process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href;
|
||||
const [first, second, third] = process.argv.slice(2);
|
||||
if (!runAsScript) {
|
||||
// Imported as a module (for example from a test): no CLI side effects.
|
||||
} else if (first === "--compare") {
|
||||
if (!second || !third) {
|
||||
console.error("usage: node test/capture-manifest.mjs --compare BEFORE_DIR AFTER_DIR");
|
||||
process.exit(2);
|
||||
}
|
||||
compare(second, third).catch((error) => {
|
||||
console.error(error.message);
|
||||
process.exit(2);
|
||||
});
|
||||
} else if (first) {
|
||||
manifest(first).then(printManifest).catch((error) => {
|
||||
console.error(error.message);
|
||||
process.exit(2);
|
||||
});
|
||||
} else {
|
||||
console.error("usage: node test/capture-manifest.mjs DIR | --compare BEFORE AFTER");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
export { compare, manifest };
|
||||
@@ -0,0 +1,288 @@
|
||||
// Unit tests for the pure URL route model (web/src/routes.js). No DOM and no
|
||||
// server: every case here is a claim the live UI smoke relies on.
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
DEFAULT_ROUTE,
|
||||
parseRoute,
|
||||
sameRoute,
|
||||
serializeRoute,
|
||||
} from "../src/routes.js";
|
||||
|
||||
const defaultRoute = () => ({ ...DEFAULT_ROUTE });
|
||||
|
||||
test("default destination: empty, root, unknown and malformed paths", () => {
|
||||
for (const path of [
|
||||
undefined,
|
||||
null,
|
||||
"",
|
||||
"/",
|
||||
"///",
|
||||
"/nope",
|
||||
"/pipelinesx",
|
||||
"/runs/abc",
|
||||
"/runs/0",
|
||||
"/runs/-1",
|
||||
"/runs/1x",
|
||||
"/pipelines/x",
|
||||
"/pipelines/24/-1",
|
||||
"/pipelines/24/1x",
|
||||
"/pipelines/24/5/nope",
|
||||
"/pipelines/24/5/stage",
|
||||
"/runs/440/stage",
|
||||
// A trailing segment on a versionless stage branch is malformed, not a
|
||||
// dropped visit or an ignored extra: both stage branches require exactly
|
||||
// four segments (the versioned pipeline branch already rejected extras).
|
||||
"/runs/440/stage/planner/extra",
|
||||
"/runs/440/stage/planner/2",
|
||||
"/pipelines/24/stage/planner/extra",
|
||||
"/pipelines/24/stage/planner/2",
|
||||
"/runs/%E0%A4%A",
|
||||
"/pipelines/%E0%A4%A",
|
||||
"/templates/%E0%A4%A",
|
||||
"/runs/440/stage/%E0%A4%A",
|
||||
]) {
|
||||
assert.deepEqual(parseRoute(path), defaultRoute(), `path ${JSON.stringify(path)}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("top-level destinations", () => {
|
||||
assert.deepEqual(parseRoute("/pipelines"), { kind: "pipelines" });
|
||||
assert.deepEqual(parseRoute("/runs"), { kind: "runs" });
|
||||
assert.deepEqual(parseRoute("/chat"), { kind: "chat" });
|
||||
assert.deepEqual(parseRoute("/settings"), { kind: "settings" });
|
||||
assert.deepEqual(parseRoute("/templates"), { kind: "templates" });
|
||||
});
|
||||
|
||||
test("trailing slashes are normalised and location-style strings accepted", () => {
|
||||
assert.deepEqual(parseRoute("/runs/"), { kind: "runs" });
|
||||
assert.deepEqual(parseRoute("/runs/440/"), { kind: "run", id: 440 });
|
||||
assert.deepEqual(parseRoute("http://127.0.0.1:8090/runs/440?visit=2"), {
|
||||
kind: "run",
|
||||
id: 440,
|
||||
});
|
||||
assert.deepEqual(parseRoute("http://127.0.0.1:8090/runs/440"), { kind: "run", id: 440 });
|
||||
assert.deepEqual(parseRoute("/runs/440?action=decide"), { kind: "run", id: 440, action: "decide" });
|
||||
});
|
||||
|
||||
test("pipeline detail: absent and zero versions are the same latest route", () => {
|
||||
const latest = { kind: "pipeline", id: 24, version: 0 };
|
||||
assert.deepEqual(parseRoute("/pipelines/24"), latest);
|
||||
assert.deepEqual(parseRoute("/pipelines/24/0"), latest);
|
||||
assert.deepEqual(parseRoute("/pipelines/24/5"), { kind: "pipeline", id: 24, version: 5 });
|
||||
assert.equal(serializeRoute(parseRoute("/pipelines/24")), "/pipelines/24");
|
||||
assert.equal(serializeRoute(parseRoute("/pipelines/24/0")), "/pipelines/24");
|
||||
assert.equal(serializeRoute(parseRoute("/pipelines/24/5")), "/pipelines/24/5");
|
||||
});
|
||||
|
||||
test("run detail and the optional decide action", () => {
|
||||
assert.deepEqual(parseRoute("/runs/440"), { kind: "run", id: 440 });
|
||||
assert.deepEqual(parseRoute("/runs/440?action=decide"), { kind: "run", id: 440, action: "decide" });
|
||||
assert.equal(serializeRoute({ kind: "run", id: 440 }), "/runs/440");
|
||||
assert.equal(serializeRoute({ kind: "run", id: 440, action: "decide" }), "/runs/440?action=decide");
|
||||
});
|
||||
|
||||
test("run stage: optional zero-based visit, invalid visit dropped", () => {
|
||||
assert.deepEqual(parseRoute("/runs/440/stage/planner"), {
|
||||
kind: "runStage",
|
||||
id: 440,
|
||||
stageKey: "planner",
|
||||
});
|
||||
assert.deepEqual(parseRoute("/runs/440/stage/planner", "?visit=2"), {
|
||||
kind: "runStage",
|
||||
id: 440,
|
||||
stageKey: "planner",
|
||||
visit: 2,
|
||||
});
|
||||
assert.deepEqual(parseRoute("/runs/440/stage/planner?visit=0"), {
|
||||
kind: "runStage",
|
||||
id: 440,
|
||||
stageKey: "planner",
|
||||
visit: 0,
|
||||
});
|
||||
// An invalid visit is dropped while the stage route is kept.
|
||||
for (const query of ["?visit=-1", "?visit=x", "?visit=", "?visit=1.5"]) {
|
||||
assert.deepEqual(parseRoute("/runs/440/stage/planner", query), {
|
||||
kind: "runStage",
|
||||
id: 440,
|
||||
stageKey: "planner",
|
||||
});
|
||||
}
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "runStage", id: 440, stageKey: "planner" }),
|
||||
"/runs/440/stage/planner",
|
||||
);
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "runStage", id: 440, stageKey: "planner", visit: 0 }),
|
||||
"/runs/440/stage/planner?visit=0",
|
||||
);
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "runStage", id: 440, stageKey: "planner", visit: -1 }),
|
||||
"/runs/440/stage/planner",
|
||||
);
|
||||
});
|
||||
|
||||
test("pipeline stage routes, with and without an explicit version", () => {
|
||||
assert.deepEqual(parseRoute("/pipelines/24/5/stage/planner"), {
|
||||
kind: "pipelineStage",
|
||||
id: 24,
|
||||
version: 5,
|
||||
stageKey: "planner",
|
||||
});
|
||||
assert.deepEqual(parseRoute("/pipelines/24/stage/planner"), {
|
||||
kind: "pipelineStage",
|
||||
id: 24,
|
||||
version: 0,
|
||||
stageKey: "planner",
|
||||
});
|
||||
assert.deepEqual(parseRoute("/pipelines/24/0/stage/planner"), {
|
||||
kind: "pipelineStage",
|
||||
id: 24,
|
||||
version: 0,
|
||||
stageKey: "planner",
|
||||
});
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "pipelineStage", id: 24, version: 5, stageKey: "planner" }),
|
||||
"/pipelines/24/5/stage/planner",
|
||||
);
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "pipelineStage", id: 24, version: 0, stageKey: "planner" }),
|
||||
"/pipelines/24/stage/planner",
|
||||
);
|
||||
});
|
||||
|
||||
test("templates gallery and detail, including the /settings aliases", () => {
|
||||
assert.deepEqual(parseRoute("/templates"), { kind: "templates" });
|
||||
assert.deepEqual(parseRoute("/settings/templates"), { kind: "templates" });
|
||||
assert.deepEqual(parseRoute("/templates/plan"), { kind: "template", key: "plan" });
|
||||
assert.deepEqual(parseRoute("/settings/templates/plan"), { kind: "template", key: "plan" });
|
||||
assert.equal(serializeRoute({ kind: "template", key: "plan" }), "/templates/plan");
|
||||
assert.equal(
|
||||
serializeRoute(parseRoute("/settings/templates/plan")),
|
||||
"/templates/plan",
|
||||
);
|
||||
});
|
||||
|
||||
test("unknown query state is ignored; only action and visit are read", () => {
|
||||
assert.deepEqual(parseRoute("/runs/440", "?q=plan&kind=runs&sort=name"), {
|
||||
kind: "run",
|
||||
id: 440,
|
||||
});
|
||||
assert.deepEqual(parseRoute("/runs", "?q=plan&kind=pipelines&sort=newest"), { kind: "runs" });
|
||||
assert.deepEqual(parseRoute("/runs/440?visit=2"), { kind: "run", id: 440 });
|
||||
assert.deepEqual(parseRoute("/runs/440/stage/planner?visit=2&q=x"), {
|
||||
kind: "runStage",
|
||||
id: 440,
|
||||
stageKey: "planner",
|
||||
visit: 2,
|
||||
});
|
||||
});
|
||||
|
||||
test("stage and template keys are percent-encoded and round-trip", () => {
|
||||
const stageKey = "plan/land & go";
|
||||
const templateKey = "a b/c?d#e";
|
||||
// A dotted key stays one path segment; serve.mjs must not mistake it for an
|
||||
// asset when the shell is requested for a hard navigation.
|
||||
assert.deepEqual(parseRoute(serializeRoute({ kind: "pipelineStage", id: 7, version: 2, stageKey: "plan.v2" })), {
|
||||
kind: "pipelineStage",
|
||||
id: 7,
|
||||
version: 2,
|
||||
stageKey: "plan.v2",
|
||||
});
|
||||
const stage = parseRoute(serializeRoute({ kind: "runStage", id: 7, stageKey, visit: 3 }));
|
||||
assert.deepEqual(stage, { kind: "runStage", id: 7, stageKey, visit: 3 });
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "pipelineStage", id: 7, version: 2, stageKey }),
|
||||
"/pipelines/7/2/stage/plan%2Fland%20%26%20go",
|
||||
);
|
||||
assert.deepEqual(parseRoute(serializeRoute({ kind: "template", key: templateKey })), {
|
||||
kind: "template",
|
||||
key: templateKey,
|
||||
});
|
||||
assert.equal(serializeRoute({ kind: "template", key: templateKey }), "/templates/a%20b%2Fc%3Fd%23e");
|
||||
});
|
||||
|
||||
test("serialisation is idempotent and parse(serialize(route)) preserves every route", () => {
|
||||
const routes = [
|
||||
{ kind: "pipelines" },
|
||||
{ kind: "runs" },
|
||||
{ kind: "chat" },
|
||||
{ kind: "settings" },
|
||||
{ kind: "templates" },
|
||||
{ kind: "template", key: "plan" },
|
||||
{ kind: "pipeline", id: 24, version: 0 },
|
||||
{ kind: "pipeline", id: 24, version: 5 },
|
||||
{ kind: "pipelineStage", id: 24, version: 0, stageKey: "planner" },
|
||||
{ kind: "pipelineStage", id: 24, version: 5, stageKey: "plan/land" },
|
||||
{ kind: "run", id: 440 },
|
||||
{ kind: "run", id: 440, action: "decide" },
|
||||
{ kind: "runStage", id: 440, stageKey: "planner" },
|
||||
{ kind: "runStage", id: 440, stageKey: "plan/land", visit: 0 },
|
||||
];
|
||||
for (const route of routes) {
|
||||
const url = serializeRoute(route);
|
||||
const parsed = parseRoute(url);
|
||||
assert.equal(serializeRoute(parsed), url, `route ${JSON.stringify(route)}`);
|
||||
assert.ok(sameRoute(parsed, route), `sameRoute ${JSON.stringify(route)}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("sameRoute compares the canonical serialised form", () => {
|
||||
assert.ok(sameRoute({ kind: "pipeline", id: 24 }, { kind: "pipeline", id: 24, version: 0 }));
|
||||
assert.ok(
|
||||
sameRoute(
|
||||
parseRoute("/settings/templates/plan"),
|
||||
{ kind: "template", key: "plan" },
|
||||
),
|
||||
);
|
||||
assert.ok(!sameRoute({ kind: "run", id: 440 }, { kind: "run", id: 440, action: "decide" }));
|
||||
assert.ok(!sameRoute({ kind: "runs" }, { kind: "pipelines" }));
|
||||
});
|
||||
|
||||
test("a bad route object serialises to the default, never throws", () => {
|
||||
assert.equal(serializeRoute(null), "/pipelines");
|
||||
assert.equal(serializeRoute({}), "/pipelines");
|
||||
assert.equal(serializeRoute({ kind: "unknown" }), "/pipelines");
|
||||
assert.equal(serializeRoute({ kind: "pipeline" }), "/pipelines");
|
||||
assert.equal(serializeRoute({ kind: "runStage", id: 1 }), "/runs");
|
||||
});
|
||||
|
||||
test("the serialiser rejects ids/versions the parser would not accept", () => {
|
||||
// An invalid id cannot name an entity; the nearest canonical route is the list.
|
||||
for (const id of [0, -1, 1.5, NaN, Infinity, "abc", "", null]) {
|
||||
assert.equal(serializeRoute({ kind: "pipeline", id }), "/pipelines", `pipeline id ${String(id)}`);
|
||||
assert.equal(serializeRoute({ kind: "run", id }), "/runs", `run id ${String(id)}`);
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "runStage", id, stageKey: "planner" }),
|
||||
"/runs",
|
||||
`runStage id ${String(id)}`,
|
||||
);
|
||||
}
|
||||
// An invalid or negative version falls back to the latest form, which parses
|
||||
// back to the same route instead of emitting a path the parser rejects.
|
||||
for (const version of [-1, 1.5, NaN, "abc", ""]) {
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "pipeline", id: 24, version }),
|
||||
"/pipelines/24",
|
||||
`pipeline version ${String(version)}`,
|
||||
);
|
||||
assert.equal(
|
||||
serializeRoute({ kind: "pipelineStage", id: 24, version, stageKey: "planner" }),
|
||||
"/pipelines/24/stage/planner",
|
||||
`pipelineStage version ${String(version)}`,
|
||||
);
|
||||
assert.deepEqual(parseRoute(serializeRoute({ kind: "pipelineStage", id: 24, version, stageKey: "planner" })), {
|
||||
kind: "pipelineStage",
|
||||
id: 24,
|
||||
version: 0,
|
||||
stageKey: "planner",
|
||||
});
|
||||
}
|
||||
// A blank or non-string key cannot describe a stage/template.
|
||||
assert.equal(serializeRoute({ kind: "pipelineStage", id: 24, stageKey: "" }), "/pipelines");
|
||||
assert.equal(serializeRoute({ kind: "runStage", id: 440, stageKey: "" }), "/runs");
|
||||
assert.equal(serializeRoute({ kind: "template", key: "" }), "/templates");
|
||||
// A canonical numeric string is emitted as the number the parser reads back.
|
||||
assert.equal(serializeRoute({ kind: "run", id: "440" }), "/runs/440");
|
||||
assert.equal(serializeRoute({ kind: "pipeline", id: "24", version: "5" }), "/pipelines/24/5");
|
||||
});
|
||||
+548
-40
@@ -160,13 +160,38 @@ const showChatNotice = () =>
|
||||
// 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 });
|
||||
const deadline = Date.now() + timeout;
|
||||
while (Date.now() < deadline) {
|
||||
const ok = await page.evaluate(
|
||||
`document.querySelector(".conn-banner")?.classList.contains("conn-ok") ?? false`,
|
||||
);
|
||||
if (ok) return;
|
||||
// The page's own recovery path: an `online` event resets the client's
|
||||
// backoff and re-opens the configured endpoint. A dropped long-lived socket
|
||||
// can take a few tries on the shared server, so nudge until the deadline.
|
||||
await page.evaluate(`window.dispatchEvent(new Event("online"))`);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
// One last honest wait, so the failure names the banner selector.
|
||||
await page.waitForSelector(".conn-banner.conn-ok", { timeout: 2000 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Hard-navigate to a page route and connect, exactly as a pasted link would: a
|
||||
* full document load parses the URL at boot and keeps it pending until the socket
|
||||
* comes up. The configured endpoint is already in localStorage from the live
|
||||
* run's first connection, so clicking Connect is the same user action.
|
||||
*/
|
||||
async function openDeepLink(path) {
|
||||
await page.goto(`http://127.0.0.1:${port}${path}`);
|
||||
await page.waitForSelector("#connectBtn", { timeout: 15000 });
|
||||
await page.click("#connectBtn");
|
||||
await ensureConnected(30000);
|
||||
}
|
||||
|
||||
/** The current path+query the page shows. */
|
||||
const currentLocation = () => page.evaluate(`location.pathname + location.search`);
|
||||
|
||||
// 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.
|
||||
@@ -632,11 +657,20 @@ async function runDecisionChecks() {
|
||||
// Open one chat row's Chat actions menu (the row's management items live behind
|
||||
// it since C13: Rename… / Close chat… or Reopen / Hide on this device).
|
||||
async function openChatRowMenu(sessionId) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
|
||||
await page.waitForSelector(
|
||||
`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel`,
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
// The row can be re-rendered by a just-finished create/refresh right under the
|
||||
// click, which closes the menu again; retry once before failing.
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
await page.click(`#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-button`);
|
||||
const opened = await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector('#chatRows .chat-row[data-session="${sessionId}"] .chat-menu-panel')`,
|
||||
),
|
||||
{ timeout: attempt === 0 ? 3000 : 10000, what: "the Chat actions menu" },
|
||||
).catch(() => false);
|
||||
if (opened) return;
|
||||
}
|
||||
throw new Error(`the Chat actions menu did not open for ${sessionId}`);
|
||||
}
|
||||
|
||||
// --- P5: create a pipeline from a template (scratch server only) -----------
|
||||
@@ -2101,19 +2135,29 @@ try {
|
||||
what: "the run 440 pane to close",
|
||||
});
|
||||
|
||||
// The Timeline empty state, on a run that recorded no visits (R7).
|
||||
// The Timeline empty state, on a run that recorded no visits (R7). The exact
|
||||
// empty wording is unit-tested; this is the live capture, so it is taken only
|
||||
// when the server still holds a run with no visits (run 428 once was one, but
|
||||
// the live history grows and its steps can gain visits), and otherwise reported
|
||||
// as skipped rather than failing the whole check on drifting live data.
|
||||
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}`);
|
||||
let emptyTimeline = "";
|
||||
try {
|
||||
await openRunDetail(428);
|
||||
await page.clickText(".detail .detail-tabs .detail-tab", "Timeline");
|
||||
await page.waitForSelector(".detail .run-tab-body .run-empty", { timeout: 15000 });
|
||||
emptyTimeline = await page.evaluate(
|
||||
`document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`,
|
||||
);
|
||||
} catch {
|
||||
emptyTimeline = "";
|
||||
}
|
||||
if (emptyTimeline === "No visits recorded.") {
|
||||
console.log(` timeline empty state: ${emptyTimeline}`);
|
||||
shots.push(await page.screenshot(`${out}/26-run-428-timeline-empty.png`));
|
||||
} else {
|
||||
console.log(" -- no run with an empty Timeline on this server; empty-state wording is unit-tested");
|
||||
}
|
||||
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
|
||||
@@ -3459,20 +3503,30 @@ try {
|
||||
{ timeout: 30000, what: "the C2-created session to be selected" },
|
||||
);
|
||||
createdSessionId = createdId;
|
||||
const created = await page.evaluate(`(() => {
|
||||
const rows = [...document.querySelectorAll("#chatRows .chat-row")];
|
||||
const row = document.querySelector('.chat-row[data-session="${createdId}"]');
|
||||
return {
|
||||
first: rows[0]?.dataset.session ?? "",
|
||||
title: row?.querySelector(".chat-row-title")?.textContent ?? "",
|
||||
selected: row?.classList.contains("selected") ?? false,
|
||||
closed: !!row?.querySelector(".chat-closed-chip"),
|
||||
header: document.querySelector(".chat-bar-title")?.textContent ?? "",
|
||||
empty: document.querySelector(".chat-detail .chat-transcript-empty")?.textContent ?? "",
|
||||
composer: !!document.querySelector("#chatComposer"),
|
||||
pickerGone: !document.querySelector(".chat-create"),
|
||||
};
|
||||
})()`);
|
||||
// The created conversation loads its history asynchronously; sample it only once
|
||||
// it has settled (a loaded OpenCode endpoint can take a few seconds).
|
||||
const created = await eventually(
|
||||
() =>
|
||||
page
|
||||
.evaluate(`(() => {
|
||||
const rows = [...document.querySelectorAll("#chatRows .chat-row")];
|
||||
const row = document.querySelector('.chat-row[data-session="${createdId}"]');
|
||||
return {
|
||||
first: rows[0]?.dataset.session ?? "",
|
||||
title: row?.querySelector(".chat-row-title")?.textContent ?? "",
|
||||
selected: row?.classList.contains("selected") ?? false,
|
||||
closed: !!row?.querySelector(".chat-closed-chip"),
|
||||
header: document.querySelector(".chat-bar-title")?.textContent ?? "",
|
||||
empty: document.querySelector(".chat-detail .chat-transcript-empty")?.textContent ?? "",
|
||||
composer: !!document.querySelector("#chatComposer"),
|
||||
pickerGone: !document.querySelector(".chat-create"),
|
||||
};
|
||||
})()`)
|
||||
.then((value) =>
|
||||
value.empty === "This chat has no messages yet. Ask something below." ? value : false,
|
||||
),
|
||||
{ timeout: 30000, what: "the created chat's empty conversation to load" },
|
||||
);
|
||||
const createBodies = await page.evaluate(`window.__chatCreateBodies || []`);
|
||||
if (createBodies.length !== 1) {
|
||||
throw new Error(`C2 sent ${createBodies.length} chat_create request(s) for one create`);
|
||||
@@ -3525,15 +3579,23 @@ try {
|
||||
const createdClosed = await page.evaluate(`(() => {
|
||||
const row = document.querySelector('.chat-row[data-session="${createdId}"]');
|
||||
row?.scrollIntoView({ block: "center" });
|
||||
return { closed: !!row?.querySelector(".chat-closed-chip") };
|
||||
})()`);
|
||||
if (!createdClosed.closed) throw new Error(`C2 closed chip missing: ${JSON.stringify(createdClosed)}`);
|
||||
// C13 moved the row actions behind the Chat actions menu, so the closed row's
|
||||
// Reopen (and the absence of Close) is asserted with that menu open.
|
||||
await openChatRowMenu(createdId);
|
||||
const closedMenu = await page.evaluate(`(() => {
|
||||
const row = document.querySelector('.chat-row[data-session="${createdId}"]');
|
||||
return {
|
||||
closed: !!row?.querySelector(".chat-closed-chip"),
|
||||
hasClose: !!row?.querySelector(".chat-menu-close"),
|
||||
hasReopen: !!row?.querySelector(".chat-menu-reopen"),
|
||||
};
|
||||
})()`);
|
||||
if (!createdClosed.closed || createdClosed.hasClose || !createdClosed.hasReopen) {
|
||||
throw new Error(`C2 closed row: ${JSON.stringify(createdClosed)}`);
|
||||
if (closedMenu.hasClose || !closedMenu.hasReopen) {
|
||||
throw new Error(`C2 closed row menu: ${JSON.stringify(closedMenu)}`);
|
||||
}
|
||||
await page.click(`#chatRows .chat-row[data-session="${createdId}"] .chat-menu-button`);
|
||||
// Close the actions menu so the capture shows the row itself, not the panel.
|
||||
await page.click(`#chatRows .chat-row[data-session="${createdId}"] .chat-menu-button`);
|
||||
console.log(
|
||||
@@ -4520,6 +4582,9 @@ try {
|
||||
if (!startedNotice.startsWith("Started a new session “")) {
|
||||
throw new Error(`/new notice: ${startedNotice}`);
|
||||
}
|
||||
// Only the throwaway is a verification chat: clear the marker so C2's own
|
||||
// create (which must appear in the list as its acceptance) is a normal chat.
|
||||
await page.evaluate(`window.__pipelinesEphemeralChat = false`);
|
||||
console.log(` /new opened throwaway session ${throwawayId} ("${throwawayTitle}") — ${startedNotice}`);
|
||||
await showComposer();
|
||||
await shot("62-chat-new-session.png");
|
||||
@@ -5507,6 +5572,15 @@ try {
|
||||
// F2: the header URL field and the Settings field are one draft, mirrored in
|
||||
// place, so they cannot show different endpoints while typing.
|
||||
const goodUrl = await page.evaluate(`document.querySelector("#settingsServerUrl")?.value ?? ""`);
|
||||
// An earlier section can leave a page banner behind; the assertion below is
|
||||
// about where THIS refusal is surfaced, so clear any stale one with the page's
|
||||
// own path (re-selecting the active destination) before triggering it.
|
||||
await page.evaluate(`(() => {
|
||||
if (!document.querySelector("#content .banner.error")) return true;
|
||||
const tab = [...document.querySelectorAll("nav.tabs button.tab")].find((b) => b.classList.contains("active"));
|
||||
if (tab) tab.click();
|
||||
return !document.querySelector("#content .banner.error");
|
||||
})()`);
|
||||
await page.fill("#settingsServerUrl", "not a url");
|
||||
await page.click("#settingsSecondary");
|
||||
const urlErrorState = await eventually(
|
||||
@@ -6129,6 +6203,421 @@ try {
|
||||
);
|
||||
console.log(" chat_shells re-fetched after the stream reconnect (real request)");
|
||||
|
||||
// --- L6: URL routes, deep links and history -------------------------------
|
||||
// Every later hard navigation records uncaught errors/unhandled rejections, so
|
||||
// a route that throws can never pass as a rendered fallback.
|
||||
await page.addInitScript(`(() => {
|
||||
window.__pipelinesPageErrors = [];
|
||||
window.addEventListener("error", (event) => {
|
||||
window.__pipelinesPageErrors.push(String(event.message || event.error || "error"));
|
||||
});
|
||||
window.addEventListener("unhandledrejection", (event) => {
|
||||
window.__pipelinesPageErrors.push(String(event.reason || "unhandled rejection"));
|
||||
});
|
||||
})()`);
|
||||
|
||||
step("L6: deep links, URL routing and Back/Forward");
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
|
||||
const discovered = await page.evaluate(`(() => {
|
||||
const rows = [...document.querySelectorAll(".list.runs .run-row")];
|
||||
const idOf = (row) =>
|
||||
Number(row.querySelector(".run-row-meta[data-run-id]")?.dataset.runId ?? 0);
|
||||
const ids = rows.map(idOf).filter((id) => id > 0);
|
||||
const waitingRow = rows.find((row) => row.querySelector(".chip-waiting"));
|
||||
return {
|
||||
ids,
|
||||
preferred: ids.includes(440) ? 440 : (ids[0] ?? 0),
|
||||
waiting: waitingRow ? idOf(waitingRow) : 0,
|
||||
};
|
||||
})()`);
|
||||
if (!discovered.preferred) throw new Error("L6: no real run id on the Runs list");
|
||||
console.log(
|
||||
` live run ids on the list: ${discovered.ids.join(", ")} (using ${discovered.preferred})`,
|
||||
);
|
||||
|
||||
// An in-page pipeline selection is a real pushState: the detail route records
|
||||
// the id and version, and the hard link below uses the id it found.
|
||||
await page.clickText("nav.tabs button.tab", "Pipelines");
|
||||
await page.waitForSelector("#pipelineRows button.row", { timeout: 25000 });
|
||||
const pipelineSelection = await page.evaluate(`(async () => {
|
||||
const rows = [...document.querySelectorAll("#pipelineRows button.row")];
|
||||
const row =
|
||||
rows.find((candidate) =>
|
||||
(candidate.querySelector(".row-title")?.textContent ?? "").includes("Plan and land"),
|
||||
) ?? rows[0];
|
||||
if (!row) return null;
|
||||
row.click();
|
||||
const deadline = Date.now() + 20000;
|
||||
while (Date.now() < deadline) {
|
||||
if (document.querySelector(".detail h2")) break;
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}
|
||||
return {
|
||||
path: location.search ? location.pathname + location.search : location.pathname,
|
||||
name: document.querySelector(".detail h2")?.textContent ?? "",
|
||||
};
|
||||
})()`);
|
||||
if (!pipelineSelection?.path) throw new Error("L6: the pipeline detail did not open");
|
||||
const pipelineId = Number((/^\/pipelines\/([0-9]+)/.exec(pipelineSelection.path) ?? [])[1] ?? 0);
|
||||
if (!pipelineId) throw new Error(`L6: pipeline detail route ${JSON.stringify(pipelineSelection.path)}`);
|
||||
console.log(
|
||||
` in-page pipeline selection pushed ${pipelineSelection.path} (${JSON.stringify(pipelineSelection.name)})`,
|
||||
);
|
||||
|
||||
// A hard navigation to a run route: boot parses the URL, the first connection
|
||||
// loads the runs list and then the run, and the detail owns the requested id.
|
||||
const runPath = `/runs/${discovered.preferred}`;
|
||||
await openDeepLink(runPath);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${discovered.preferred} ") ?? false`,
|
||||
),
|
||||
{ timeout: 30000, what: `the deep-linked run ${discovered.preferred}` },
|
||||
);
|
||||
const deepRunUrl = await currentLocation();
|
||||
if (deepRunUrl !== runPath) throw new Error(`L6: run URL is ${deepRunUrl}, expected ${runPath}`);
|
||||
// The nav badge reads the pipeline count; a run deep link must not leave a
|
||||
// false `Pipelines (0)` beside a populated list.
|
||||
const runNav = await page.evaluate(
|
||||
`[...document.querySelectorAll("nav.tabs button.tab")].map((b) => b.textContent.trim())`,
|
||||
);
|
||||
const pipelinesTab = runNav.find((label) => label.startsWith("Pipelines")) ?? "";
|
||||
if (pipelinesTab === "Pipelines (0)") {
|
||||
throw new Error(`L6: the run deep link left a false Pipelines (0) in the nav: ${JSON.stringify(runNav)}`);
|
||||
}
|
||||
console.log(` hard navigation ${runPath} opened run ${discovered.preferred}'s detail; nav ${JSON.stringify(runNav)}`);
|
||||
await shot(`L6-deeplink-run-${discovered.preferred}.png`);
|
||||
|
||||
// The same for a pipeline route: /pipelines/:id means latest.
|
||||
const pipelinePath = `/pipelines/${pipelineId}`;
|
||||
await openDeepLink(pipelinePath);
|
||||
await eventually(
|
||||
() => page.evaluate(`!!document.querySelector(".detail h2")`),
|
||||
{ timeout: 30000, what: `the deep-linked pipeline ${pipelineId}` },
|
||||
);
|
||||
const deepPipeline = await page.evaluate(`(() => ({
|
||||
path: location.pathname + location.search,
|
||||
name: document.querySelector(".detail h2")?.textContent ?? "",
|
||||
}))()`);
|
||||
if (deepPipeline.path !== pipelinePath) {
|
||||
throw new Error(`L6: pipeline URL is ${deepPipeline.path}, expected ${pipelinePath}`);
|
||||
}
|
||||
if (pipelineSelection.name && deepPipeline.name !== pipelineSelection.name) {
|
||||
throw new Error(
|
||||
`L6: deep-linked pipeline rendered ${JSON.stringify(deepPipeline.name)}, expected ${JSON.stringify(pipelineSelection.name)}`,
|
||||
);
|
||||
}
|
||||
console.log(` hard navigation ${pipelinePath} opened ${JSON.stringify(deepPipeline.name)}`);
|
||||
await shot(`L6-deeplink-pipeline-${pipelineId}.png`);
|
||||
|
||||
// A pipeline-stage route opens the Graph tab and the named definition pane,
|
||||
// and brings that pane into view (the graph above it is taller than a viewport).
|
||||
const stagePath = `/pipelines/${pipelineId}/stage/planner`;
|
||||
await openDeepLink(stagePath);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`document.querySelector(".detail-tab.active")?.textContent === "Graph" &&
|
||||
!!document.querySelector(".graph-pane") && !document.querySelector(".graph-pane").hidden`,
|
||||
),
|
||||
{ timeout: 30000, what: "the deep-linked pipeline stage pane" },
|
||||
);
|
||||
const stageState = await page.evaluate(`(() => {
|
||||
const pane = document.querySelector(".graph-pane");
|
||||
const rect = pane.getBoundingClientRect();
|
||||
const head = document.querySelector(".graph-pane-head")?.getBoundingClientRect() ?? null;
|
||||
const close = document.querySelector(".graph-pane-close")?.getBoundingClientRect() ?? null;
|
||||
const topbar = document.querySelector(".topbar")?.getBoundingClientRect() ?? null;
|
||||
return {
|
||||
path: location.pathname + location.search,
|
||||
tab: document.querySelector(".detail-tab.active")?.textContent ?? "",
|
||||
title: document.querySelector(".graph-pane-title")?.textContent ?? "",
|
||||
top: Math.round(rect.top),
|
||||
viewport: window.innerHeight,
|
||||
topbarBottom: topbar ? Math.round(topbar.bottom) : 0,
|
||||
headTop: head ? Math.round(head.top) : null,
|
||||
headBottom: head ? Math.round(head.bottom) : null,
|
||||
closeTop: close ? Math.round(close.top) : null,
|
||||
};
|
||||
})()`);
|
||||
if (stageState.path !== stagePath) throw new Error(`L6: pipeline stage URL is ${stageState.path}`);
|
||||
if (stageState.tab !== "Graph") throw new Error(`L6: pipeline stage opened tab ${stageState.tab}`);
|
||||
if (!stageState.title) throw new Error("L6: the pipeline stage pane has no title");
|
||||
if (stageState.headTop == null || stageState.headTop < stageState.topbarBottom) {
|
||||
throw new Error(
|
||||
`L6: the opened stage pane head (top ${stageState.headTop}) is hidden under the sticky top bar (bottom ${stageState.topbarBottom})`,
|
||||
);
|
||||
}
|
||||
if (stageState.headBottom > stageState.viewport) {
|
||||
throw new Error(`L6: the opened stage pane head is below the viewport (bottom ${stageState.headBottom})`);
|
||||
}
|
||||
if (stageState.closeTop == null || stageState.closeTop < stageState.topbarBottom) {
|
||||
throw new Error(
|
||||
`L6: the stage pane Close control (top ${stageState.closeTop}) is hidden under the top bar (bottom ${stageState.topbarBottom})`,
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
` hard navigation ${stagePath} opened the Graph tab and the ${JSON.stringify(stageState.title)} pane (head ${stageState.headTop}px, top bar ${stageState.topbarBottom}px)`,
|
||||
);
|
||||
await shot(`L6-deeplink-pipeline-${pipelineId}-stage.png`);
|
||||
|
||||
// The graph also selects its terminals, and the URL it pushes for one must
|
||||
// re-open the same pane (a terminal is not a named stage, but it is a node the
|
||||
// page itself writes a /stage/ URL for). Find a terminal in the live graph.
|
||||
const terminalKey = await page.evaluate(`(() => {
|
||||
const node = [...document.querySelectorAll(".graph-node[data-key]")]
|
||||
.find((n) => (n.dataset.key ?? "").startsWith("#"));
|
||||
return node?.dataset.key ?? "";
|
||||
})()`);
|
||||
if (terminalKey) {
|
||||
const terminalPath = `/pipelines/${pipelineId}/stage/${encodeURIComponent(terminalKey)}`;
|
||||
await openDeepLink(terminalPath);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`!!document.querySelector(".graph-pane") && !document.querySelector(".graph-pane").hidden`,
|
||||
),
|
||||
{ timeout: 30000, what: `the deep-linked terminal pane ${terminalKey}` },
|
||||
);
|
||||
const terminalState = await page.evaluate(`(() => ({
|
||||
path: location.pathname + location.search,
|
||||
title: document.querySelector(".graph-pane-title")?.textContent ?? "",
|
||||
headTop: Math.round(document.querySelector(".graph-pane-head")?.getBoundingClientRect().top ?? -1),
|
||||
topbarBottom: Math.round(document.querySelector(".topbar")?.getBoundingClientRect().bottom ?? 0),
|
||||
}))()`);
|
||||
if (terminalState.path !== terminalPath) {
|
||||
throw new Error(
|
||||
`L6: the terminal stage URL was rewritten to ${terminalState.path}, expected ${terminalPath}`,
|
||||
);
|
||||
}
|
||||
if (!terminalState.title) throw new Error("L6: the terminal stage pane has no title");
|
||||
if (terminalState.headTop < terminalState.topbarBottom) {
|
||||
throw new Error("L6: the terminal stage pane head is hidden under the top bar");
|
||||
}
|
||||
console.log(
|
||||
` hard navigation ${terminalPath} re-opened the ${JSON.stringify(terminalState.title)} terminal pane (URL unchanged)`,
|
||||
);
|
||||
await shot(`L6-deeplink-pipeline-${pipelineId}-terminal.png`);
|
||||
} else {
|
||||
console.log(" -- the live graph has no terminal node; skipped the terminal stage deep link");
|
||||
}
|
||||
|
||||
// In-page moves: Pipelines -> Runs -> a run detail, then Back/Forward. A window
|
||||
// marker proves the document was never reloaded.
|
||||
const marker = `L6-no-reload-${Date.now()}`;
|
||||
await page.evaluate(`window.__pipelinesNoReload = ${JSON.stringify(marker)}`);
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs" && !!document.querySelector(".list.runs .run-row")`,
|
||||
),
|
||||
{ timeout: 25000, what: "the Runs list after a pushState move" },
|
||||
);
|
||||
console.log(` pushState Pipelines -> Runs: ${await currentLocation()}`);
|
||||
|
||||
const runRowSelector = `.list.runs .run-row-meta[data-run-id="${discovered.preferred}"]`;
|
||||
const clickedRun = await page.evaluate(`(() => {
|
||||
const node = document.querySelector(${JSON.stringify(runRowSelector)});
|
||||
if (!node) return false;
|
||||
node.click();
|
||||
return true;
|
||||
})()`);
|
||||
if (!clickedRun) throw new Error(`L6: run ${discovered.preferred} was not on the Runs list`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs/${discovered.preferred}" &&
|
||||
(document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${discovered.preferred} ") ?? false)`,
|
||||
),
|
||||
{ timeout: 30000, what: `run ${discovered.preferred} after a pushState selection` },
|
||||
);
|
||||
console.log(` pushState Runs -> run detail: ${await currentLocation()}`);
|
||||
|
||||
await page.evaluate(`history.back()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs" && !!document.querySelector(".list.runs .run-row")`,
|
||||
),
|
||||
{ timeout: 25000, what: "Back to the Runs list" },
|
||||
);
|
||||
const backState = await page.evaluate(`(() => ({
|
||||
path: location.pathname,
|
||||
marker: window.__pipelinesNoReload ?? null,
|
||||
staleDetail: !!document.querySelector(".run-detail .run-identity"),
|
||||
}))()`);
|
||||
if (backState.path !== "/runs") throw new Error(`L6: Back landed on ${backState.path}`);
|
||||
if (backState.staleDetail) throw new Error("L6: Back left a stale run detail rendered");
|
||||
if (backState.marker !== marker) throw new Error("L6: Back reloaded the document");
|
||||
console.log(` history.back() -> /runs, marker survived (${backState.marker})`);
|
||||
await shot("L6-history-back.png");
|
||||
|
||||
await page.evaluate(`history.forward()`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs/${discovered.preferred}" &&
|
||||
(document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${discovered.preferred} ") ?? false)`,
|
||||
),
|
||||
{ timeout: 30000, what: "Forward back to the run detail" },
|
||||
);
|
||||
const forwardState = await page.evaluate(`(() => ({
|
||||
path: location.pathname,
|
||||
marker: window.__pipelinesNoReload ?? null,
|
||||
}))()`);
|
||||
if (forwardState.marker !== marker) throw new Error("L6: Forward reloaded the document");
|
||||
console.log(` history.forward() -> ${forwardState.path}, marker survived`);
|
||||
|
||||
// Leaving Runs while an executing run's poll is active must stop that poll: a
|
||||
// silent get_run loop for a detail the view no longer shows would otherwise run
|
||||
// forever. Conditional because the live server may have no executing run.
|
||||
const executingId = 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 (executingId != null) {
|
||||
await page.click(`.list.runs .run-row-meta[data-run-id="${executingId}"]`);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`(document.querySelector(".run-detail .run-identity")?.textContent?.startsWith("run ${executingId} ") ?? false)`,
|
||||
),
|
||||
{ timeout: 30000, what: `the executing run ${executingId}` },
|
||||
);
|
||||
await page.evaluate(`window.__pipelinesSentTypes = []`);
|
||||
await page.clickText("nav.tabs button.tab", "Pipelines");
|
||||
await eventually(() => page.evaluate(`location.pathname === "/pipelines"`), {
|
||||
timeout: 15000,
|
||||
what: "Pipelines after leaving the executing run",
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2600));
|
||||
const leftoverPolls = await page.evaluate(
|
||||
`(window.__pipelinesSentTypes || []).filter((type) => type === "get_run").length`,
|
||||
);
|
||||
if (leftoverPolls > 0) {
|
||||
throw new Error(
|
||||
`L6: leaving Runs left the executing run's poll active (${leftoverPolls} get_run frame(s) after 2.6s)`,
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
` left executing run ${executingId} for /pipelines; no get_run poll fired in the next 2.6s`,
|
||||
);
|
||||
} else {
|
||||
console.log(" -- no executing run available; skipped the leave-Runs poll check");
|
||||
}
|
||||
|
||||
// The decide deep link is exercised only against a genuinely waiting run; with
|
||||
// none, say so rather than claiming a capture of a state that never rendered.
|
||||
if (discovered.waiting) {
|
||||
await openDeepLink(`/runs/${discovered.waiting}?action=decide`);
|
||||
await eventually(() => page.evaluate(`!!document.querySelector(".decision-sheet")`), {
|
||||
timeout: 30000,
|
||||
what: `the decision sheet for waiting run ${discovered.waiting}`,
|
||||
});
|
||||
const decideUrl = await currentLocation();
|
||||
if (decideUrl !== `/runs/${discovered.waiting}`) {
|
||||
throw new Error(`L6: the decide action was not consumed to /runs/${discovered.waiting}: ${decideUrl}`);
|
||||
}
|
||||
console.log(
|
||||
` hard navigation /runs/${discovered.waiting}?action=decide opened the decision sheet, action consumed`,
|
||||
);
|
||||
await shot(`L6-deeplink-decide-${discovered.waiting}.png`);
|
||||
await page.evaluate(`document.querySelector(".decision-sheet .decision-cancel")?.click()`);
|
||||
await eventually(() => page.evaluate(`!document.querySelector(".decision-sheet")`), {
|
||||
timeout: 5000,
|
||||
what: "the decision sheet to close without sending",
|
||||
});
|
||||
} else {
|
||||
console.log(
|
||||
" NOTE: the ?action=decide path was not exercised live (no waiting run on the server); test/routes.test.mjs covers its parsing",
|
||||
);
|
||||
}
|
||||
|
||||
// A missing run falls back honestly: the list with real rows, /runs in the URL,
|
||||
// the server's refusal in the banner and no stale run identity.
|
||||
await openDeepLink("/runs/900000000");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs" && document.querySelectorAll(".list.runs .run-row").length > 0`,
|
||||
),
|
||||
{ timeout: 30000, what: "the missing-run fallback to the Runs list" },
|
||||
);
|
||||
const missingState = await page.evaluate(`(() => ({
|
||||
path: location.pathname + location.search,
|
||||
rows: document.querySelectorAll(".list.runs .run-row").length,
|
||||
staleDetail: !!document.querySelector(".run-detail .run-identity"),
|
||||
error: document.querySelector(".banner.error")?.textContent ?? "",
|
||||
pageErrors: window.__pipelinesPageErrors ?? [],
|
||||
}))()`);
|
||||
if (missingState.path !== "/runs") throw new Error(`L6: missing run fell back to ${missingState.path}`);
|
||||
if (!missingState.rows) throw new Error("L6: missing run rendered no run rows");
|
||||
if (missingState.staleDetail) throw new Error("L6: missing run left a stale run detail");
|
||||
if (!missingState.error) throw new Error("L6: missing run showed no server refusal");
|
||||
if (missingState.pageErrors.length) {
|
||||
throw new Error(`L6: page errors: ${missingState.pageErrors.join(" | ")}`);
|
||||
}
|
||||
console.log(
|
||||
` missing run -> /runs with ${missingState.rows} real rows, banner ${JSON.stringify(missingState.error.replace(/^Error:\\s*/, ""))}`,
|
||||
);
|
||||
await shot("L6-missing-run.png");
|
||||
|
||||
// The same honest fallback for a pipeline the server does not have.
|
||||
await openDeepLink("/pipelines/900000000");
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/pipelines" && document.querySelectorAll("#pipelineRows button.row").length > 0`,
|
||||
),
|
||||
{ timeout: 30000, what: "the missing-pipeline fallback to the Pipelines list" },
|
||||
);
|
||||
const missingPipeline = await page.evaluate(`(() => ({
|
||||
path: location.pathname + location.search,
|
||||
rows: document.querySelectorAll("#pipelineRows button.row").length,
|
||||
staleDetail: !!document.querySelector(".detail h2"),
|
||||
error: document.querySelector(".banner.error")?.textContent ?? "",
|
||||
pageErrors: window.__pipelinesPageErrors ?? [],
|
||||
}))()`);
|
||||
if (missingPipeline.path !== "/pipelines") {
|
||||
throw new Error(`L6: missing pipeline fell back to ${missingPipeline.path}`);
|
||||
}
|
||||
if (!missingPipeline.rows) throw new Error("L6: missing pipeline rendered no pipeline rows");
|
||||
if (missingPipeline.staleDetail) throw new Error("L6: missing pipeline left a stale pipeline detail");
|
||||
if (!missingPipeline.error) throw new Error("L6: missing pipeline showed no server refusal");
|
||||
if (missingPipeline.pageErrors.length) {
|
||||
throw new Error(`L6: page errors: ${missingPipeline.pageErrors.join(" | ")}`);
|
||||
}
|
||||
console.log(
|
||||
` missing pipeline -> /pipelines with ${missingPipeline.rows} real rows, banner ${JSON.stringify(missingPipeline.error.replace(/^Error:\\s*/, ""))}`,
|
||||
);
|
||||
await shot("L6-missing-pipeline.png");
|
||||
|
||||
// A move made before the socket is up must become the destination the first
|
||||
// connection opens; only an untouched boot deep link is replayed. Load `/`,
|
||||
// choose Runs while disconnected, then connect and require URL and view to
|
||||
// agree (regression: the stale boot route used to win at connect time).
|
||||
await page.goto(`http://127.0.0.1:${port}/`);
|
||||
await page.waitForSelector("#connectBtn", { timeout: 15000 });
|
||||
await page.clickText("nav.tabs button.tab", "Runs");
|
||||
const preConnect = await currentLocation();
|
||||
if (preConnect !== "/runs") {
|
||||
throw new Error(`L6: a Runs choice before connecting left ${preConnect}, expected /runs`);
|
||||
}
|
||||
await page.click("#connectBtn");
|
||||
await ensureConnected(30000);
|
||||
await eventually(
|
||||
() =>
|
||||
page.evaluate(
|
||||
`location.pathname === "/runs" && !!document.querySelector(".list.runs .run-row")`,
|
||||
),
|
||||
{ timeout: 30000, what: "the pre-connect Runs choice after connecting" },
|
||||
);
|
||||
console.log(" a Runs choice made before connecting survived the first connection (/runs, list rendered)");
|
||||
|
||||
// C13: this device's own chat changes — a local rename that wins over the
|
||||
// server's title, the hide + Undo report, and the seen/New marker. Every
|
||||
// action here is device-local (localStorage): nothing is sent to the server for
|
||||
@@ -6228,7 +6717,16 @@ try {
|
||||
`(() => { const rows = [...document.querySelectorAll("#chatRows .chat-row")]; return rows.at(-1)?.dataset.session ?? ""; })()`,
|
||||
);
|
||||
if (!lastRowId) throw new Error("C13: no last row to test the menu against");
|
||||
await page.evaluate(`document.querySelector('.chat-row[data-session="${lastRowId}"]')?.scrollIntoView({ block: "center" })`);
|
||||
// Scroll the ROW LIST itself to the bottom (the list, not the page, is the
|
||||
// scroller), then the row, so the last-row menu check really starts with the row
|
||||
// on screen whatever the session count has grown to.
|
||||
await page.evaluate(`(() => {
|
||||
const list = document.querySelector(".chat-list") || document.querySelector("#chatRows");
|
||||
if (list) list.scrollTop = list.scrollHeight;
|
||||
document.querySelector('.chat-row[data-session="${lastRowId}"]')?.scrollIntoView({ block: "center" });
|
||||
return true;
|
||||
})()`);
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
await openChatRowMenu(lastRowId);
|
||||
const lastMenuHit = await page.evaluate(`(() => {
|
||||
const button = document.querySelector('.chat-row[data-session="${lastRowId}"] .chat-menu-hide');
|
||||
@@ -6261,9 +6759,19 @@ try {
|
||||
// (c) Hide the row the conversation is open on: it disappears, its conversation
|
||||
// closes, and one snackbar carries the exact message and Undo. Undo puts the
|
||||
// row back and leaves the server untouched.
|
||||
const activeBeforeHide = await page.evaluate(
|
||||
// Open a conversation when none is open: the preceding sections close their
|
||||
// throwaway through /close, and which chat is open is section state, not
|
||||
// something this device-local check should depend on.
|
||||
let activeBeforeHide = await page.evaluate(
|
||||
`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`,
|
||||
);
|
||||
if (!activeBeforeHide) {
|
||||
await page.evaluate(`document.querySelector("#chatRows .chat-row")?.click()`);
|
||||
await page.waitForSelector("#chatInput", { timeout: 15000 });
|
||||
activeBeforeHide = await page.evaluate(
|
||||
`document.querySelector(".chat-row.selected")?.dataset.session ?? ""`,
|
||||
);
|
||||
}
|
||||
if (!activeBeforeHide) throw new Error("C13: no conversation was open before the hide");
|
||||
await openChatRowMenu(activeBeforeHide);
|
||||
await page.click(`#chatRows .chat-row[data-session="${activeBeforeHide}"] .chat-menu-hide`);
|
||||
|
||||
Reference in New Issue
Block a user