test: guard whatsapp mock calls · openclaw/openclaw@b42227e
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -917,7 +917,7 @@ describe("whatsapp inbound dispatch", () => {
|
917 | 917 | replyKind: "final", |
918 | 918 | conversationId: "+1000", |
919 | 919 | }); |
920 | | -expect(warnMock.mock.calls[0]?.[1]).toBe("auto-reply was not accepted by WhatsApp provider"); |
| 920 | +expect(warnMock.mock.calls.at(0)?.[1]).toBe("auto-reply was not accepted by WhatsApp provider"); |
921 | 921 | }); |
922 | 922 | |
923 | 923 | it("returns true for tool-only media turns after delivering media", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -201,7 +201,7 @@ function makeRemoveAckAfterReplyParams() {
|
201 | 201 | } |
202 | 202 | |
203 | 203 | function firstTranscriptionContext(): Record<string, unknown> { |
204 | | -const call = transcribeFirstAudioMock.mock.calls[0]?.[0] as |
| 204 | +const call = transcribeFirstAudioMock.mock.calls.at(0)?.[0] as |
205 | 205 | | { ctx?: Record<string, unknown> } |
206 | 206 | | undefined; |
207 | 207 | if (!call?.ctx) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -194,7 +194,7 @@ describe("whatsapp setup wizard", () => {
|
194 | 194 | forceAllowFrom: true, |
195 | 195 | }); |
196 | 196 | |
197 | | -const prompt = harness.text.mock.calls[0]?.[0] as |
| 197 | +const prompt = harness.text.mock.calls.at(0)?.[0] as |
198 | 198 | | { validate?: (value: string) => string | undefined } |
199 | 199 | | undefined; |
200 | 200 | if (!prompt?.validate) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -93,7 +93,7 @@ describe("WhatsAppConnectionController", () => {
|
93 | 93 | |
94 | 94 | expect(createListener).not.toHaveBeenCalled(); |
95 | 95 | expect(sock.end).toHaveBeenCalledOnce(); |
96 | | -const closeError = sock.end.mock.calls[0]?.[0] as Error | undefined; |
| 96 | +const closeError = sock.end.mock.calls.at(0)?.[0] as Error | undefined; |
97 | 97 | expect(closeError).toBeInstanceOf(Error); |
98 | 98 | expect(closeError?.message).toBe("OpenClaw WhatsApp socket close"); |
99 | 99 | expect(sock.ws.close).not.toHaveBeenCalled(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -153,7 +153,7 @@ async function waitForMessage(onMessage: ReturnType<typeof vi.fn>) {
|
153 | 153 | interval: 1, |
154 | 154 | timeout: 250, |
155 | 155 | }); |
156 | | -return onMessage.mock.calls[0][0]; |
| 156 | +return onMessage.mock.calls.at(0)?.[0]; |
157 | 157 | } |
158 | 158 | |
159 | 159 | function requireMediaPath(value: unknown): string { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -267,7 +267,7 @@ describe("web monitor inbox", () => {
|
267 | 267 | expect(inbound.groupSubject).toBe("Recovered Group"); |
268 | 268 | expect(inbound.senderE164).toBe("+444"); |
269 | 269 | expect(inbound.chatType).toBe("group"); |
270 | | -expect(onMessage.mock.calls[0]?.[0].groupParticipants).toBeUndefined(); |
| 270 | +expect(onMessage.mock.calls.at(0)?.[0].groupParticipants).toBeUndefined(); |
271 | 271 | |
272 | 272 | await second.listener.close(); |
273 | 273 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -272,7 +272,7 @@ export function buildNotifyMessageUpsert(params: {
|
272 | 272 | |
273 | 273 | export function expectPairingPromptSent(sock: MockSock, jid: string, senderE164: string) { |
274 | 274 | expect(sock.sendMessage).toHaveBeenCalledTimes(1); |
275 | | -const sendCall = sock.sendMessage.mock.calls[0]; |
| 275 | +const sendCall = sock.sendMessage.mock.calls.at(0); |
276 | 276 | expect(sendCall?.[0]).toBe(jid); |
277 | 277 | expectInboxPairingReplyText((sendCall?.[1] as { text?: string } | undefined)?.text ?? "", { |
278 | 278 | channel: "whatsapp", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -298,7 +298,7 @@ describe("web outbound", () => {
|
298 | 298 | }); |
299 | 299 | |
300 | 300 | expect(hoisted.runFfmpeg).toHaveBeenCalledTimes(1); |
301 | | -const ffmpegArgs = hoisted.runFfmpeg.mock.calls[0]?.[0] as string[] | undefined; |
| 301 | +const ffmpegArgs = hoisted.runFfmpeg.mock.calls.at(0)?.[0] as string[] | undefined; |
302 | 302 | expect(ffmpegArgs?.slice(0, 5)).toEqual(["-hide_banner", "-loglevel", "error", "-y", "-i"]); |
303 | 303 | expect(ffmpegArgs?.[5]).toContain(`/input.${media.name}`); |
304 | 304 | expect(ffmpegArgs?.slice(6, -1)).toEqual([ |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。