Files
archie/ui/test/task-filter.test.ts
T
sam 4de8b67ba8 refactor(workflow): stop assuming a human decides
An approval, ask or park can be resolved by an operator, a rule, a
classifier or automatically, so the vocabulary stops naming a person:

- step type human.approve -> workflow.approve
- park class needs_human -> needs_decision (ParkNeedsDecision)
- event kinds human_* -> operator_*
- alert kind task.needs_human -> task.needs_decision
- status grouping "needs you" -> "needs attention"

0061 rewrites the stored values, including the approval step type in the
workflow-definitions resource and each task's pinned definition, with the
digest recomputed so resumed tasks still match.
2026-10-25 17:31:16 +11:00

62 lines
1.6 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { computed, ref } from "vue";
import {
boardStatus,
initialTaskFilter,
} from "../src/tasks/task-filter.ts";
const QUEUED = { id: "queued", label: "Queued", kind: "idle" };
const WAITING = {
id: "waiting_approval",
label: "Waiting for approval",
kind: "warn",
needs_attention: true,
};
const TRIAGING = { id: "triaging", label: "Triaging", kind: "info" };
test("only a status the served catalog knows becomes a filter", () => {
const catalog = [QUEUED, WAITING, TRIAGING];
const cases: Array<[string | null | undefined, string]> = [
["queued", "queued"],
["needs_attention", "needs_attention"],
["triaging", "triaging"],
["archived_elsewhere", ""],
[" ", ""],
["", ""],
[null, ""],
[undefined, ""],
];
for (const [requested, expected] of cases) {
assert.equal(
initialTaskFilter(requested, catalog),
expected,
JSON.stringify(requested),
);
}
});
test("a filter is re-derived when the served catalog lands", () => {
const catalog = ref([QUEUED]);
const query = ref("triaging");
const status = computed(() => boardStatus(query.value, catalog.value));
assert.equal(status.value, "", "an id no catalog has held yet is dropped");
catalog.value = [...catalog.value, TRIAGING];
assert.equal(
status.value,
"triaging",
"the served id becomes the filter once it arrives",
);
query.value = "queued";
assert.equal(
status.value,
"queued",
"a back-button step still moves the filter",
);
query.value = "";
assert.equal(status.value, "", "clearing the query clears the filter");
});