Skip to content

Commit 395f890

Browse files
committed
Fix tests
1 parent b14e844 commit 395f890

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

apps/sim/app/api/copilot/api-keys/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('Copilot API Keys API Route', () => {
1919

2020
vi.doMock('@/lib/copilot/constants', () => ({
2121
SIM_AGENT_API_URL_DEFAULT: 'https://agent.sim.example.com',
22+
SIM_AGENT_API_URL: 'https://agent.sim.example.com',
2223
}))
2324

2425
vi.doMock('@/lib/core/config/env', async () => {

apps/sim/app/api/copilot/confirm/route.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ describe('Copilot Confirm API Route', () => {
139139
status: 'success',
140140
})
141141

142-
expect(mockRedisExists).toHaveBeenCalled()
143142
expect(mockRedisSet).toHaveBeenCalled()
144143
})
145144

@@ -256,11 +255,11 @@ describe('Copilot Confirm API Route', () => {
256255
expect(responseData.error).toBe('Failed to update tool call status or tool call not found')
257256
})
258257

259-
it('should return 400 when tool call is not found in Redis', async () => {
258+
it('should return 400 when Redis set fails', async () => {
260259
const authMocks = mockAuth()
261260
authMocks.setAuthenticated()
262261

263-
mockRedisExists.mockResolvedValue(0)
262+
mockRedisSet.mockRejectedValueOnce(new Error('Redis set failed'))
264263

265264
const req = createMockRequest('POST', {
266265
toolCallId: 'non-existent-tool',
@@ -279,7 +278,7 @@ describe('Copilot Confirm API Route', () => {
279278
const authMocks = mockAuth()
280279
authMocks.setAuthenticated()
281280

282-
mockRedisExists.mockRejectedValue(new Error('Redis connection failed'))
281+
mockRedisSet.mockRejectedValueOnce(new Error('Redis connection failed'))
283282

284283
const req = createMockRequest('POST', {
285284
toolCallId: 'tool-call-123',

apps/sim/app/api/copilot/stats/route.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('Copilot Stats API Route', () => {
4040

4141
vi.doMock('@/lib/copilot/constants', () => ({
4242
SIM_AGENT_API_URL_DEFAULT: 'https://agent.sim.example.com',
43+
SIM_AGENT_API_URL: 'https://agent.sim.example.com',
4344
}))
4445

4546
vi.doMock('@/lib/core/config/env', async () => {

apps/sim/lib/copilot/orchestrator/sse-handlers.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
77

88
vi.mock('@sim/logger', () => loggerMock)
99

10-
const executeToolServerSide = vi.fn()
11-
const markToolComplete = vi.fn()
10+
const { executeToolServerSide, markToolComplete, isIntegrationTool, isToolAvailableOnSimSide } =
11+
vi.hoisted(() => ({
12+
executeToolServerSide: vi.fn(),
13+
markToolComplete: vi.fn(),
14+
isIntegrationTool: vi.fn().mockReturnValue(false),
15+
isToolAvailableOnSimSide: vi.fn().mockReturnValue(true),
16+
}))
1217

1318
vi.mock('@/lib/copilot/orchestrator/tool-executor', () => ({
1419
executeToolServerSide,
1520
markToolComplete,
21+
isIntegrationTool,
22+
isToolAvailableOnSimSide,
1623
}))
1724

1825
import { sseHandlers } from '@/lib/copilot/orchestrator/sse-handlers'

0 commit comments

Comments
 (0)