perf(test): replace claude runner call polling loop
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { sleep } from "../utils.js";
|
||||
import { runClaudeCliAgent } from "./claude-cli-runner.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -65,13 +64,12 @@ function successExit(payload: { message: string; session_id: string }) {
|
||||
}
|
||||
|
||||
async function waitForCalls(mockFn: { mock: { calls: unknown[][] } }, count: number) {
|
||||
for (let i = 0; i < 50; i += 1) {
|
||||
if (mockFn.mock.calls.length >= count) {
|
||||
return;
|
||||
}
|
||||
await sleep(0);
|
||||
}
|
||||
throw new Error(`Expected ${count} calls, got ${mockFn.mock.calls.length}`);
|
||||
await vi.waitFor(
|
||||
() => {
|
||||
expect(mockFn.mock.calls.length).toBeGreaterThanOrEqual(count);
|
||||
},
|
||||
{ timeout: 2_000, interval: 5 },
|
||||
);
|
||||
}
|
||||
|
||||
describe("runClaudeCliAgent", () => {
|
||||
|
||||
Reference in New Issue
Block a user