refactor: code review improvements

- Add 30s timeout to Stockfish evaluation to prevent hanging promises
- Add FEN validation and depth cap (max 30) to Stockfish API route
- Create ErrorBoundary component with specialized fallbacks for chess game and tutor
- Extract useChessSounds hook for better audio management
- Add React.memo to EvaluationBar and CapturedPieces for performance
- Add useMemo to CapturedPieces for sorted pieces calculation
- Improve tacticDetection to return empty array instead of "none" type
- Add filterMeaningfulTactics and hasTactics helper functions
- Translate hardcoded UI strings (stockfishLevel, download, evalChange)
- Update translations for EN, DE, FR, IT, PL
- Add uuid to Jest transformIgnorePatterns for ESM compatibility
- Update tests to use new filterMeaningfulTactics function
This commit is contained in:
Claude
2025-12-10 21:30:28 +00:00
parent 014781e2d0
commit 47c37487b3
17 changed files with 385 additions and 61 deletions
@@ -10,6 +10,11 @@
* This is Phase 5 of the refactoring plan - comprehensive testing.
*/
// Mock uuid before any imports
jest.mock('uuid', () => ({
v4: jest.fn(() => 'test-uuid-1234'),
}));
import React from 'react';
import { renderHook, act, waitFor } from '@testing-library/react';
import { OpeningTrainingProvider, useOpeningTraining } from '../OpeningTrainingContext';