test: guard qa lab session mock calls · openclaw/openclaw@f97815a
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,11 +26,19 @@ describe("qa suite runtime agent session helpers", () => {
|
26 | 26 | gatewayCall.mockReset(); |
27 | 27 | }); |
28 | 28 | |
| 29 | +function requireGatewayCall() { |
| 30 | +const [call] = gatewayCall.mock.calls; |
| 31 | +if (!call) { |
| 32 | +throw new Error("expected gateway call"); |
| 33 | +} |
| 34 | +return call; |
| 35 | +} |
| 36 | + |
29 | 37 | it("creates sessions and trims the returned key", async () => { |
30 | 38 | gatewayCall.mockResolvedValueOnce({ key: " session-1 " }); |
31 | 39 | |
32 | 40 | await expect(createSession(env, "Test Session")).resolves.toBe("session-1"); |
33 | | -const [method, params, options] = gatewayCall.mock.calls[0] ?? []; |
| 41 | +const [method, params, options] = requireGatewayCall(); |
34 | 42 | expect(method).toBe("sessions.create"); |
35 | 43 | expect(params).toEqual({ label: "Test Session" }); |
36 | 44 | expect(options?.timeoutMs).toBe(60_000); |
@@ -53,7 +61,7 @@ describe("qa suite runtime agent session helpers", () => {
|
53 | 61 | }); |
54 | 62 | |
55 | 63 | await expect(readSkillStatus(env)).resolves.toEqual([{ name: "alpha", eligible: true }]); |
56 | | -const [method, params, options] = gatewayCall.mock.calls[0] ?? []; |
| 64 | +const [method, params, options] = requireGatewayCall(); |
57 | 65 | expect(method).toBe("skills.status"); |
58 | 66 | expect(params).toEqual({ agentId: "qa" }); |
59 | 67 | expect(options?.timeoutMs).toBe(45_000); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。