Description
The repository has zero tests. The chess engine (packages/server/bot),
the game state machine (packages/server/game), and the WebSocket message
flow (packages/server/handler) all contain non-trivial logic with no
coverage. This is a blocker for safely fixing other bugs (e.g. the broken
chess moves) because there is no safety net to prevent regressions.
Proposed fix
Add Go tests using stdlib testing (no new dependency):
packages/server/bot/bot_test.go
TestBotReturnsValidMove: from the starting position, the bot's
chosen move must be in ValidMoves().
TestBotPlaysVariety: 50 games from the start, assert that the set
of first moves includes at least 3 different SAN strings.
TestEvaluateMaterial: known position with material advantage
returns positive score for the side with more pieces.
packages/server/game/game_test.go
TestMakeMoveUpdatesTurn
TestMakeMoveRejectsInvalidSAN
TestGameOverStatusCheckmate
TestBotGameRespectsBotColor
packages/server/handler/websocket_test.go
TestParseMovePayload
TestJoinRejectsFullGame
Frontend: do not add tests in this issue (no test runner configured yet;
track in a follow-up).
Acceptance criteria
Files
packages/server/bot/bot_test.go (new)
packages/server/game/game_test.go (new)
packages/server/handler/websocket_test.go (new)
Description
The repository has zero tests. The chess engine (
packages/server/bot),the game state machine (
packages/server/game), and the WebSocket messageflow (
packages/server/handler) all contain non-trivial logic with nocoverage. This is a blocker for safely fixing other bugs (e.g. the broken
chess moves) because there is no safety net to prevent regressions.
Proposed fix
Add Go tests using stdlib
testing(no new dependency):packages/server/bot/bot_test.goTestBotReturnsValidMove: from the starting position, the bot'schosen move must be in
ValidMoves().TestBotPlaysVariety: 50 games from the start, assert that the setof first moves includes at least 3 different SAN strings.
TestEvaluateMaterial: known position with material advantagereturns positive score for the side with more pieces.
packages/server/game/game_test.goTestMakeMoveUpdatesTurnTestMakeMoveRejectsInvalidSANTestGameOverStatusCheckmateTestBotGameRespectsBotColorpackages/server/handler/websocket_test.goTestParseMovePayloadTestJoinRejectsFullGameFrontend: do not add tests in this issue (no test runner configured yet;
track in a follow-up).
Acceptance criteria
cd packages/server && go test ./...runs and passesbotpackage is at least 50%Files
packages/server/bot/bot_test.go(new)packages/server/game/game_test.go(new)packages/server/handler/websocket_test.go(new)