test: speed up subagent registry persistence tests

This commit is contained in:
Shakker
2026-05-09 21:16:57 +01:00
parent 7c1ab59ee2
commit 2acd6aef92
2 changed files with 12 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ export function createSubagentRegistryTestDeps(
): Record<string, unknown> {
return {
cleanupBrowserSessionsForLifecycleEnd: vi.fn(async () => {}),
captureSubagentCompletionReply: vi.fn(async () => undefined),
ensureContextEnginesInitialized: vi.fn(),
ensureRuntimePluginsLoaded: vi.fn(),
getRuntimeConfig: vi.fn(() => ({})),

View File

@@ -188,6 +188,8 @@ describe("subagent registry persistence", () => {
};
beforeEach(() => {
announceSpy.mockReset();
announceSpy.mockResolvedValue(true);
__testing.setDepsForTest({
...createSubagentRegistryTestDeps(),
persistSubagentRunsToDisk: fastPersistSubagentRunsToDisk,
@@ -204,7 +206,6 @@ describe("subagent registry persistence", () => {
});
afterEach(async () => {
announceSpy.mockClear();
__testing.setDepsForTest();
resetSubagentRegistryForTests({ persist: false });
await drainSessionStoreWriterQueuesForTest();
@@ -670,6 +671,15 @@ describe("subagent registry persistence", () => {
});
it("keeps stale unended restored runs with abortedLastRun for restart recovery", async () => {
vi.mocked(callGateway).mockImplementationOnce(async (request) => {
expect(request).toMatchObject({
method: "agent.wait",
params: { runId: "run-stale-aborted-restore" },
});
return {
status: "pending",
};
});
const now = Date.now();
const runId = "run-stale-aborted-restore";
const childSessionKey = "agent:main:subagent:stale-aborted-restore";