diff --git a/extensions/github-copilot/models.test.ts b/extensions/github-copilot/models.test.ts index 83b9711cb9e..a0c6a5c783d 100644 --- a/extensions/github-copilot/models.test.ts +++ b/extensions/github-copilot/models.test.ts @@ -491,7 +491,7 @@ describe("fetchCopilotModelCatalog", () => { }); expect(fetchImpl).toHaveBeenCalledTimes(1); - const [calledUrl, calledInit] = fetchImpl.mock.calls[0]; + const [calledUrl, calledInit] = fetchImpl.mock.calls.at(0) ?? []; expect(calledUrl).toBe("https://api.githubcopilot.com/models"); expect((calledInit as RequestInit).method).toBe("GET"); expect(((calledInit as RequestInit).headers as Record).Authorization).toBe( @@ -539,7 +539,7 @@ describe("fetchCopilotModelCatalog", () => { fetchImpl: fetchImpl as unknown as typeof fetch, }); - expect(fetchImpl.mock.calls[0][0]).toBe("https://api.githubcopilot.com/models"); + expect(fetchImpl.mock.calls.at(0)?.[0]).toBe("https://api.githubcopilot.com/models"); }); it("dedupes by id when API returns duplicates", async () => { diff --git a/extensions/google-meet/src/cli.test.ts b/extensions/google-meet/src/cli.test.ts index c0d5327bad3..946e36a549d 100644 --- a/extensions/google-meet/src/cli.test.ts +++ b/extensions/google-meet/src/cli.test.ts @@ -811,7 +811,7 @@ describe("google-meet CLI", () => { ], { from: "user" }, ); - const gatewayCall = callGatewayFromCli.mock.calls[0] as unknown as + const gatewayCall = callGatewayFromCli.mock.calls.at(0) as unknown as | [ string, { json?: boolean; timeout?: unknown }, @@ -1144,7 +1144,7 @@ describe("google-meet CLI", () => { expectFields(checks[0], { id: "oauth-config", ok: true }); expectFields(checks[1], { id: "oauth-token", ok: true }); expect(ensureRuntime).not.toHaveBeenCalled(); - const body = fetchMock.mock.calls[0]?.[1]?.body as URLSearchParams; + const body = fetchMock.mock.calls.at(0)?.[1]?.body as URLSearchParams; expect(body.get("grant_type")).toBe("refresh_token"); } finally { stdout.restore(); diff --git a/extensions/imessage/src/monitor.watch-subscribe-retry.test.ts b/extensions/imessage/src/monitor.watch-subscribe-retry.test.ts index 5137c93e156..7ac09882838 100644 --- a/extensions/imessage/src/monitor.watch-subscribe-retry.test.ts +++ b/extensions/imessage/src/monitor.watch-subscribe-retry.test.ts @@ -109,7 +109,7 @@ describe("monitorIMessageProvider watch.subscribe startup retry", () => { { timeoutMs: 10_000 }, ); expect(runtime.log).toHaveBeenCalledTimes(1); - expect(String(runtime.log.mock.calls[0][0])).toContain( + expect(String(runtime.log.mock.calls.at(0)?.[0])).toContain( "imessage: watch.subscribe startup failed (attempt 1/3): Error: imsg rpc timeout (watch.subscribe); retrying", ); expect( @@ -141,7 +141,7 @@ describe("monitorIMessageProvider watch.subscribe startup retry", () => { expect((monitorError as Error).message).toContain("imsg rpc timeout (watch.subscribe)"); expect(createIMessageRpcClientMock).toHaveBeenCalledTimes(3); expect(runtime.error).toHaveBeenCalledTimes(1); - expect(String(runtime.error.mock.calls[0][0])).toContain( + expect(String(runtime.error.mock.calls.at(0)?.[0])).toContain( "imessage: monitor failed: Error: imsg rpc timeout (watch.subscribe)", ); }); diff --git a/extensions/line/src/rich-menu.test.ts b/extensions/line/src/rich-menu.test.ts index 744a2f509a9..9ffa50978d0 100644 --- a/extensions/line/src/rich-menu.test.ts +++ b/extensions/line/src/rich-menu.test.ts @@ -266,7 +266,7 @@ describe("uploadRichMenuImage", () => { expect(MessagingApiBlobClientMock).toHaveBeenCalledWith({ channelAccessToken: "line-token" }); expect(setRichMenuImageMock).toHaveBeenCalledOnce(); - const [richMenuId, blob] = setRichMenuImageMock.mock.calls[0] ?? []; + const [richMenuId, blob] = setRichMenuImageMock.mock.calls.at(0) ?? []; expect(richMenuId).toBe("rich-menu-1"); expect(blob).toBeInstanceOf(Blob); expect((blob as Blob).type).toBe("image/png"); @@ -306,7 +306,7 @@ describe("uploadRichMenuImage", () => { }); expect(setRichMenuImageMock).toHaveBeenCalledOnce(); - const blob = setRichMenuImageMock.mock.calls[0]?.[1] as Blob; + const blob = setRichMenuImageMock.mock.calls.at(0)?.[1] as Blob; expect(blob.type).toBe("image/jpeg"); await expect(blob.arrayBuffer()).resolves.toEqual( imageBytes.buffer.slice(imageBytes.byteOffset, imageBytes.byteOffset + imageBytes.byteLength), diff --git a/extensions/llm-task/src/llm-task-tool.test.ts b/extensions/llm-task/src/llm-task-tool.test.ts index fd0ac1c8f33..c2d4676198a 100644 --- a/extensions/llm-task/src/llm-task-tool.test.ts +++ b/extensions/llm-task/src/llm-task-tool.test.ts @@ -88,7 +88,7 @@ function resetRunnerMocks() { async function executeEmbeddedRun(input: Record) { const tool = createLlmTaskTool(fakeApi()); await tool.execute("id", input); - return (runEmbeddedPiAgent as any).mock.calls[0]?.[0]; + return (runEmbeddedPiAgent as any).mock.calls.at(0)?.[0]; } describe("llm-task tool (json-only)", () => { @@ -238,7 +238,7 @@ describe("llm-task tool (json-only)", () => { await tool.execute("id", { prompt: "x", model: "gemini-flash" }); - const call = (runEmbeddedPiAgent as any).mock.calls[0]?.[0]; + const call = (runEmbeddedPiAgent as any).mock.calls.at(0)?.[0]; expect(call.provider).toBe("google"); expect(call.model).toBe("gemini-3-flash-preview"); }); diff --git a/extensions/matrix/src/matrix/draft-stream.test.ts b/extensions/matrix/src/matrix/draft-stream.test.ts index 0bcda3a43b4..47359d09990 100644 --- a/extensions/matrix/src/matrix/draft-stream.test.ts +++ b/extensions/matrix/src/matrix/draft-stream.test.ts @@ -349,7 +349,7 @@ describe("createMatrixDraftStream", () => { await stream.stop(); expect(sendMessageMock).toHaveBeenCalledTimes(1); - expect(sendMessageMock.mock.calls[0]?.[1]).toHaveProperty("org.matrix.msc4357.live"); + expect(sendMessageMock.mock.calls.at(0)?.[1]).toHaveProperty("org.matrix.msc4357.live"); }); it("finalizeLive clears the live marker at most once", async () => { @@ -367,7 +367,7 @@ describe("createMatrixDraftStream", () => { await stream.finalizeLive(); expect(sendMessageMock).toHaveBeenCalledTimes(2); - expect(sendMessageMock.mock.calls[1]?.[1]).not.toHaveProperty("org.matrix.msc4357.live"); + expect(sendMessageMock.mock.calls.at(1)?.[1]).not.toHaveProperty("org.matrix.msc4357.live"); }); it("marks live finalize failures for normal final delivery fallback", async () => { diff --git a/extensions/matrix/src/matrix/monitor/handler.thread-root-media.test.ts b/extensions/matrix/src/matrix/monitor/handler.thread-root-media.test.ts index d628c19a38a..41fc7960f6c 100644 --- a/extensions/matrix/src/matrix/monitor/handler.thread-root-media.test.ts +++ b/extensions/matrix/src/matrix/monitor/handler.thread-root-media.test.ts @@ -14,7 +14,7 @@ function requireRecord(value: unknown, label: string): Record { } function readFirstMockArg(fn: unknown): unknown { - return (fn as { mock: { calls: unknown[][] } }).mock.calls[0]?.[0]; + return (fn as { mock: { calls: unknown[][] } }).mock.calls.at(0)?.[0]; } describe("createMatrixRoomMessageHandler thread root media", () => { @@ -79,7 +79,7 @@ describe("createMatrixRoomMessageHandler thread root media", () => { expect(formatAgentEnvelope).toHaveBeenCalledTimes(1); const envelope = requireRecord( - formatAgentEnvelope.mock.calls[0]?.[0], + formatAgentEnvelope.mock.calls.at(0)?.[0], "format agent envelope params", ); expect(String(envelope.body)).toContain("replying"); diff --git a/extensions/matrix/src/matrix/sdk.test.ts b/extensions/matrix/src/matrix/sdk.test.ts index 2bfc1208413..f41a23d6b87 100644 --- a/extensions/matrix/src/matrix/sdk.test.ts +++ b/extensions/matrix/src/matrix/sdk.test.ts @@ -1678,7 +1678,7 @@ describe("MatrixClient crypto bootstrapping", () => { await client.start(); - const startOpts = matrixJsClient.startClient.mock.calls[0]?.[0] as + const startOpts = matrixJsClient.startClient.mock.calls.at(0)?.[0] as | { filter?: { getDefinition?: () => unknown } } | undefined; expect(startOpts?.filter?.getDefinition?.()).toEqual({ @@ -1703,7 +1703,7 @@ describe("MatrixClient crypto bootstrapping", () => { await client.start(); expect(databasesSpy).toHaveBeenCalled(); - const intervalCall = setIntervalSpy.mock.calls[0] as unknown[]; + const intervalCall = setIntervalSpy.mock.calls.at(0) as unknown[]; expect(intervalCall[0]).toBeTypeOf("function"); expect(intervalCall[1]).toBe(60_000); client.stop(); diff --git a/extensions/mattermost/src/mattermost/monitor.inbound-system-event.test.ts b/extensions/mattermost/src/mattermost/monitor.inbound-system-event.test.ts index 627e9a27615..1a49d5ba80b 100644 --- a/extensions/mattermost/src/mattermost/monitor.inbound-system-event.test.ts +++ b/extensions/mattermost/src/mattermost/monitor.inbound-system-event.test.ts @@ -414,7 +414,7 @@ describe("mattermost inbound user posts", () => { expect(mockState.enqueueSystemEvent).not.toHaveBeenCalled(); expect(mockState.dispatchReplyFromConfig).toHaveBeenCalledTimes(1); - const ctx = mockState.dispatchReplyFromConfig.mock.calls[0]?.[0].ctx; + const ctx = mockState.dispatchReplyFromConfig.mock.calls.at(0)?.[0].ctx; expect(ctx?.BodyForAgent).toBe("hello from mattermost"); expect(ctx?.ConversationLabel).toBe("Town Square id:chan-1"); expect(ctx?.MessageSid).toBe("post-1"); @@ -484,7 +484,7 @@ describe("mattermost inbound user posts", () => { await monitor; expect(runtimeCore.channel.session.recordInboundSession).toHaveBeenCalledTimes(1); - const [recordCall] = runtimeCore.channel.session.recordInboundSession.mock.calls[0] ?? []; + const [recordCall] = runtimeCore.channel.session.recordInboundSession.mock.calls.at(0) ?? []; expect(recordCall?.storePath).toBe("/tmp/openclaw-test-sessions.json"); expect(recordCall?.sessionKey).toBe("mattermost:default:channel:chan-1"); const updateLastRoute = recordCall?.updateLastRoute; diff --git a/extensions/mattermost/src/mattermost/monitor.test.ts b/extensions/mattermost/src/mattermost/monitor.test.ts index 51473b2a37e..db7f98747ce 100644 --- a/extensions/mattermost/src/mattermost/monitor.test.ts +++ b/extensions/mattermost/src/mattermost/monitor.test.ts @@ -114,7 +114,7 @@ describe("mattermost mention gating", () => { expect(decision.dropReason).toBeNull(); expect(decision.shouldRequireMention).toBe(false); expect(resolver).toHaveBeenCalledTimes(1); - const [resolverCall] = resolver.mock.calls[0] ?? []; + const [resolverCall] = resolver.mock.calls.at(0) ?? []; expect(resolverCall).toStrictEqual({ cfg, channel: "mattermost", @@ -493,7 +493,8 @@ describe("deliverMattermostReplyWithDraftPreview", () => { }); expect(updateMattermostPostSpy).toHaveBeenCalledTimes(1); - const [updateClient, updatePostId, updateParams] = updateMattermostPostSpy.mock.calls[0] ?? []; + const [updateClient, updatePostId, updateParams] = + updateMattermostPostSpy.mock.calls.at(0) ?? []; expect(updateClient).toBe(client); expect(updatePostId).toBe("preview-post-1"); expect(updateParams).toStrictEqual({ message: "Final answer" }); diff --git a/extensions/memory-core/src/cli.test.ts b/extensions/memory-core/src/cli.test.ts index 0a3684dfb74..95414167912 100644 --- a/extensions/memory-core/src/cli.test.ts +++ b/extensions/memory-core/src/cli.test.ts @@ -109,7 +109,7 @@ describe("memory cli", () => { const inactiveMemorySecretDiagnostic = "agents.defaults.memorySearch.remote.apiKey inactive"; // pragma: allowlist secret function expectCliSync(sync: ReturnType) { - const syncCall = sync.mock.calls[0]?.[0] as + const syncCall = sync.mock.calls.at(0)?.[0] as | { reason?: unknown; force?: unknown; progress?: unknown } | undefined; expect(syncCall?.reason).toBe("cli"); @@ -353,7 +353,7 @@ describe("memory cli", () => { await runMemoryCli(["status"]); - const secretRefsCall = resolveCommandSecretRefsViaGateway.mock.calls[0]?.[0] as + const secretRefsCall = resolveCommandSecretRefsViaGateway.mock.calls.at(0)?.[0] as | { config?: unknown; commandName?: unknown; targetIds?: unknown } | undefined; expect(secretRefsCall?.config).toBe(config); diff --git a/extensions/memory-core/src/dreaming-phases.test.ts b/extensions/memory-core/src/dreaming-phases.test.ts index a1f14a19121..d5ddd25277f 100644 --- a/extensions/memory-core/src/dreaming-phases.test.ts +++ b/extensions/memory-core/src/dreaming-phases.test.ts @@ -2498,7 +2498,7 @@ describe("memory-core dreaming phases", () => { }); expect(subagent.run).toHaveBeenCalledTimes(1); - const firstRun = subagent.run.mock.calls[0]?.[0]; + const firstRun = subagent.run.mock.calls.at(0)?.[0]; expect(firstRun?.message).toContain("Move backups to S3 Glacier."); expect(firstRun?.message).toContain("Keep retention at 365 days."); expect(firstRun?.model).toBe("anthropic/claude-sonnet-4-6"); @@ -2561,7 +2561,7 @@ describe("memory-core dreaming phases", () => { }); expect(subagent.run).toHaveBeenCalledTimes(1); - const firstRun = subagent.run.mock.calls[0]?.[0]; + const firstRun = subagent.run.mock.calls.at(0)?.[0]; expect(firstRun?.message).toContain("Move backups to S3 Glacier."); expect(firstRun?.message).toContain("Keep retention at 365 days."); expect(firstRun?.model).toBe("xai/grok-4.1-fast"); diff --git a/extensions/memory-core/src/memory/manager.watcher-config.test.ts b/extensions/memory-core/src/memory/manager.watcher-config.test.ts index fe62bf23df5..f25822f2c54 100644 --- a/extensions/memory-core/src/memory/manager.watcher-config.test.ts +++ b/extensions/memory-core/src/memory/manager.watcher-config.test.ts @@ -161,7 +161,7 @@ describe("memory watcher config", () => { await expectWatcherManager(cfg); expect(watchMock).toHaveBeenCalledTimes(1); - const [watchedPaths, options] = watchMock.mock.calls[0] as unknown as [ + const [watchedPaths, options] = watchMock.mock.calls.at(0) as unknown as [ string[], Record, ]; @@ -217,7 +217,7 @@ describe("memory watcher config", () => { await expectWatcherManager(cfg); expect(watchMock).toHaveBeenCalledTimes(1); - const [watchedPaths, options] = watchMock.mock.calls[0] as unknown as [ + const [watchedPaths, options] = watchMock.mock.calls.at(0) as unknown as [ string[], Record, ]; diff --git a/extensions/memory-core/src/memory/qmd-manager.test.ts b/extensions/memory-core/src/memory/qmd-manager.test.ts index 558fe60b798..85fe600cd8a 100644 --- a/extensions/memory-core/src/memory/qmd-manager.test.ts +++ b/extensions/memory-core/src/memory/qmd-manager.test.ts @@ -457,7 +457,7 @@ describe("QmdMemoryManager", () => { }; const initialUpdateCalls = spawnMock.mock.calls.filter((call) => call[1]?.[0] === "update"); expect(initialUpdateCalls).toHaveLength(0); - const [, watchOptions] = watchMock.mock.calls[0] as unknown as [ + const [, watchOptions] = watchMock.mock.calls.at(0) as unknown as [ string[], { ignored?: (watchPath: string) => boolean }, ]; @@ -3719,7 +3719,7 @@ describe("QmdMemoryManager", () => { const firstSync = first.manager.sync({ reason: "manual", force: true }); await vi.advanceTimersByTimeAsync(0); expect(embedChildren).toHaveLength(1); - const lockCall = withFileLockMock.mock.calls[0] as + const lockCall = withFileLockMock.mock.calls.at(0) as | [ string, { diff --git a/extensions/memory-wiki/src/gateway.test.ts b/extensions/memory-wiki/src/gateway.test.ts index 060244cd985..df7e563085e 100644 --- a/extensions/memory-wiki/src/gateway.test.ts +++ b/extensions/memory-wiki/src/gateway.test.ts @@ -92,13 +92,13 @@ function readGatewayMethodOptions( } function readRespondPayload(respond: { mock: { calls: Array> } }): unknown { - const call = respond.mock.calls[0]; + const call = respond.mock.calls.at(0); expect(call?.[0]).toBe(true); return call?.[1]; } function readRespondError(respond: { mock: { calls: Array> } }): unknown { - const call = respond.mock.calls[0]; + const call = respond.mock.calls.at(0); expect(call?.[0]).toBe(false); expect(call?.[1]).toBeUndefined(); return call?.[2]; diff --git a/extensions/minimax/image-generation-provider.test.ts b/extensions/minimax/image-generation-provider.test.ts index 02e3b27c62c..663a9d7a1f8 100644 --- a/extensions/minimax/image-generation-provider.test.ts +++ b/extensions/minimax/image-generation-provider.test.ts @@ -49,7 +49,7 @@ describe("minimax image-generation provider", () => { function expectImageGenerationUrl(fetchMock: ReturnType, url: string) { expect(fetchMock).toHaveBeenCalled(); - const [actualUrl, init] = fetchMock.mock.calls[0] as [string, RequestInit | undefined]; + const [actualUrl, init] = fetchMock.mock.calls.at(0) as [string, RequestInit | undefined]; expect(actualUrl).toBe(url); expect(init?.method).toBe("POST"); } @@ -83,7 +83,7 @@ describe("minimax image-generation provider", () => { }); expect(fetchMock).toHaveBeenCalledOnce(); - const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit]; + const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit]; expect(url).toBe("https://api.minimax.io/v1/image_generation"); expect(init.method).toBe("POST"); expect(init.body).toBe(