perf(test): stub config + persistence in subagent registry tests

This commit is contained in:
Peter Steinberger
2026-02-15 13:34:45 +00:00
parent b2088d2e1d
commit a742d44133
2 changed files with 24 additions and 2 deletions

View File

@@ -14,15 +14,26 @@ vi.mock("../infra/agent-events.js", () => ({
onAgentEvent: vi.fn(() => noop),
}));
vi.mock("../config/config.js", () => ({
loadConfig: vi.fn(() => ({
agents: { defaults: { subagents: { archiveAfterMinutes: 0 } } },
})),
}));
vi.mock("./subagent-announce.js", () => ({
runSubagentAnnounceFlow: vi.fn(async () => true),
buildSubagentSystemPrompt: vi.fn(() => "test prompt"),
}));
vi.mock("./subagent-registry.store.js", () => ({
loadSubagentRegistryFromDisk: vi.fn(() => new Map()),
saveSubagentRegistryToDisk: vi.fn(() => {}),
}));
describe("subagent registry nested agent tracking", () => {
afterEach(async () => {
const mod = await import("./subagent-registry.js");
mod.resetSubagentRegistryForTests();
mod.resetSubagentRegistryForTests({ persist: false });
});
it("listSubagentRunsForRequester returns children of the requesting session", async () => {

View File

@@ -22,17 +22,28 @@ vi.mock("../infra/agent-events.js", () => ({
}),
}));
vi.mock("../config/config.js", () => ({
loadConfig: vi.fn(() => ({
agents: { defaults: { subagents: { archiveAfterMinutes: 0 } } },
})),
}));
const announceSpy = vi.fn(async () => true);
vi.mock("./subagent-announce.js", () => ({
runSubagentAnnounceFlow: (...args: unknown[]) => announceSpy(...args),
}));
vi.mock("./subagent-registry.store.js", () => ({
loadSubagentRegistryFromDisk: vi.fn(() => new Map()),
saveSubagentRegistryToDisk: vi.fn(() => {}),
}));
describe("subagent registry steer restarts", () => {
afterEach(async () => {
announceSpy.mockClear();
lifecycleHandler = undefined;
const mod = await import("./subagent-registry.js");
mod.resetSubagentRegistryForTests();
mod.resetSubagentRegistryForTests({ persist: false });
});
it("suppresses announce for interrupted runs and only announces the replacement run", async () => {