test: guard agent runtime mock calls

This commit is contained in:
Peter Steinberger
2026-05-12 08:52:32 +01:00
parent 96288dd19c
commit cb059e4006
5 changed files with 5 additions and 5 deletions

View File

@@ -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");
}

View File

@@ -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,
]);

View File

@@ -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");

View File

@@ -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}`);

View File

@@ -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");