mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-06 00:54:23 +00:00
Fix health service tests
This commit is contained in:
@@ -12,12 +12,14 @@ import { AuthProvider } from '@/contexts/AuthContext'
|
|||||||
vi.mock('@/lib/api', () => ({
|
vi.mock('@/lib/api', () => ({
|
||||||
instancesApi: {
|
instancesApi: {
|
||||||
list: vi.fn(),
|
list: vi.fn(),
|
||||||
|
get: vi.fn(),
|
||||||
create: vi.fn(),
|
create: vi.fn(),
|
||||||
update: vi.fn(),
|
update: vi.fn(),
|
||||||
start: vi.fn(),
|
start: vi.fn(),
|
||||||
stop: vi.fn(),
|
stop: vi.fn(),
|
||||||
restart: vi.fn(),
|
restart: vi.fn(),
|
||||||
delete: vi.fn(),
|
delete: vi.fn(),
|
||||||
|
getHealth: vi.fn(),
|
||||||
},
|
},
|
||||||
serverApi: {
|
serverApi: {
|
||||||
getHelp: vi.fn(),
|
getHelp: vi.fn(),
|
||||||
@@ -30,9 +32,21 @@ vi.mock('@/lib/api', () => ({
|
|||||||
vi.mock('@/lib/healthService', () => ({
|
vi.mock('@/lib/healthService', () => ({
|
||||||
healthService: {
|
healthService: {
|
||||||
subscribe: vi.fn(() => () => {}),
|
subscribe: vi.fn(() => () => {}),
|
||||||
checkHealth: 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(),
|
checkHealth: vi.fn(() => Promise.resolve({
|
||||||
|
state: 'ready',
|
||||||
|
instanceStatus: 'running',
|
||||||
|
lastChecked: new Date(),
|
||||||
|
source: 'http'
|
||||||
|
})),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function renderApp() {
|
function renderApp() {
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import { BackendType } from '@/types/instance'
|
|||||||
|
|
||||||
// Mock the health hook since we're not testing health logic here
|
// Mock the health hook since we're not testing health logic here
|
||||||
vi.mock('@/hooks/useInstanceHealth', () => ({
|
vi.mock('@/hooks/useInstanceHealth', () => ({
|
||||||
useInstanceHealth: vi.fn(() => ({ status: 'ok', lastChecked: new Date() }))
|
useInstanceHealth: vi.fn(() => ({
|
||||||
|
state: 'ready',
|
||||||
|
instanceStatus: 'running',
|
||||||
|
lastChecked: new Date(),
|
||||||
|
source: 'http'
|
||||||
|
}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
describe('InstanceCard - Instance Actions and State', () => {
|
describe('InstanceCard - Instance Actions and State', () => {
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import { AuthProvider } from '@/contexts/AuthContext'
|
|||||||
vi.mock('@/lib/api', () => ({
|
vi.mock('@/lib/api', () => ({
|
||||||
instancesApi: {
|
instancesApi: {
|
||||||
list: vi.fn(),
|
list: vi.fn(),
|
||||||
|
get: vi.fn(),
|
||||||
create: vi.fn(),
|
create: vi.fn(),
|
||||||
update: vi.fn(),
|
update: vi.fn(),
|
||||||
start: vi.fn(),
|
start: vi.fn(),
|
||||||
stop: vi.fn(),
|
stop: vi.fn(),
|
||||||
restart: vi.fn(),
|
restart: vi.fn(),
|
||||||
delete: vi.fn(),
|
delete: vi.fn(),
|
||||||
|
getHealth: vi.fn(),
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -25,9 +27,21 @@ vi.mock('@/lib/api', () => ({
|
|||||||
vi.mock('@/lib/healthService', () => ({
|
vi.mock('@/lib/healthService', () => ({
|
||||||
healthService: {
|
healthService: {
|
||||||
subscribe: vi.fn(() => () => {}),
|
subscribe: vi.fn(() => () => {}),
|
||||||
checkHealth: 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(),
|
checkHealth: vi.fn(() => Promise.resolve({
|
||||||
|
state: 'ready',
|
||||||
|
instanceStatus: 'running',
|
||||||
|
lastChecked: new Date(),
|
||||||
|
source: 'http'
|
||||||
|
})),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function renderInstanceList(editInstance = vi.fn()) {
|
function renderInstanceList(editInstance = vi.fn()) {
|
||||||
|
|||||||
@@ -11,15 +11,38 @@ import { AuthProvider } from "../AuthContext";
|
|||||||
vi.mock("@/lib/api", () => ({
|
vi.mock("@/lib/api", () => ({
|
||||||
instancesApi: {
|
instancesApi: {
|
||||||
list: vi.fn(),
|
list: vi.fn(),
|
||||||
|
get: vi.fn(),
|
||||||
create: vi.fn(),
|
create: vi.fn(),
|
||||||
update: vi.fn(),
|
update: vi.fn(),
|
||||||
start: vi.fn(),
|
start: vi.fn(),
|
||||||
stop: vi.fn(),
|
stop: vi.fn(),
|
||||||
restart: vi.fn(),
|
restart: vi.fn(),
|
||||||
delete: 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
|
// Test component to access context
|
||||||
function TestComponent() {
|
function TestComponent() {
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user