feat(workflows): pick a lane in the pipeline pass-rate panel
The panel aggregated every lane at once, which answers "does this stage get proved across the project" but never "does THIS lane prove it". A lane picker now narrows the same aggregation through ?lane=<id> on GET /api/lanes/pipeline-stats, counting that lane plus its own archived features — dropping the features would hide most of a lane's history the moment it starts its next one. The response carries a `lanes` array that the filter never narrows: it populates the picker, so it has to keep offering every other lane even while the counts show one. For the same reason the picker renders above the empty branch rather than inside the populated one — narrowing to a lane that has recorded nothing would otherwise be a one-way trip, with no control left to select anything else. A lane filter that is not a positive integer is rejected with 400 EBADLANE rather than silently aggregating everything.
This commit is contained in:
@@ -118,6 +118,52 @@ describe("GET /api/lanes/pipeline-stats", () => {
|
||||
assert.equal(gate.passed, 1);
|
||||
assert.equal(gate.withEvidence, 1);
|
||||
});
|
||||
|
||||
it("narrows to one lane and its own archived features with ?lane=", async () => {
|
||||
const mine = makeLane();
|
||||
const other = makeLane();
|
||||
setStages(mine.id, { plan: { enteredAt: "x", evidence: "plan.md", result: null } });
|
||||
setStages(other.id, { plan: { enteredAt: "x", evidence: null, result: null } });
|
||||
db.prepare(
|
||||
`INSERT INTO lane_features (lane_id, slug, pipeline, stage, stages, archived_at)
|
||||
VALUES (?, 'mine-old', 'default', 'done', ?, '2026-01-02T00:00:00Z')`
|
||||
).run(mine.id, JSON.stringify({ plan: { enteredAt: "x", evidence: "old.md", result: null } }));
|
||||
|
||||
const res = await get(`/api/lanes/pipeline-stats?lane=${mine.id}`);
|
||||
assert.equal(res.status, 200);
|
||||
const plan = node(res.body, "default", "plan");
|
||||
// The lane itself plus its one archived feature — never the other lane's.
|
||||
assert.deepEqual(
|
||||
{ entered: plan.entered, withEvidence: plan.withEvidence },
|
||||
{ entered: 2, withEvidence: 2 }
|
||||
);
|
||||
});
|
||||
|
||||
it("always returns every lane for the picker, even when narrowed", async () => {
|
||||
const lane = makeLane();
|
||||
const res = await get(`/api/lanes/pipeline-stats?lane=${lane.id}`);
|
||||
assert.ok(res.body.lanes.length > 1);
|
||||
assert.ok(res.body.lanes.every((l) => l.id && typeof l.cwd === "string"));
|
||||
});
|
||||
|
||||
it("still describes the template for a lane that has recorded nothing", async () => {
|
||||
const lane = makeLane();
|
||||
const res = await get(`/api/lanes/pipeline-stats?lane=${lane.id}`);
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(node(res.body, "default", "plan").entered, 0);
|
||||
});
|
||||
|
||||
it("returns no pipelines at all for a lane id that does not exist", async () => {
|
||||
const res = await get("/api/lanes/pipeline-stats?lane=999999");
|
||||
assert.equal(res.status, 200);
|
||||
assert.deepEqual(res.body.pipelines, []);
|
||||
});
|
||||
|
||||
it("rejects a lane filter that is not an id", async () => {
|
||||
const res = await get("/api/lanes/pipeline-stats?lane=../etc");
|
||||
assert.equal(res.status, 400);
|
||||
assert.equal(res.body.error.code, "EBADLANE");
|
||||
});
|
||||
});
|
||||
|
||||
describe("GET /api/workflows/skill-usage", () => {
|
||||
|
||||
Reference in New Issue
Block a user