27 lines
957 B
TypeScript
27 lines
957 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { filterActivity, matchesActivityFilter } from "../src/dashboard/activity-filter.ts";
|
|
|
|
const feed = [
|
|
{ kind: "task_started", task_id: 41 },
|
|
{ kind: "curator_run" },
|
|
{ kind: "session-memory", task_id: 0 },
|
|
{ kind: "agent_finish", task_id: "42" },
|
|
];
|
|
|
|
test("activity filters partition task and system events without reordering", () => {
|
|
for (const [filter, expected] of [
|
|
["all", feed],
|
|
["tasks", [feed[0], feed[3]]],
|
|
["system", [feed[1], feed[2]]],
|
|
] as const) {
|
|
assert.deepEqual(filterActivity(feed, filter), expected, filter);
|
|
}
|
|
for (const task_id of [0, "", "abc", -1, null, undefined]) {
|
|
assert.equal(matchesActivityFilter({ task_id }, "tasks"), false, String(task_id));
|
|
assert.equal(matchesActivityFilter({ task_id }, "system"), true, String(task_id));
|
|
}
|
|
assert.equal(matchesActivityFilter({ task_id: "7" }, "tasks"), true);
|
|
});
|
|
|