Fix health service tests

This commit is contained in:
2025-10-26 19:48:07 +01:00
parent 75e7b628ca
commit 777e07752b
4 changed files with 61 additions and 5 deletions

View File

@@ -11,15 +11,38 @@ import { AuthProvider } from "../AuthContext";
vi.mock("@/lib/api", () => ({
instancesApi: {
list: vi.fn(),
get: vi.fn(),
create: vi.fn(),
update: vi.fn(),
start: vi.fn(),
stop: vi.fn(),
restart: vi.fn(),
delete: vi.fn(),
getHealth: vi.fn(),
},
}));
// Mock health service
vi.mock("@/lib/healthService", () => ({
healthService: {
subscribe: vi.fn(() => () => {}),
refreshHealth: vi.fn(() => Promise.resolve()),
checkHealthAfterOperation: vi.fn(),
performHealthCheck: vi.fn(() => Promise.resolve({
state: 'ready',
instanceStatus: 'running',
lastChecked: new Date(),
source: 'http'
})),
},
checkHealth: vi.fn(() => Promise.resolve({
state: 'ready',
instanceStatus: 'running',
lastChecked: new Date(),
source: 'http'
})),
}));
// Test component to access context
function TestComponent() {
const {