mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-10 22:55:16 -05:00
Fix tests
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user