From 7f1c20f5539836a9c936af157cffd7d8830edaf2 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 4 Jan 2026 10:19:57 +0100 Subject: [PATCH] Fix TypeScript errors in test files - Add missing 'src' property to OpeningMetadata test fixtures - Add missing 'id' and 'description' properties to Personality test fixtures - Add missing 'isPlayerWhite' property to EvaluationBar test cases All tests now pass TypeScript validation. No changes to production code. --- src/components/ChessGame.test.tsx | 2 ++ src/components/EvaluationBar.test.tsx | 6 +++--- src/components/__tests__/Tutor.test.tsx | 12 ++++++++---- .../__tests__/OpeningTrainingContext.test.tsx | 1 + src/lib/openingTrainer/__tests__/gameLogic.test.ts | 2 ++ .../__tests__/sessionOrchestrator.test.ts | 1 + .../openingTrainer/__tests__/sessionReducer.test.ts | 2 ++ 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/ChessGame.test.tsx b/src/components/ChessGame.test.tsx index 560b77a..3248f87 100644 --- a/src/components/ChessGame.test.tsx +++ b/src/components/ChessGame.test.tsx @@ -67,9 +67,11 @@ jest.mock("./StartScreen", () => ({ describe("ChessGame Component", () => { const mockPersonality = { + id: "test", name: "Test Personality", systemPrompt: "You are a helpful assistant.", image: "🤖", + description: "Test description", }; beforeEach(() => { diff --git a/src/components/EvaluationBar.test.tsx b/src/components/EvaluationBar.test.tsx index f7e92ab..4d0013f 100644 --- a/src/components/EvaluationBar.test.tsx +++ b/src/components/EvaluationBar.test.tsx @@ -4,7 +4,7 @@ import "@testing-library/jest-dom"; describe("EvaluationBar", () => { it("renders 0.0 for initial state", () => { - render(); + render(); expect(screen.getByText("0.0")).toBeInTheDocument(); }); @@ -19,12 +19,12 @@ describe("EvaluationBar", () => { }); it("renders mate score", () => { - render(); + render(); expect(screen.getByText("M3")).toBeInTheDocument(); }); it("renders negative mate score", () => { - render(); + render(); expect(screen.getByText("M5")).toBeInTheDocument(); }); }); diff --git a/src/components/__tests__/Tutor.test.tsx b/src/components/__tests__/Tutor.test.tsx index 0ffd8b1..4eea196 100644 --- a/src/components/__tests__/Tutor.test.tsx +++ b/src/components/__tests__/Tutor.test.tsx @@ -46,14 +46,16 @@ describe('Tutor', () => { stockfish={stockfish} evalP0={null} evalP2={null} - openingData={null} + openingData={[]} missedTactics={null} onAnalysisComplete={() => {}} apiKey="test-api-key" personality={{ + id: "test", name: "Test Personality", systemPrompt: "Test Prompt", - image: "🤖" + image: "🤖", + description: "Test description" }} language="en" playerColor="white" @@ -103,14 +105,16 @@ describe('Tutor', () => { stockfish={stockfish} evalP0={null} evalP2={null} - openingData={null} + openingData={[]} missedTactics={null} onAnalysisComplete={() => {}} apiKey="test-api-key" personality={{ + id: "test", name: "Test Personality", systemPrompt: "Test Prompt", - image: "🤖" + image: "🤖", + description: "Test description" }} language="en" playerColor="white" diff --git a/src/contexts/__tests__/OpeningTrainingContext.test.tsx b/src/contexts/__tests__/OpeningTrainingContext.test.tsx index b7da09b..c7a871c 100644 --- a/src/contexts/__tests__/OpeningTrainingContext.test.tsx +++ b/src/contexts/__tests__/OpeningTrainingContext.test.tsx @@ -96,6 +96,7 @@ const mockOpening: OpeningMetadata = { eco: 'C00', name: 'French Defense', moves: '1. e4 e6 2. d4 d5', + src: 'test', wikipediaSlug: 'French_Defence', }; diff --git a/src/lib/openingTrainer/__tests__/gameLogic.test.ts b/src/lib/openingTrainer/__tests__/gameLogic.test.ts index d609110..3f5a69b 100644 --- a/src/lib/openingTrainer/__tests__/gameLogic.test.ts +++ b/src/lib/openingTrainer/__tests__/gameLogic.test.ts @@ -29,6 +29,7 @@ const mockOpening: OpeningMetadata = { eco: 'C00', name: 'French Defense', moves: '1. e4 e6 2. d4 d5', + src: 'test', wikipediaSlug: 'French_Defence', }; @@ -36,6 +37,7 @@ const mockBlackOpening: OpeningMetadata = { eco: 'D00', name: "Queen's Pawn Opening", moves: '1. d4 d5', + src: 'test', wikipediaSlug: 'Queens_Pawn_Game', }; diff --git a/src/lib/openingTrainer/__tests__/sessionOrchestrator.test.ts b/src/lib/openingTrainer/__tests__/sessionOrchestrator.test.ts index 8308bba..bc64b67 100644 --- a/src/lib/openingTrainer/__tests__/sessionOrchestrator.test.ts +++ b/src/lib/openingTrainer/__tests__/sessionOrchestrator.test.ts @@ -52,6 +52,7 @@ const mockOpening: OpeningMetadata = { eco: 'C00', name: 'French Defense', moves: '1. e4 e6 2. d4 d5', + src: 'test', wikipediaSlug: 'French_Defence', }; diff --git a/src/lib/openingTrainer/__tests__/sessionReducer.test.ts b/src/lib/openingTrainer/__tests__/sessionReducer.test.ts index 8369542..603f414 100644 --- a/src/lib/openingTrainer/__tests__/sessionReducer.test.ts +++ b/src/lib/openingTrainer/__tests__/sessionReducer.test.ts @@ -20,6 +20,7 @@ const mockOpening: OpeningMetadata = { eco: 'C00', name: 'French Defense', moves: '1. e4 e6 2. d4 d5', + src: 'test', wikipediaSlug: 'French_Defence', }; @@ -27,6 +28,7 @@ const mockBlackOpening: OpeningMetadata = { eco: 'D00', name: "Queen's Pawn", moves: '1. d4 d5', + src: 'test', }; function createMockMove(