web: run detail Graph tab with executed styling and stage panes (R5)
Add the run detail's Graph tab (between Summary and Input), reusing the shared src/graph.js renderer (P6) rather than a second renderer. In run mode a visited stage is executed (solid fill + border), an unvisited one hollow with a dashed muted border; a terminal is executed only when a visit resolved to it; a route is executed only when a recorded visit produced that outcome (solid with an arrowhead, success first, error last, others alphabetical, `error*` for the fallback). The Executed / Not executed legend shows only for a run. While the run executes the current stage carries a pulsing halo (static under prefers-reduced-motion) and a ticking elapsed badge; a finished run shows neither. Clicking a stage opens the existing visit pane at that stage's latest visit, and Back/Escape return focus. The empty state is the exact "This server did not include the run graph." extend src/graph.js with the run-mode inputs (runState-driven executed styling, legend, active halo/elapsed badge); keep app.js to wiring. Extend graph.test.mjs with focused run-mode unit tests and ui-smoke.mjs with the run 438 / run 440 / live-run captures. Mark R5 done in web/PARITY.md. Checks: node --check on every touched file; cd web && node --test test/ (178 pass, 0 fail); cd web && node test/ui-smoke.mjs --out captures (UI SMOKE PASS, captures 28-31).
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
MAX_SCALE,
|
||||
PIPELINE_GRAPH_EMPTY,
|
||||
RUN_GRAPH_MISSING,
|
||||
RUN_GRAPH_NOTE,
|
||||
NO_NODE_DETAILS,
|
||||
STAGE_DEFINITION_TITLE,
|
||||
configLabel,
|
||||
@@ -33,7 +34,11 @@ import {
|
||||
clampOffset,
|
||||
fitScale,
|
||||
zoomAbout,
|
||||
stageIsExecuted,
|
||||
edgeIsExecuted,
|
||||
activeStage,
|
||||
} from "../src/graph.js";
|
||||
import { runGraphState } from "../src/runDetail.js";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fixtures
|
||||
@@ -369,12 +374,119 @@ test("terminalFields lists the incoming routes into a terminal", () => {
|
||||
assert.deepEqual(terminalFields(twoStageGraph(), "#nope"), []);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Run-mode execution state (R5: GraphSemantics RunGraphState.from)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("runGraphState resolves visited stages, taken routes and reached terminals", () => {
|
||||
const run = {
|
||||
executing: false,
|
||||
current_stage: "committer",
|
||||
steps: [
|
||||
{ stage: "implementer", sequence: 1, status: "completed", outcome: "success", target: "reviewer" },
|
||||
{ stage: "reviewer", sequence: 2, status: "completed", outcome: "rejected", target: "implementer" },
|
||||
{ stage: "implementer", sequence: 3, status: "completed", outcome: "success", target: "reviewer" },
|
||||
{ stage: "committer", sequence: 4, status: "completed", outcome: "success", target: "#success" },
|
||||
],
|
||||
};
|
||||
const state = runGraphState(run);
|
||||
assert.deepEqual(state.visitedStages, ["implementer", "reviewer", "committer", "#success"]);
|
||||
assert.equal(state.currentStage, "committer");
|
||||
assert.equal(state.executing, false);
|
||||
assert.equal(state.currentStageStartedAt, null);
|
||||
assert.deepEqual(state.takenRoutes, [
|
||||
"implementer\u0000success\u0000reviewer",
|
||||
"reviewer\u0000rejected\u0000implementer",
|
||||
"committer\u0000success\u0000#success",
|
||||
]);
|
||||
});
|
||||
|
||||
test("runGraphState marks a terminal only when a visit resolved to it", () => {
|
||||
// A `#` target resolves by outcome: error -> #failure, everything else -> #success.
|
||||
const failed = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "error", target: "#" }],
|
||||
});
|
||||
assert.deepEqual(failed.visitedStages, ["impl", "#failure"]);
|
||||
assert.equal(stageIsExecuted("#failure", failed), true);
|
||||
assert.equal(stageIsExecuted("#success", failed), false);
|
||||
|
||||
const midRun = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "success", target: "review" }],
|
||||
});
|
||||
assert.equal(stageIsExecuted("#success", midRun), false);
|
||||
assert.equal(stageIsExecuted("#failure", midRun), false);
|
||||
assert.equal(stageIsExecuted("review", midRun), false, "a target is not visited until a step lands on it");
|
||||
});
|
||||
|
||||
test("stageIsExecuted is true for a visited stage and for the definition view", () => {
|
||||
const state = runGraphState({
|
||||
executing: false,
|
||||
steps: [{ stage: "impl", outcome: "success", target: "review" }],
|
||||
});
|
||||
assert.equal(stageIsExecuted("impl", state), true);
|
||||
assert.equal(stageIsExecuted("review", state), false);
|
||||
// The definition view passes no runState, so every stage is executed.
|
||||
assert.equal(stageIsExecuted("review", null), true);
|
||||
});
|
||||
|
||||
test("edgeIsExecuted is true only for a route a recorded visit produced", () => {
|
||||
const state = runGraphState({
|
||||
executing: false,
|
||||
steps: [
|
||||
{ stage: "impl", outcome: "success", target: "review" },
|
||||
{ stage: "review", outcome: "error", target: "#" },
|
||||
],
|
||||
});
|
||||
const taken = { source: "impl", outcome: "success", target: "review" };
|
||||
const byFallback = { source: "review", outcome: "error", target: "#failure" };
|
||||
const untaken = { source: "impl", outcome: "blocked", target: "#failure" };
|
||||
assert.equal(edgeIsExecuted(taken, state), true);
|
||||
assert.equal(edgeIsExecuted(byFallback, state), true, "a resolved fallback route counts");
|
||||
assert.equal(edgeIsExecuted(untaken, state), false);
|
||||
// The definition view draws every route executed.
|
||||
assert.equal(edgeIsExecuted(untaken, null), true);
|
||||
});
|
||||
|
||||
test("activeStage resolves only while the run is executing", () => {
|
||||
const live = runGraphState({
|
||||
executing: true,
|
||||
current_stage: "review",
|
||||
steps: [
|
||||
{ stage: "review", status: "running", started_at: "2026-01-01T00:00:00Z" },
|
||||
],
|
||||
});
|
||||
assert.equal(activeStage(live), "review");
|
||||
assert.equal(live.currentStageStartedAt, "2026-01-01T00:00:00Z");
|
||||
|
||||
const settled = runGraphState({
|
||||
executing: false,
|
||||
current_stage: "review",
|
||||
steps: [
|
||||
{ stage: "review", status: "running", started_at: "2026-01-01T00:00:00Z" },
|
||||
],
|
||||
});
|
||||
assert.equal(activeStage(settled), null, "a finished run has no active stage");
|
||||
assert.equal(settled.currentStageStartedAt, null);
|
||||
assert.equal(activeStage(null), null, "the definition view has no active stage");
|
||||
});
|
||||
|
||||
test("runGraphState falls back to the last visit's stage, else null", () => {
|
||||
const state = runGraphState({ executing: false, steps: [{ stage: "a" }, { stage: "b" }] });
|
||||
assert.equal(state.currentStage, "b");
|
||||
assert.equal(runGraphState({ executing: false, steps: [] }).currentStage, null);
|
||||
assert.equal(runGraphState({}).currentStage, null);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Wording, exports and the no-innerHTML contract
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test("the empty-state and pane wording matches the app's sentences", () => {
|
||||
assert.equal(RUN_GRAPH_MISSING, "This server did not include the run graph.");
|
||||
assert.ok(RUN_GRAPH_NOTE.includes("pulses"));
|
||||
assert.ok(RUN_GRAPH_NOTE.includes("Mouse wheel to zoom"));
|
||||
assert.equal(PIPELINE_GRAPH_EMPTY, "This pipeline has no stages.");
|
||||
assert.equal(NO_NODE_DETAILS, "No details recorded for this node.");
|
||||
assert.equal(STAGE_DEFINITION_TITLE, "Stage definition");
|
||||
|
||||
Reference in New Issue
Block a user