From 77b8d0fa7abf593d50d9675343fcb29dc1a422d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 1 Feb 2026 17:53:41 +0000 Subject: [PATCH] Fix TypeScript transpile errors in test files - Add jest.d.ts to include @testing-library/jest-dom types - Fix dashboard test mock to include all required props (isAuthenticated, authLoading, isLoading, hasContainers) - Fix authSlice test by properly typing the Redux store - Fix useInteractiveTerminal test by adding type annotation to props parameter - Update tsconfig.json to include jest.d.ts All TypeScript errors are now resolved and the build passes successfully. https://claude.ai/code/session_01KrwCxjP4joh9CFAtreiBFu --- frontend/app/dashboard/__tests__/page.test.tsx | 15 +++++++++++++-- frontend/jest.d.ts | 1 + .../__tests__/useInteractiveTerminal.test.tsx | 10 +++++++++- frontend/lib/store/__tests__/authSlice.test.ts | 15 +++++++++------ frontend/tsconfig.json | 1 + 5 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 frontend/jest.d.ts 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",