mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-19 01:04:45 +00:00
test: check ACP retry calls
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user