Skip to content

Commit 22667fb

Browse files
committed
test: guard messaging extension mock calls
1 parent 43332ce commit 22667fb

18 files changed

Lines changed: 21 additions & 18 deletions

extensions/qqbot/src/engine/api/media-chunked.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe("media-chunked: ChunkedMediaApi.uploadChunked", () => {
264264

265265
// Progress callback hit 3 times with monotonically-increasing counts.
266266
expect(onProgress).toHaveBeenCalledTimes(3);
267-
const last = onProgress.mock.calls[2][0];
267+
const last = onProgress.mock.calls.at(2)?.[0];
268268
expect(last.completedParts).toBe(3);
269269
expect(last.totalParts).toBe(3);
270270
expect(last.uploadedBytes).toBe(FIXTURE_BUFFER.length);

extensions/qqbot/src/engine/commands/slash-command-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ describe("trySlashCommand", () => {
7777
expect(result).toBe("handled");
7878
expect(writes).toHaveLength(1);
7979
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("已开启");
8181
});
8282
});

extensions/qqbot/src/engine/gateway/outbound-dispatch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe("dispatchOutbound", () => {
202202
accountId: "qq-main",
203203
});
204204
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
206206
| { kind?: string; source?: unknown; msgId?: string; ttsText?: string }
207207
| undefined;
208208
expect(sentMedia?.kind).toBe("voice");

extensions/synology-chat/src/channel.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe("Synology channel wiring integration", () => {
8787
);
8888
expect(registerPluginHttpRouteMock).toHaveBeenCalledTimes(1);
8989

90-
const firstCall = registerPluginHttpRouteMock.mock.calls[0];
90+
const firstCall = registerPluginHttpRouteMock.mock.calls.at(0);
9191
if (!firstCall) {
9292
throw new Error("Expected registerPluginHttpRoute to be called");
9393
}

extensions/synology-chat/src/webhook-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function countMatching<T>(items: readonly T[], predicate: (item: T) => boolean):
2828

2929
function deliveredMessage(deliver: ReturnType<typeof vi.fn>) {
3030
expect(deliver).toHaveBeenCalledTimes(1);
31-
const message = deliver.mock.calls[0]?.[0] as
31+
const message = deliver.mock.calls.at(0)?.[0] as
3232
| {
3333
accountId?: unknown;
3434
body?: unknown;

extensions/telegram/src/bot-message-context.dm-topic-threadid.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe("buildTelegramMessageContext DM topic threadId in deliveryContext (#889
9999

100100
expect(ctx?.ctxPayload.ReplyToBody).toBe("parent");
101101
expect(buildChannelTurnContextMock).toHaveBeenCalledOnce();
102-
const [turnOptions] = buildChannelTurnContextMock.mock.calls[0] ?? [];
102+
const [turnOptions] = buildChannelTurnContextMock.mock.calls.at(0) ?? [];
103103
expect(turnOptions?.channel).toBe("telegram");
104104
expect(turnOptions?.from).toBe("telegram:1234");
105105
expect(turnOptions?.message.rawBody).toBe("hello");

extensions/telegram/src/bot-message-context.reactions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe("buildTelegramMessageContext reactions", () => {
146146
expect(controller.setQueued).toHaveBeenCalledTimes(1);
147147
expect(createStatusReactionController).toHaveBeenCalledTimes(1);
148148

149-
const params = createStatusReactionController.mock.calls[0]?.[0];
149+
const params = createStatusReactionController.mock.calls.at(0)?.[0];
150150
expect(params?.initialEmoji).toBe("👀");
151151
expect(params?.emojis?.done).toBe("✅");
152152

extensions/telegram/src/bot-message-context.thread-binding.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function buildForumTopicMessageContext(accountId?: string) {
6868
function expectRouteArgs(): Record<string, unknown> {
6969
expect(resolveTelegramConversationRouteMock).toHaveBeenCalledTimes(1);
7070
return (
71-
resolveTelegramConversationRouteMock.mock.calls[0] as unknown as [Record<string, unknown>]
71+
resolveTelegramConversationRouteMock.mock.calls.at(0) as unknown as [Record<string, unknown>]
7272
)[0];
7373
}
7474

extensions/telegram/src/bot-native-commands.menu-test-support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function waitForRegisteredCommands(
5757
await vi.waitFor(() => {
5858
expect(setMyCommands).toHaveBeenCalled();
5959
});
60-
return setMyCommands.mock.calls[0]?.[0] as RegisteredCommand[];
60+
return setMyCommands.mock.calls.at(0)?.[0] as RegisteredCommand[];
6161
}
6262

6363
export function resetNativeCommandMenuMocks() {

extensions/telegram/src/bot.command-menu.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ describe("createTelegramBot command menu", () => {
222222

223223
await commandsSynced;
224224

225-
const registered = setMyCommandsSpy.mock.calls[0]?.[0] as Array<{
225+
const registered = setMyCommandsSpy.mock.calls.at(0)?.[0] as Array<{
226226
command: string;
227227
description: string;
228228
}>;

0 commit comments

Comments
 (0)