mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-22 14:17:14 +00:00
test: guard agent runtime mock calls
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
]);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user