Fix tests

This commit is contained in:
Siddharth Ganesan
2026-02-09 13:24:49 -08:00
parent b14e844868
commit 395f8901fe
4 changed files with 14 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ describe('Copilot API Keys API Route', () => {
vi.doMock('@/lib/copilot/constants', () => ({
SIM_AGENT_API_URL_DEFAULT: 'https://agent.sim.example.com',
SIM_AGENT_API_URL: 'https://agent.sim.example.com',
}))
vi.doMock('@/lib/core/config/env', async () => {

View File

@@ -139,7 +139,6 @@ describe('Copilot Confirm API Route', () => {
status: 'success',
})
expect(mockRedisExists).toHaveBeenCalled()
expect(mockRedisSet).toHaveBeenCalled()
})
@@ -256,11 +255,11 @@ describe('Copilot Confirm API Route', () => {
expect(responseData.error).toBe('Failed to update tool call status or tool call not found')
})
it('should return 400 when tool call is not found in Redis', async () => {
it('should return 400 when Redis set fails', async () => {
const authMocks = mockAuth()
authMocks.setAuthenticated()
mockRedisExists.mockResolvedValue(0)
mockRedisSet.mockRejectedValueOnce(new Error('Redis set failed'))
const req = createMockRequest('POST', {
toolCallId: 'non-existent-tool',
@@ -279,7 +278,7 @@ describe('Copilot Confirm API Route', () => {
const authMocks = mockAuth()
authMocks.setAuthenticated()
mockRedisExists.mockRejectedValue(new Error('Redis connection failed'))
mockRedisSet.mockRejectedValueOnce(new Error('Redis connection failed'))
const req = createMockRequest('POST', {
toolCallId: 'tool-call-123',

View File

@@ -40,6 +40,7 @@ describe('Copilot Stats API Route', () => {
vi.doMock('@/lib/copilot/constants', () => ({
SIM_AGENT_API_URL_DEFAULT: 'https://agent.sim.example.com',
SIM_AGENT_API_URL: 'https://agent.sim.example.com',
}))
vi.doMock('@/lib/core/config/env', async () => {

View File

@@ -7,12 +7,19 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('@sim/logger', () => loggerMock)
const executeToolServerSide = vi.fn()
const markToolComplete = vi.fn()
const { executeToolServerSide, markToolComplete, isIntegrationTool, isToolAvailableOnSimSide } =
vi.hoisted(() => ({
executeToolServerSide: vi.fn(),
markToolComplete: vi.fn(),
isIntegrationTool: vi.fn().mockReturnValue(false),
isToolAvailableOnSimSide: vi.fn().mockReturnValue(true),
}))
vi.mock('@/lib/copilot/orchestrator/tool-executor', () => ({
executeToolServerSide,
markToolComplete,
isIntegrationTool,
isToolAvailableOnSimSide,
}))
import { sseHandlers } from '@/lib/copilot/orchestrator/sse-handlers'