swarm ui: an open todos section on the agent card
This commit is contained in:
parent
b239500f88
commit
fa2a75d499
1 changed files with 200 additions and 12 deletions
36
frontend/packages/swarm-ui/test/agent-todos.test.mjs
Normal file
36
frontend/packages/swarm-ui/test/agent-todos.test.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// An agent's open todos: their order and the count in words. Run by `npm test`.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { sortTodos, todosLabel } from "../src/agent/terminal/agent-todos.ts";
|
||||
|
||||
const todo = (id, updated_unix) => ({
|
||||
id,
|
||||
subsystem: "forge",
|
||||
summary: `todo ${id}`,
|
||||
updated_unix,
|
||||
});
|
||||
|
||||
test("the newest todo comes first and a tie goes to the higher id", () => {
|
||||
const ids = sortTodos([
|
||||
todo(1, 100),
|
||||
todo(2, 300),
|
||||
todo(3, 300),
|
||||
todo(4, 200),
|
||||
]).map((t) => t.id);
|
||||
assert.deepEqual(ids, [3, 2, 4, 1]);
|
||||
});
|
||||
|
||||
test("sorting leaves the list it was given alone", () => {
|
||||
const list = [todo(1, 100), todo(2, 200)];
|
||||
sortTodos(list);
|
||||
assert.deepEqual(
|
||||
list.map((t) => t.id),
|
||||
[1, 2],
|
||||
);
|
||||
});
|
||||
|
||||
test("the count reads in words", () => {
|
||||
assert.equal(todosLabel([]), "no open todos");
|
||||
assert.equal(todosLabel([todo(1, 1)]), "1 open todo");
|
||||
assert.equal(todosLabel([todo(1, 1), todo(2, 2)]), "2 open todos");
|
||||
});
|
||||
Loading…
Reference in a new issue