perf(test): replace subagent lifecycle polling helper

This commit is contained in:
Peter Steinberger
2026-02-18 17:53:33 +00:00
parent c68d1073b5
commit cd8eb079e3

View File

@@ -1,7 +1,6 @@
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
import { emitAgentEvent } from "../infra/agent-events.js"; import { emitAgentEvent } from "../infra/agent-events.js";
import "./test-helpers/fast-core-tools.js"; import "./test-helpers/fast-core-tools.js";
import { sleep } from "../utils.js";
import { import {
getCallGatewayMock, getCallGatewayMock,
resetSessionsSpawnConfigOverride, resetSessionsSpawnConfigOverride,
@@ -126,13 +125,12 @@ function setupSessionsSpawnGatewayMock(opts: {
} }
const waitFor = async (predicate: () => boolean, timeoutMs = 2000) => { const waitFor = async (predicate: () => boolean, timeoutMs = 2000) => {
const start = Date.now(); await vi.waitFor(
while (!predicate()) { () => {
if (Date.now() - start > timeoutMs) { expect(predicate()).toBe(true);
throw new Error(`timed out waiting for condition (timeoutMs=${timeoutMs})`); },
} { timeout: timeoutMs, interval: 10 },
await sleep(10); );
}
}; };
function expectSingleCompletionSend( function expectSingleCompletionSend(