mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:28:27 +00:00
perf(test): replace subagent lifecycle polling helper
This commit is contained in:
@@ -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(
|
||||||
|
|||||||
Reference in New Issue
Block a user