From cb059e40065a65fd93ea22caf8bee0eb215868a9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 12 May 2026 08:52:32 +0100 Subject: [PATCH] test: guard agent runtime mock calls --- src/agents/openclaw-owned-tool-runtime-contract.test.ts | 2 +- src/agents/outcome-fallback-runtime-contract.test.ts | 2 +- src/agents/pi-bundle-lsp-runtime.test.ts | 2 +- .../pi-embedded-runner.anthropic-tool-replay.live.test.ts | 2 +- ...nner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/agents/openclaw-owned-tool-runtime-contract.test.ts b/src/agents/openclaw-owned-tool-runtime-contract.test.ts index 99ad558c133..3e73995b71c 100644 --- a/src/agents/openclaw-owned-tool-runtime-contract.test.ts +++ b/src/agents/openclaw-owned-tool-runtime-contract.test.ts @@ -95,7 +95,7 @@ async function waitForAfterToolCall(hooks: { await vi.waitFor(() => { expect(hooks.afterToolCall).toHaveBeenCalledTimes(1); }); - const call = hooks.afterToolCall.mock.calls[0]; + const call = hooks.afterToolCall.mock.calls.at(0); if (!call) { throw new Error("Expected afterToolCall hook call"); } diff --git a/src/agents/outcome-fallback-runtime-contract.test.ts b/src/agents/outcome-fallback-runtime-contract.test.ts index 8a20b238150..d549ad755f8 100644 --- a/src/agents/outcome-fallback-runtime-contract.test.ts +++ b/src/agents/outcome-fallback-runtime-contract.test.ts @@ -68,7 +68,7 @@ describe("Outcome/fallback runtime contract - Pi fallback classifier", () => { expect(result.result).toBe(fallback); expect(run).toHaveBeenCalledTimes(2); - expect(run.mock.calls[1]).toEqual([ + expect(run.mock.calls.at(1)).toEqual([ OUTCOME_FALLBACK_RUNTIME_CONTRACT.fallbackProvider, OUTCOME_FALLBACK_RUNTIME_CONTRACT.fallbackModel, ]); diff --git a/src/agents/pi-bundle-lsp-runtime.test.ts b/src/agents/pi-bundle-lsp-runtime.test.ts index 7d67bfb34bd..7ba6789ec61 100644 --- a/src/agents/pi-bundle-lsp-runtime.test.ts +++ b/src/agents/pi-bundle-lsp-runtime.test.ts @@ -106,7 +106,7 @@ describe("bundle LSP runtime", () => { const runtime = await createBundleLspToolRuntime({ workspaceDir: "/tmp/workspace" }); expect(spawnMock).toHaveBeenCalledTimes(1); - const [command, args, options] = spawnMock.mock.calls[0] ?? []; + const [command, args, options] = spawnMock.mock.calls.at(0) ?? []; expect(command).toBe("typescript-language-server"); expect(args).toEqual(["--stdio"]); expect(options?.detached).toBe(process.platform !== "win32"); diff --git a/src/agents/pi-embedded-runner.anthropic-tool-replay.live.test.ts b/src/agents/pi-embedded-runner.anthropic-tool-replay.live.test.ts index d2465d5e9f3..e4e5ff12e2c 100644 --- a/src/agents/pi-embedded-runner.anthropic-tool-replay.live.test.ts +++ b/src/agents/pi-embedded-runner.anthropic-tool-replay.live.test.ts @@ -172,7 +172,7 @@ describeLive("pi embedded anthropic replay sanitization (live)", () => { await Promise.resolve(wrapped(model as never, { messages } as never, {} as never)); expect(baseFn).toHaveBeenCalledTimes(1); - const seenMessages = (baseFn.mock.calls[0]?.[1] as { messages?: unknown[] })?.messages; + const seenMessages = (baseFn.mock.calls.at(0)?.[1] as { messages?: unknown[] })?.messages; expect(seenMessages).toEqual(messages); logLiveCache(`anthropic replay live model=${model.provider}/${model.id}`); diff --git a/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts b/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts index 28908cecdd0..6d5b2670dae 100644 --- a/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts +++ b/src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.e2e.test.ts @@ -1222,7 +1222,7 @@ describe("runEmbeddedPiAgent auth profile rotation", () => { expect(runEmbeddedAttemptMock).toHaveBeenCalledTimes(1); const attemptParams = requireRecord( - runEmbeddedAttemptMock.mock.calls[0]?.[0], + runEmbeddedAttemptMock.mock.calls.at(0)?.[0], "embedded attempt params", ); expect(attemptParams.authProfileId).toBe("openai-codex:work");