Archie owns the status and action vocabulary in internal/taskstate, but the
dashboard had to keep a hand-synced copy of the display labels, pill severities
and action confirm prompts -- so a new status or action silently rendered
wrong until someone edited the frontend.
- add taskstate.Statuses() and taskstate.ActionCatalog() so the rules and their
presentation live in one place
- expose GET /api/task-meta returning {statuses, actions}
- add a client base/task-meta.js that fetches the catalog and exposes
statusLabel/statusKind/statusIds/attentionStatusIds/actionFor, with a
freeze-dried default snapshot so the dashboard renders instantly and keeps
working when archied is unreachable
- tests for the catalog, the endpoint and the client accessors
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import "./shim.js";
|
|
import {
|
|
actionFor,
|
|
attentionStatusIds,
|
|
statusIds,
|
|
statusKind,
|
|
statusLabel,
|
|
} from "../src/base/task-meta.js";
|
|
|
|
test("statusLabel returns the human label for known statuses", () => {
|
|
assert.equal(statusLabel("pr_open"), "In review");
|
|
assert.equal(statusLabel("waiting_human"), "Waiting for you");
|
|
});
|
|
|
|
test("statusLabel falls back to the raw id for unknown statuses", () => {
|
|
assert.equal(statusLabel("quantum_superposition"), "quantum_superposition");
|
|
});
|
|
|
|
test("statusKind returns the pill severity for a status", () => {
|
|
assert.equal(statusKind("running"), "info");
|
|
assert.equal(statusKind("pr_open"), "ok");
|
|
assert.equal(statusKind("parked"), "warn");
|
|
assert.equal(statusKind("dead"), "danger");
|
|
});
|
|
|
|
test("statusKind defaults to idle for unknown statuses", () => {
|
|
assert.equal(statusKind("quantum_superposition"), "idle");
|
|
});
|
|
|
|
test("statusIds includes every lifecycle status", () => {
|
|
assert.deepEqual(new Set(statusIds()), new Set([
|
|
"queued", "running", "waiting_human", "pr_open", "merged",
|
|
"parked", "dead", "rejected", "closed_wont_do",
|
|
]));
|
|
});
|
|
|
|
test("attentionStatusIds groups the statuses that need a human", () => {
|
|
const ids = attentionStatusIds();
|
|
assert.ok(ids.has("waiting_human"));
|
|
assert.ok(ids.has("parked"));
|
|
assert.ok(!ids.has("queued"));
|
|
});
|
|
|
|
test("actionFor returns label, kind and confirm from the catalog", () => {
|
|
const reject = actionFor("reject");
|
|
assert.ok(reject);
|
|
assert.equal(reject.label, "Reject");
|
|
assert.equal(reject.kind, "quiet");
|
|
assert.ok(reject.confirm.includes("{title}"));
|
|
});
|
|
|
|
test("actionFor marks navigation links as link kind", () => {
|
|
assert.equal(actionFor("open_pr").kind, "link");
|
|
assert.equal(actionFor("open_issue").kind, "link");
|
|
});
|
|
|
|
test("actionFor returns null for an unknown action", () => {
|
|
assert.equal(actionFor("teleport"), null);
|
|
});
|