4d5ec5ecc3
This commit fixes a bug where the AI tutor and end-game analysis would use stale data from previous evaluations. The `Tutor` component now receives the live `game` instance and has a new function, `evaluateCurrentPosition`, which is called on-demand when a user requests a hint or the best move. This ensures the LLM receives up-to-date information. The end-game analysis was also corrected to use the proper evaluation data when constructing the move history, preventing incorrect analysis of mistakes and blunders. The test suite was improved by restoring deleted tests, adding a new test to verify the fix, and making existing tests more robust.
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { EvaluationBar } from "./EvaluationBar";
|
|
import "@testing-library/jest-dom";
|
|
|
|
describe("EvaluationBar", () => {
|
|
it("renders 0.0 for initial state", () => {
|
|
render(<EvaluationBar score={0} />);
|
|
expect(screen.getByText("0.0")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders positive score for white advantage", () => {
|
|
render(<EvaluationBar score={150} isPlayerWhite={true} />);
|
|
expect(screen.getByText("+1.5")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders negative score for black advantage", () => {
|
|
render(<EvaluationBar score={-230} isPlayerWhite={true} />);
|
|
expect(screen.getByText("-2.3")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders mate score", () => {
|
|
render(<EvaluationBar mate={3} />);
|
|
expect(screen.getByText("M3")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders negative mate score", () => {
|
|
render(<EvaluationBar mate={-5} />);
|
|
expect(screen.getByText("M5")).toBeInTheDocument();
|
|
});
|
|
});
|