diff --git a/src/agents/tools/cron-tool.test.ts b/src/agents/tools/cron-tool.test.ts index b134d7d7f7c..0d895d95329 100644 --- a/src/agents/tools/cron-tool.test.ts +++ b/src/agents/tools/cron-tool.test.ts @@ -105,7 +105,7 @@ describe("cron tool", () => { }, }); - const call = callGatewayMock.mock.calls[0]?.[0] as { + const call = callGatewayMock.mock.calls.at(0)?.[0] as { params?: { delivery?: TestDelivery }; }; return call?.params?.delivery; @@ -534,7 +534,7 @@ describe("cron tool", () => { }, }); - const call = callGatewayMock.mock.calls[0]?.[0] as { + const call = callGatewayMock.mock.calls.at(0)?.[0] as { params?: { agentId?: unknown }; }; expect(call?.params?.agentId).toBeNull(); @@ -721,7 +721,7 @@ describe("cron tool", () => { }, }); - const call = callGatewayMock.mock.calls[0]?.[0] as { + const call = callGatewayMock.mock.calls.at(0)?.[0] as { method?: string; params?: { agentId?: string | null }; }; @@ -1066,7 +1066,7 @@ describe("cron tool", () => { name: "flat-name-should-be-ignored", }); - const call = callGatewayMock.mock.calls[0]?.[0] as { + const call = callGatewayMock.mock.calls.at(0)?.[0] as { params?: { name?: string; payload?: { text?: string } }; }; expect(call?.params?.name).toBe("nested-job"); diff --git a/src/agents/tools/sessions-spawn-tool.test.ts b/src/agents/tools/sessions-spawn-tool.test.ts index 0d539daa323..2bba41107b8 100644 --- a/src/agents/tools/sessions-spawn-tool.test.ts +++ b/src/agents/tools/sessions-spawn-tool.test.ts @@ -668,10 +668,8 @@ describe("sessions_spawn tool", () => { expect(spawnArgs.task).toBe("resume prior work"); const spawnContext = mockCallArg(hoisted.spawnSubagentDirectMock, 0, 1, "spawnSubagentDirect"); expect(spawnContext.agentSessionKey).toBe("agent:main:main"); - expect(hoisted.spawnSubagentDirectMock.mock.calls[0]?.[0]).not.toHaveProperty( - "resumeSessionId", - ); - expect(hoisted.spawnSubagentDirectMock.mock.calls[0]?.[0]).not.toHaveProperty("streamTo"); + expect(spawnArgs).not.toHaveProperty("resumeSessionId"); + expect(spawnArgs).not.toHaveProperty("streamTo"); expect(hoisted.spawnAcpDirectMock).not.toHaveBeenCalled(); }); @@ -717,10 +715,8 @@ describe("sessions_spawn tool", () => { expect(hoisted.spawnAcpDirectMock).not.toHaveBeenCalled(); const spawnArgs = mockCallArg(hoisted.spawnSubagentDirectMock, 0, 0, "spawnSubagentDirect"); expect(spawnArgs.task).toBe("analyze file"); - expect(hoisted.spawnSubagentDirectMock.mock.calls[0]?.[0]).not.toHaveProperty( - "resumeSessionId", - ); - expect(hoisted.spawnSubagentDirectMock.mock.calls[0]?.[0]).not.toHaveProperty("streamTo"); + expect(spawnArgs).not.toHaveProperty("resumeSessionId"); + expect(spawnArgs).not.toHaveProperty("streamTo"); }); it('treats model="default" as no explicit model override', async () => { diff --git a/src/agents/tools/video-generate-tool.test.ts b/src/agents/tools/video-generate-tool.test.ts index 19f6cc49b2e..28f3b2c7076 100644 --- a/src/agents/tools/video-generate-tool.test.ts +++ b/src/agents/tools/video-generate-tool.test.ts @@ -156,7 +156,7 @@ function resultDetails(result: { details?: unknown }): Record { } function firstMockCallArg(mock: { mock: { calls: unknown[][] } }): unknown { - const firstCall = mock.mock.calls[0]; + const firstCall = mock.mock.calls.at(0); if (!firstCall) { throw new Error("Expected first mock call"); } @@ -399,7 +399,7 @@ describe("createVideoGenerateTool", () => { }); expect((firstMockCallArg(generateSpy) as { timeoutMs?: number }).timeoutMs).toBe(180_000); - expect((generateSpy.mock.calls[1]?.[0] as { timeoutMs?: number }).timeoutMs).toBe(12_345); + expect((generateSpy.mock.calls.at(1)?.[0] as { timeoutMs?: number }).timeoutMs).toBe(12_345); expect(resultDetails(defaultResult).timeoutMs).toBe(180_000); expect(resultDetails(overrideResult).timeoutMs).toBe(12_345); }); @@ -1059,7 +1059,7 @@ describe("createVideoGenerateTool", () => { }); expect(generateSpy).toHaveBeenCalledTimes(1); - const call = generateSpy.mock.calls[0]?.[0] as { + const call = generateSpy.mock.calls.at(0)?.[0] as { inputImages?: Array<{ role?: string }>; }; expect(call.inputImages).toHaveLength(2); @@ -1096,7 +1096,7 @@ describe("createVideoGenerateTool", () => { image: "/tmp/reference.png", }); - const loadCall = vi.mocked(webMedia.loadWebMedia).mock.calls[0]; + const loadCall = vi.mocked(webMedia.loadWebMedia).mock.calls.at(0); expect(loadCall?.[0]).toBe("/tmp/reference.png"); const loadOptions = loadCall?.[1] as { ssrfPolicy?: unknown } | undefined; expect(loadOptions?.ssrfPolicy).toEqual({ allowRfc2544BenchmarkRange: true });