test: guard messaging extension mock calls · openclaw/openclaw@22667fb
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -264,7 +264,7 @@ describe("media-chunked: ChunkedMediaApi.uploadChunked", () => {
|
264 | 264 | |
265 | 265 | // Progress callback hit 3 times with monotonically-increasing counts. |
266 | 266 | expect(onProgress).toHaveBeenCalledTimes(3); |
267 | | -const last = onProgress.mock.calls[2][0]; |
| 267 | +const last = onProgress.mock.calls.at(2)?.[0]; |
268 | 268 | expect(last.completedParts).toBe(3); |
269 | 269 | expect(last.totalParts).toBe(3); |
270 | 270 | expect(last.uploadedBytes).toBe(FIXTURE_BUFFER.length); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -77,6 +77,6 @@ describe("trySlashCommand", () => {
|
77 | 77 | expect(result).toBe("handled"); |
78 | 78 | expect(writes).toHaveLength(1); |
79 | 79 | expect(qqbot?.streaming).toBe(true); |
80 | | -expect(vi.mocked(sendText).mock.calls[0]?.[1]).toContain("已开启"); |
| 80 | +expect(vi.mocked(sendText).mock.calls.at(0)?.[1]).toContain("已开启"); |
81 | 81 | }); |
82 | 82 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -202,7 +202,7 @@ describe("dispatchOutbound", () => {
|
202 | 202 | accountId: "qq-main", |
203 | 203 | }); |
204 | 204 | expect(audioFileToSilkBase64Mock).toHaveBeenCalledWith("/tmp/openclaw-qqbot/tts.wav"); |
205 | | -const sentMedia = sendMediaMock.mock.calls[0]?.[0] as |
| 205 | +const sentMedia = sendMediaMock.mock.calls.at(0)?.[0] as |
206 | 206 | | { kind?: string; source?: unknown; msgId?: string; ttsText?: string } |
207 | 207 | | undefined; |
208 | 208 | expect(sentMedia?.kind).toBe("voice"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -87,7 +87,7 @@ describe("Synology channel wiring integration", () => {
|
87 | 87 | ); |
88 | 88 | expect(registerPluginHttpRouteMock).toHaveBeenCalledTimes(1); |
89 | 89 | |
90 | | -const firstCall = registerPluginHttpRouteMock.mock.calls[0]; |
| 90 | +const firstCall = registerPluginHttpRouteMock.mock.calls.at(0); |
91 | 91 | if (!firstCall) { |
92 | 92 | throw new Error("Expected registerPluginHttpRoute to be called"); |
93 | 93 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -28,7 +28,7 @@ function countMatching<T>(items: readonly T[], predicate: (item: T) => boolean):
|
28 | 28 | |
29 | 29 | function deliveredMessage(deliver: ReturnType<typeof vi.fn>) { |
30 | 30 | expect(deliver).toHaveBeenCalledTimes(1); |
31 | | -const message = deliver.mock.calls[0]?.[0] as |
| 31 | +const message = deliver.mock.calls.at(0)?.[0] as |
32 | 32 | | { |
33 | 33 | accountId?: unknown; |
34 | 34 | body?: unknown; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -99,7 +99,7 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
|
99 | 99 | |
100 | 100 | expect(ctx?.ctxPayload.ReplyToBody).toBe("parent"); |
101 | 101 | expect(buildChannelTurnContextMock).toHaveBeenCalledOnce(); |
102 | | -const [turnOptions] = buildChannelTurnContextMock.mock.calls[0] ?? []; |
| 102 | +const [turnOptions] = buildChannelTurnContextMock.mock.calls.at(0) ?? []; |
103 | 103 | expect(turnOptions?.channel).toBe("telegram"); |
104 | 104 | expect(turnOptions?.from).toBe("telegram:1234"); |
105 | 105 | expect(turnOptions?.message.rawBody).toBe("hello"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -146,7 +146,7 @@ describe("buildTelegramMessageContext reactions", () => {
|
146 | 146 | expect(controller.setQueued).toHaveBeenCalledTimes(1); |
147 | 147 | expect(createStatusReactionController).toHaveBeenCalledTimes(1); |
148 | 148 | |
149 | | -const params = createStatusReactionController.mock.calls[0]?.[0]; |
| 149 | +const params = createStatusReactionController.mock.calls.at(0)?.[0]; |
150 | 150 | expect(params?.initialEmoji).toBe("👀"); |
151 | 151 | expect(params?.emojis?.done).toBe("✅"); |
152 | 152 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -68,7 +68,7 @@ async function buildForumTopicMessageContext(accountId?: string) {
|
68 | 68 | function expectRouteArgs(): Record<string, unknown> { |
69 | 69 | expect(resolveTelegramConversationRouteMock).toHaveBeenCalledTimes(1); |
70 | 70 | return ( |
71 | | -resolveTelegramConversationRouteMock.mock.calls[0] as unknown as [Record<string, unknown>] |
| 71 | +resolveTelegramConversationRouteMock.mock.calls.at(0) as unknown as [Record<string, unknown>] |
72 | 72 | )[0]; |
73 | 73 | } |
74 | 74 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,7 +57,7 @@ export async function waitForRegisteredCommands(
|
57 | 57 | await vi.waitFor(() => { |
58 | 58 | expect(setMyCommands).toHaveBeenCalled(); |
59 | 59 | }); |
60 | | -return setMyCommands.mock.calls[0]?.[0] as RegisteredCommand[]; |
| 60 | +return setMyCommands.mock.calls.at(0)?.[0] as RegisteredCommand[]; |
61 | 61 | } |
62 | 62 | |
63 | 63 | export function resetNativeCommandMenuMocks() { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -222,7 +222,7 @@ describe("createTelegramBot command menu", () => {
|
222 | 222 | |
223 | 223 | await commandsSynced; |
224 | 224 | |
225 | | -const registered = setMyCommandsSpy.mock.calls[0]?.[0] as Array<{ |
| 225 | +const registered = setMyCommandsSpy.mock.calls.at(0)?.[0] as Array<{ |
226 | 226 | command: string; |
227 | 227 | description: string; |
228 | 228 | }>; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。