fix: Update analysis page tests to use aria-labels

- Change from getByText to getByLabelText for navigation buttons
- Buttons now use icon-only display with aria-labels for accessibility
- Fixes tests after UI simplification in previous commit
This commit is contained in:
Stefan
2025-11-27 12:54:52 +01:00
parent 6b50eba05f
commit 54d92eaae5
+10 -2
View File
@@ -1,5 +1,13 @@
import { fireEvent, render, screen, waitFor } from "@testing-library/react"; import { fireEvent, render, screen, waitFor } from "@testing-library/react";
jest.mock("next/navigation", () => ({
useRouter: jest.fn(() => ({
push: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
})),
}));
jest.mock("react-chessboard", () => ({ jest.mock("react-chessboard", () => ({
Chessboard: ({ position }: { position: string }) => ( Chessboard: ({ position }: { position: string }) => (
<div data-testid="chessboard" data-fen={position} /> <div data-testid="chessboard" data-fen={position} />
@@ -84,7 +92,7 @@ describe("AnalysisPage", () => {
it("replays PGN moves with engine evaluations", async () => { it("replays PGN moves with engine evaluations", async () => {
loadGame(); loadGame();
fireEvent.click(screen.getByText(/Next Move/i)); fireEvent.click(screen.getByLabelText(/Next Move/i));
await waitFor(() => { await waitFor(() => {
expect(screen.getByText(/Move 1 \/ 6/)).toBeInTheDocument(); expect(screen.getByText(/Move 1 \/ 6/)).toBeInTheDocument();
@@ -109,7 +117,7 @@ describe("AnalysisPage", () => {
]); ]);
loadGame(); loadGame();
fireEvent.click(screen.getByText(/Next Move/i)); fireEvent.click(screen.getByLabelText(/Next Move/i));
await waitFor(() => { await waitFor(() => {
expect(screen.getByText(/fork \(~3.0 pawns\) on e5/)).toBeInTheDocument(); expect(screen.getByText(/fork \(~3.0 pawns\) on e5/)).toBeInTheDocument();