Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /* eslint-disable react-refresh/only-export-components */ import React, { type ReactNode } from 'react'; import { create } from 'zustand'; // Create mock stores using Zustand's create() function // Constant - not a component const createMockDashboardStoreImpl = () => create(() => ({ data: { modelInfo: { accuracy: 0.28, predictions_total: 150, predictions_successful: 135, }, servicesHealth: { 'api-gateway': { status: 'healthy', latency_ms: 10 }, 'rf-acquisition': { status: 'healthy', latency_ms: 50 }, 'training': { status: 'healthy', latency_ms: 30 }, 'inference': { status: 'healthy', latency_ms: 45 }, 'data-ingestion-web': { status: 'healthy', latency_ms: 20 }, }, }, metrics: { accuracy_history: [0.25, 0.26, 0.27, 0.28], latency_avg_ms: 150, }, isLoading: false, error: null, fetchDashboardData: () => { }, })); export const createMockDashboardStore = createMockDashboardStoreImpl; export const createMockWebSDRStore = () => create(() => ({ websdrs: Array(7).fill(null).map((_, i) => ({ id: i + 1, name: `WebSDR ${i + 1}`, url: `http://localhost:800${i}`, country: 'Italy', location: `Receiver ${i + 1}`, is_active: true, })), healthStatus: Object.fromEntries( Array(7).fill(null).map((_, i) => [ `${i + 1}`, { status: 'online', response_time_ms: 150 + i * 10 }, ]) ), statistics: { online_count: 7, total_count: 7, active_count: 7, avg_response_time_ms: 151, }, isLoading: false, error: null, fetchWebSDRs: () => { }, checkHealth: () => { }, refreshAll: () => { }, lastHealthCheck: new Date().toISOString(), })); export const createMockSessionStore = () => create(() => ({ knownSources: [ { id: 1, name: 'Source 1', frequency_mhz: 145.5, is_validated: true }, { id: 2, name: 'Source 2', frequency_mhz: 430.5, is_validated: false }, ], sessions: [ { id: 1, session_name: 'Session 1', status: 'completed', created_at: new Date().toISOString() }, { id: 2, session_name: 'Session 2', status: 'pending', created_at: new Date().toISOString() }, ], analytics: { total_sessions: 10, completed_sessions: 8, total_measurements: 100, }, pagination: { page: 1, pageSize: 10, total: 2, }, isLoading: false, error: null, fetchKnownSources: () => { }, fetchSessions: () => { }, fetchAnalytics: () => { }, clearError: () => { }, })); const createMockAuthStoreImpl = () => create(() => ({ user: { email: 'admin@heimdall.local', firstName: 'Admin', lastName: 'User', role: 'administrator', organization: 'Heimdall SDR', createdAt: new Date().toISOString(), }, isAuthenticated: true, isLoading: false, error: null, logout: () => { }, updateProfile: () => { }, })); export { createMockAuthStoreImpl as createMockAuthStore }; interface MockStoreProviderProps { children: ReactNode; } // Export stores globally during testing let mockDashboardStore = createMockDashboardStore(); let mockWebSDRStore = createMockWebSDRStore(); let mockSessionStore = createMockSessionStore(); let mockAuthStore = createMockAuthStoreImpl(); export const getMockStores = () => ({ mockDashboardStore, mockWebSDRStore, mockSessionStore, mockAuthStore, }); export const resetMockStores = () => { mockDashboardStore = createMockDashboardStore(); mockWebSDRStore = createMockWebSDRStore(); mockSessionStore = createMockSessionStore(); mockAuthStore = createMockAuthStoreImpl(); }; export const MockStoreProvider: React.FC<MockStoreProviderProps> = ({ children }) => { // This provider doesn't actually need to render anything special // The mock stores are injected via vi.mock() in setup.ts return <>{children}</>; }; |