Files
archie/ui/test/task-filters.test.js
T
sam cf06cd6a08 feat(dashboard): render task actions, statuses and filters from the server catalog
Three surfaces stopped keeping hand-synced copies of the lifecycle vocabulary,
so a status or action added on the backend shows up without a frontend change:

- task actions render label/variant/confirm from taskstate.ActionCatalog via
  actionFor(); unknown actions no longer vanish behind a hardcoded switch and
  a new action needs no frontend case
- status labels and pill severities come from taskstate.Statuses via
  statusLabel()/statusKind(); the local copy and the dom.js switch are gone
- the status filter vocabulary and the "needs you" grouping derive from
  statusIds()/attentionStatusIds(); a new status appears in the filter and in
  the settings page's Work lifecycle card, driven by /api/task-meta

Regenerated ui/dist so the embedded binary ships the new dashboard.
2026-08-28 00:55:17 +00:00

36 lines
1.7 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import "./shim.js";
import { initialTaskFilter, taskMatchesStatus } from "../src/tasks/task-filters.js";
import { attentionStatusIds, statusIds } from "../src/base/task-meta.js";
test("the needs_you filter group matches exactly the catalog's attention statuses", () => {
const attention = attentionStatusIds();
// Every status the catalog marks as needing a human matches "needs_you".
for (const id of attention) {
assert.equal(taskMatchesStatus({ status: id }, "needs_you"), true, `${id} should match needs_you`);
}
// No non-attention catalog status does.
for (const id of statusIds()) {
if (!attention.has(id)) {
assert.equal(taskMatchesStatus({ status: id }, "needs_you"), false, `${id} should not match needs_you`);
}
}
});
test("initialTaskFilter accepts needs_you and every catalog status, and drops unknowns", () => {
assert.equal(initialTaskFilter(new URLSearchParams("status=needs_you")), "needs_you");
// TASK_STATUSES is derived from the catalog, so every statusId is accepted.
for (const id of statusIds()) {
assert.equal(initialTaskFilter(new URLSearchParams(`status=${id}`)), id, `${id} should be accepted`);
}
assert.equal(initialTaskFilter(new URLSearchParams("status=quantum_superposition")), "");
assert.equal(initialTaskFilter(new URLSearchParams("status=")), "");
});
test("taskMatchesStatus matches a specific catalog status exactly", () => {
assert.equal(taskMatchesStatus({ status: "running" }, "running"), true);
assert.equal(taskMatchesStatus({ status: "running" }, "queued"), false);
assert.equal(taskMatchesStatus({ status: "running" }, ""), true);
});