test: check ACP retry calls · openclaw/openclaw@013ef92
shakkernerd
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -115,7 +115,7 @@ async function expectOversizedPromptRejected(params: { sessionId: string; text:
|
115 | 115 | await expect(agent.prompt(createPromptRequest(params.sessionId, params.text))).rejects.toThrow( |
116 | 116 | /maximum allowed size/i, |
117 | 117 | ); |
118 | | -expect(request).not.toHaveBeenCalledWith("chat.send", expect.anything(), expect.anything()); |
| 118 | +expect(request.mock.calls.some(([method]) => method === "chat.send")).toBe(false); |
119 | 119 | const session = sessionStore.getSession(params.sessionId); |
120 | 120 | expect(session?.activeRunId).toBeNull(); |
121 | 121 | expect(session?.abortController).toBeNull(); |
@@ -727,7 +727,7 @@ describe("acp setSessionConfigOption bridge behavior", () => {
|
727 | 727 | ); |
728 | 728 | expect(Array.isArray(result.configOptions)).toBe(true); |
729 | 729 | |
730 | | -expect(request).not.toHaveBeenCalledWith("sessions.patch", expect.anything()); |
| 730 | +expect(request.mock.calls.some(([method]) => method === "sessions.patch")).toBe(false); |
731 | 731 | |
732 | 732 | sessionStore.clearAllSessionsForTest(); |
733 | 733 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -227,17 +227,19 @@ describe("acp translator stop reason mapping", () => {
|
227 | 227 | it("rechecks accepted prompts at the disconnect deadline after reconnect timeout", async () => { |
228 | 228 | vi.useFakeTimers(); |
229 | 229 | try { |
| 230 | +let chatRunId: string | undefined; |
| 231 | +const agentWaitParams: Array<Record<string, unknown> | undefined> = []; |
230 | 232 | let waitCount = 0; |
231 | 233 | const request = vi.fn(async (method: string, params?: Record<string, unknown>) => { |
232 | 234 | if (method === "chat.send") { |
| 235 | +const runId = params?.idempotencyKey; |
| 236 | +expect(typeof runId).toBe("string"); |
| 237 | +chatRunId = runId; |
233 | 238 | return {}; |
234 | 239 | } |
235 | 240 | if (method === "agent.wait") { |
236 | 241 | waitCount += 1; |
237 | | -expect(params).toEqual({ |
238 | | -runId: expect.any(String), |
239 | | -timeoutMs: 0, |
240 | | -}); |
| 242 | +agentWaitParams.push(params); |
241 | 243 | return waitCount === 1 ? { status: "timeout" } : { status: "ok" }; |
242 | 244 | } |
243 | 245 | return {}; |
@@ -256,6 +258,16 @@ describe("acp translator stop reason mapping", () => {
|
256 | 258 | |
257 | 259 | await vi.advanceTimersByTimeAsync(1); |
258 | 260 | await expect(promptPromise).resolves.toEqual({ stopReason: "end_turn" }); |
| 261 | +expect(agentWaitParams).toEqual([ |
| 262 | +{ |
| 263 | +runId: requireValue(chatRunId, "chat.send run id"), |
| 264 | +timeoutMs: 0, |
| 265 | +}, |
| 266 | +{ |
| 267 | +runId: requireValue(chatRunId, "chat.send run id"), |
| 268 | +timeoutMs: 0, |
| 269 | +}, |
| 270 | +]); |
259 | 271 | } finally { |
260 | 272 | vi.useRealTimers(); |
261 | 273 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。