diff --git a/frontend/app/dashboard/__tests__/page.test.tsx b/frontend/app/dashboard/__tests__/page.test.tsx index 63b63f2..446d6e7 100644 --- a/frontend/app/dashboard/__tests__/page.test.tsx +++ b/frontend/app/dashboard/__tests__/page.test.tsx @@ -46,18 +46,29 @@ const mockUseDashboard = useDashboard as jest.MockedFunction { const defaultDashboardState = { + // Authentication + isAuthenticated: true, + authLoading: false, + handleLogout: jest.fn(), + + // Container list containers: [], isRefreshing: false, - error: null, + isLoading: false, + error: '', refreshContainers: jest.fn(), + + // Terminal modal selectedContainer: null, isTerminalOpen: false, openTerminal: jest.fn(), closeTerminal: jest.fn(), + + // UI state isMobile: false, isInitialLoading: false, + hasContainers: false, showEmptyState: false, - handleLogout: jest.fn(), }; beforeEach(() => { diff --git a/frontend/jest.d.ts b/frontend/jest.d.ts new file mode 100644 index 0000000..e48dee9 --- /dev/null +++ b/frontend/jest.d.ts @@ -0,0 +1 @@ +/// diff --git a/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx b/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx index 09e669a..0be07d0 100644 --- a/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx +++ b/frontend/lib/hooks/__tests__/useInteractiveTerminal.test.tsx @@ -1,6 +1,14 @@ import { renderHook, act } from '@testing-library/react'; import { useInteractiveTerminal } from '../useInteractiveTerminal'; +type UseInteractiveTerminalProps = { + open: boolean; + containerId: string; + containerName: string; + isMobile: boolean; + onFallback: (reason: string) => void; +}; + // Suppress console output during tests (terminal initialization logs) const originalConsoleLog = console.log; const originalConsoleWarn = console.warn; @@ -113,7 +121,7 @@ describe('useInteractiveTerminal', () => { const mockDiv = document.createElement('div'); const { rerender } = renderHook( - (props) => { + (props: UseInteractiveTerminalProps) => { const hook = useInteractiveTerminal(props); // Simulate ref being available if (hook.terminalRef.current === null) { diff --git a/frontend/lib/store/__tests__/authSlice.test.ts b/frontend/lib/store/__tests__/authSlice.test.ts index e2743c5..37ad427 100644 --- a/frontend/lib/store/__tests__/authSlice.test.ts +++ b/frontend/lib/store/__tests__/authSlice.test.ts @@ -11,14 +11,17 @@ import * as apiClient from '@/lib/api'; jest.mock('@/lib/api'); describe('authSlice', () => { - let store: ReturnType; + type TestStore = ReturnType; + let store: TestStore; + + const createTestStore = () => configureStore({ + reducer: { + auth: authReducer, + }, + }); beforeEach(() => { - store = configureStore({ - reducer: { - auth: authReducer, - }, - }); + store = createTestStore(); jest.clearAllMocks(); localStorage.clear(); }); diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 3a13f90..3540c1b 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -24,6 +24,7 @@ }, "include": [ "next-env.d.ts", + "jest.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts",