test: check ACP retry calls

This commit is contained in:
Shakker
2026-05-11 17:56:21 +01:00
parent 1117964ed6
commit 013ef92034
2 changed files with 18 additions and 6 deletions

View File

@@ -115,7 +115,7 @@ async function expectOversizedPromptRejected(params: { sessionId: string; text:
await expect(agent.prompt(createPromptRequest(params.sessionId, params.text))).rejects.toThrow(
/maximum allowed size/i,
);
expect(request).not.toHaveBeenCalledWith("chat.send", expect.anything(), expect.anything());
expect(request.mock.calls.some(([method]) => method === "chat.send")).toBe(false);
const session = sessionStore.getSession(params.sessionId);
expect(session?.activeRunId).toBeNull();
expect(session?.abortController).toBeNull();
@@ -727,7 +727,7 @@ describe("acp setSessionConfigOption bridge behavior", () => {
);
expect(Array.isArray(result.configOptions)).toBe(true);
expect(request).not.toHaveBeenCalledWith("sessions.patch", expect.anything());
expect(request.mock.calls.some(([method]) => method === "sessions.patch")).toBe(false);
sessionStore.clearAllSessionsForTest();
});

View File

@@ -227,17 +227,19 @@ describe("acp translator stop reason mapping", () => {
it("rechecks accepted prompts at the disconnect deadline after reconnect timeout", async () => {
vi.useFakeTimers();
try {
let chatRunId: string | undefined;
const agentWaitParams: Array<Record<string, unknown> | undefined> = [];
let waitCount = 0;
const request = vi.fn(async (method: string, params?: Record<string, unknown>) => {
if (method === "chat.send") {
const runId = params?.idempotencyKey;
expect(typeof runId).toBe("string");
chatRunId = runId;
return {};
}
if (method === "agent.wait") {
waitCount += 1;
expect(params).toEqual({
runId: expect.any(String),
timeoutMs: 0,
});
agentWaitParams.push(params);
return waitCount === 1 ? { status: "timeout" } : { status: "ok" };
}
return {};
@@ -256,6 +258,16 @@ describe("acp translator stop reason mapping", () => {
await vi.advanceTimersByTimeAsync(1);
await expect(promptPromise).resolves.toEqual({ stopReason: "end_turn" });
expect(agentWaitParams).toEqual([
{
runId: requireValue(chatRunId, "chat.send run id"),
timeoutMs: 0,
},
{
runId: requireValue(chatRunId, "chat.send run id"),
timeoutMs: 0,
},
]);
} finally {
vi.useRealTimers();
}