| 1 | import { test } from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | |
| 4 | import { shownCard } from "./cards.ts"; |
| 5 | |
| 6 | test("an old card keeps its links and drops actions nobody answers any more", () => { |
| 7 | const card = shownCard({ |
| 8 | kind: "session", |
| 9 | title: "Fix the login", |
| 10 | detail: null, |
| 11 | state: "working", |
| 12 | href: "/acme/web/pull/1", |
| 13 | owner: "agents", |
| 14 | ref: "ses_1", |
| 15 | actions: [ |
| 16 | { id: "approve", label: "Approve more", style: "primary", confirm: null, input: null, href: null }, |
| 17 | { id: "open", label: "Open", style: "default", confirm: null, input: null, href: "/acme/web/pull/1" }, |
| 18 | ], |
| 19 | }); |
| 20 | assert.equal(card.owner, undefined); |
| 21 | assert.equal(card.ref, undefined); |
| 22 | assert.deepEqual(card.actions?.map((a) => a.id), ["open"]); |
| 23 | }); |
| 24 | |
| 25 | test("a card with nothing left to press has no actions", () => { |
| 26 | const card = shownCard({ kind: "x", title: "x", detail: null, state: null, href: null, owner: "agents", actions: [{ id: "stop", label: "Stop", style: "danger", confirm: null, input: null, href: null }] }); |
| 27 | assert.equal("actions" in card, false); |
| 28 | assert.deepEqual(shownCard({ kind: "x", title: "x", detail: null, state: null, href: null }), { kind: "x", title: "x", detail: null, state: null, href: null }); |
| 29 | }); |