// The readiness bar's pills (lib/inbox/readiness.mjs): the Inbox's rows bucketed, and what is NOT known never ✓. import { test } from "node:test"; import assert from "node:assert/strict"; import { readinessPills } from "./readiness.mjs"; const hrefs = { decisions: "/d", home: "/", deliver: "/deliver", takes: "/takes", cut: "/cut", xSettings: "http://e/settings", review: (t) => `/review/${t}` }; const facts = { quoteCheck: true, linksChecked: true, clips: 3, xPosts: 1, built: true, rendered: true, decisionsKnown: true, xKnown: true }; const state = (pills) => Object.fromEntries(pills.map((p) => [p.id, p.state])); test("a piece with nothing waiting: ✓ each, the checks known", () => { assert.deepEqual(state(readinessPills({ rows: [], facts, hrefs })), { "quote-check": "ok", links: "ok", captures: "ok", render: "ok", "x-jar": "ok" }); }); test("rows: blocking is !, the rest a count; X's stale jar is ! wherever it is", () => { const rows = [ { kind: "clip-quote-moved", target: "c1", why: "heard 13 s early", href: "/d", severity: "blocking" }, { kind: "links-unchecked", target: "QR links", why: "never checked", href: "/d", severity: "info" }, { kind: "version-unjudged", target: "v2", why: "no verdict", href: "/p", severity: "open" }, { kind: "x-jar-stale", target: "x", why: "3 h old", href: "http://e/settings", severity: "blocking" }, ]; const p = readinessPills({ rows, facts, hrefs }); assert.deepEqual(state(p), { "quote-check": "bad", links: "count", captures: "ok", render: "count", "x-jar": "bad" }); assert.equal(p.find((x) => x.id === "render").href, "/review/v2"); }); test("not known is never ✓: the checks did not read -- —; the editor did not answer for X's jar -- —; nothing rendered -- —", () => { assert.deepEqual(state(readinessPills({ rows: [], facts: { ...facts, decisionsKnown: false }, hrefs })), { "quote-check": "none", links: "none", captures: "none", render: "none", "x-jar": "ok" }); const x = readinessPills({ rows: [], facts: { ...facts, xKnown: false }, hrefs }).find((p) => p.id === "x-jar"); assert.deepEqual([x.state, x.title], ["none", "the editor did not answer: X's jar is not known"]); assert.equal(readinessPills({ rows: [], facts: { ...facts, built: false, rendered: false }, hrefs }).find((p) => p.id === "render").state, "none"); });