import assert from "node:assert/strict"; import test from "node:test"; import { needsAttention, waitsOnPerson } from "../src/lib/needs-attention.ts"; // Guards #2145: the shell used to count what needs a person from the task // board's summary, which the binary does not serve, so the count went with the // board. It now counts the two things the binary does serve. test("what waits on a person is a pending approval or a parked run", () => { const approval = (state: string) => ({ state }) as never; const run = (state: string) => ({ state }) as never; assert.equal(waitsOnPerson(approval("pending"), undefined), true); assert.equal(waitsOnPerson(approval("approved"), undefined), false); assert.equal(waitsOnPerson(approval("refused"), undefined), false); assert.equal(waitsOnPerson(undefined, run("parked")), true); assert.equal(waitsOnPerson(undefined, run("running")), false); }); test("the count adds approvals and runs, and reads nothing as zero", () => { const approvals = [{ state: "pending" }, { state: "pending" }, { state: "approved" }] as never[]; const runs = [{ state: "parked" }, { state: "running" }, { state: "succeeded" }] as never[]; assert.equal(needsAttention(approvals, runs), 3); assert.equal(needsAttention([], []), 0); assert.equal(needsAttention(undefined, undefined), 0); });