test: dedupe agent create event mock reads · openclaw/openclaw@85f8944
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
File tree
src/gateway/server-methods
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,6 +42,10 @@ vi.mock("../../tasks/detached-task-runtime.js", () => ({
|
42 | 42 | |
43 | 43 | import { agentHandlers } from "./agent.js"; |
44 | 44 | |
| 45 | +function firstMockCall<T extends readonly unknown[]>(mock: { mock: { calls: readonly T[] } }) { |
| 46 | +return mock.mock.calls[0]; |
| 47 | +} |
| 48 | + |
45 | 49 | describe("agent handler session create events", () => { |
46 | 50 | let tempDir: string; |
47 | 51 | let storePath: string; |
@@ -89,7 +93,7 @@ describe("agent handler session create events", () => {
|
89 | 93 | req: { id: "req-agent-create-event" } as never, |
90 | 94 | }); |
91 | 95 | |
92 | | -const responseCall = respond.mock.calls.at(0) as |
| 96 | +const responseCall = firstMockCall(respond) as |
93 | 97 | | [boolean, { status?: string; runId?: string }, unknown, { runId?: string }] |
94 | 98 | | undefined; |
95 | 99 | expect(responseCall?.[0]).toBe(true); |
@@ -99,7 +103,7 @@ describe("agent handler session create events", () => {
|
99 | 103 | expect(responseCall?.[3]?.runId).toBe("idem-agent-create-event"); |
100 | 104 | await vi.waitFor( |
101 | 105 | () => { |
102 | | -const call = broadcastToConnIds.mock.calls.at(0) as |
| 106 | +const call = firstMockCall(broadcastToConnIds) as |
103 | 107 | | [ |
104 | 108 | string, |
105 | 109 | { sessionKey?: string; reason?: string }, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。