test: guard extension one-hit mock calls · openclaw/openclaw@a765668
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -87,7 +87,7 @@ describe("canvas CLI", () => {
|
87 | 87 | expect(writtenFile.filePath).toMatch(/openclaw-canvas-snapshot-.*\.png$/); |
88 | 88 | expect(writtenFile.base64).toBe("aGk="); |
89 | 89 | expect(runtime.log).toHaveBeenCalledTimes(1); |
90 | | -const mediaMessage = runtime.log.mock.calls[0]?.[0]; |
| 90 | +const mediaMessage = runtime.log.mock.calls.at(0)?.[0]; |
91 | 91 | expect(mediaMessage?.startsWith("MEDIA:")).toBe(true); |
92 | 92 | expect(mediaMessage?.endsWith(".png")).toBe(true); |
93 | 93 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -83,7 +83,7 @@ describe("Canvas tool", () => {
|
83 | 83 | await tool.execute("tool-call-1", { action: "snapshot" }); |
84 | 84 | |
85 | 85 | expect(mocks.imageResultFromFile).toHaveBeenCalledTimes(1); |
86 | | -const imageResultParams = mocks.imageResultFromFile.mock.calls[0]?.[0] as |
| 86 | +const imageResultParams = mocks.imageResultFromFile.mock.calls.at(0)?.[0] as |
87 | 87 | | { |
88 | 88 | label?: string; |
89 | 89 | path?: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -120,7 +120,7 @@ describe("Codex app-server dynamic tool schema boundary contract", () => {
|
120 | 120 | }); |
121 | 121 | |
122 | 122 | expect(request).toHaveBeenCalledTimes(1); |
123 | | -const [method, payload] = request.mock.calls[0] ?? []; |
| 123 | +const [method, payload] = request.mock.calls.at(0) ?? []; |
124 | 124 | if (method !== "thread/start") { |
125 | 125 | throw new Error(`expected thread/start request, got ${method}`); |
126 | 126 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,7 @@ function expectFirstBlockReplyText(params: EmbeddedRunAttemptParams): string {
|
15 | 15 | if (onBlockReply === undefined) { |
16 | 16 | throw new Error("Expected onBlockReply callback"); |
17 | 17 | } |
18 | | -const payload = vi.mocked(onBlockReply).mock.calls[0]?.[0]; |
| 18 | +const payload = vi.mocked(onBlockReply).mock.calls.at(0)?.[0]; |
19 | 19 | if (typeof payload?.text !== "string") { |
20 | 20 | throw new Error("Expected first block reply text"); |
21 | 21 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -484,7 +484,7 @@ describe("device-pair /pair qr", () => {
|
484 | 484 | const text = requireText(result); |
485 | 485 | |
486 | 486 | expect(sendMessage).toHaveBeenCalledTimes(1); |
487 | | -const [target, caption, opts] = sendMessage.mock.calls[0] as [ |
| 487 | +const [target, caption, opts] = sendMessage.mock.calls.at(0) as [ |
488 | 488 | string, |
489 | 489 | string, |
490 | 490 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -301,7 +301,7 @@ describe("broadcast dispatch", () => {
|
301 | 301 | }, |
302 | 302 | ]); |
303 | 303 | expect(mockCreateFeishuReplyDispatcher).toHaveBeenCalledTimes(1); |
304 | | -const dispatcherParams = mockCreateFeishuReplyDispatcher.mock.calls[0]?.[0] as |
| 304 | +const dispatcherParams = mockCreateFeishuReplyDispatcher.mock.calls.at(0)?.[0] as |
305 | 305 | | { agentId?: string } |
306 | 306 | | undefined; |
307 | 307 | expect(dispatcherParams?.agentId).toBe("main"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -973,7 +973,7 @@ describe("handleFeishuMessage command authorization", () => {
|
973 | 973 | await dispatchMessage({ cfg, event }); |
974 | 974 | const after = Date.now(); |
975 | 975 | |
976 | | -const call = mockFinalizeInboundContext.mock.calls[0]?.[0] as { Timestamp: number }; |
| 976 | +const call = mockFinalizeInboundContext.mock.calls.at(0)?.[0] as { Timestamp: number }; |
977 | 977 | expect(call.Timestamp).toBeGreaterThanOrEqual(before); |
978 | 978 | expect(call.Timestamp).toBeLessThanOrEqual(after); |
979 | 979 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -77,7 +77,7 @@ describe("feishu quick-action launcher", () => {
|
77 | 77 | |
78 | 78 | expect(handled).toBe(true); |
79 | 79 | expect(sendCardFeishuMock).toHaveBeenCalledTimes(1); |
80 | | -const sendArgs = sendCardFeishuMock.mock.calls[0]?.[0] as |
| 80 | +const sendArgs = sendCardFeishuMock.mock.calls.at(0)?.[0] as |
81 | 81 | | { accountId?: string; card?: unknown; cfg?: ClawdbotConfig; to?: string } |
82 | 82 | | undefined; |
83 | 83 | expect(Object.keys(sendArgs ?? {}).toSorted()).toEqual(["accountId", "card", "cfg", "to"]); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -161,7 +161,7 @@ describe("feishu setup wizard", () => {
|
161 | 161 | |
162 | 162 | expect(initAppRegistrationMock).toHaveBeenCalledWith("lark"); |
163 | 163 | expect(beginAppRegistrationMock).toHaveBeenCalledWith("lark"); |
164 | | -const [pollOptions] = pollAppRegistrationMock.mock.calls[0] ?? []; |
| 164 | +const [pollOptions] = pollAppRegistrationMock.mock.calls.at(0) ?? []; |
165 | 165 | expect(pollOptions?.deviceCode).toBe("device-code"); |
166 | 166 | expect(pollOptions?.initialDomain).toBe("lark"); |
167 | 167 | expect(pollOptions?.tp).toBe("ob_cli_app"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -442,7 +442,7 @@ export async function setupFeishuLifecycleHandler(params: {
|
442 | 442 | }); |
443 | 443 | |
444 | 444 | const handlers: Record<string, (data: unknown) => Promise<void>> = {}; |
445 | | -for (const [key, value] of Object.entries(register.mock.calls[0]?.[0] ?? {})) { |
| 445 | +for (const [key, value] of Object.entries(register.mock.calls.at(0)?.[0] ?? {})) { |
446 | 446 | handlers[key] = value as (data: unknown) => Promise<void>; |
447 | 447 | } |
448 | 448 | const handler = handlers[params.handlerKey]; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。