agent-r/test/progress.test.ts
2026-04-11 17:06:06 +09:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { formatProgressEventHuman, progressEventsFromThreadEvent } from "../src/progress.js";
describe("progress helpers", () => {
test("summarizes command and todo events for stdout", () => {
const todoEvents = progressEventsFromThreadEvent("run-1", "implementation", {
type: "item.started",
item: {
id: "todo-1",
type: "todo_list",
items: [
{ text: "Inspect repository state", completed: true },
{ text: "Run proof command", completed: false },
],
},
});
const commandEvents = progressEventsFromThreadEvent("run-1", "implementation", {
type: "item.completed",
item: {
id: "cmd-1",
type: "command_execution",
command: "/bin/bash -lc 'npm test'",
aggregated_output: "ok 5 tests\n",
exit_code: 0,
status: "completed",
},
});
expect(todoEvents).toHaveLength(1);
expect(todoEvents[0]?.kind).toBe("todo_list.updated");
expect(todoEvents[0]?.message).toContain("1/2 complete");
expect(commandEvents[0]?.kind).toBe("command.completed");
expect(commandEvents[0]?.message).toContain("exit=0");
expect(formatProgressEventHuman(commandEvents[0]!)).toContain("[implementation] [command.completed]");
});
});