[Medium] Chess test suite asserts the weak move generator, not full legality (stalemate/checkmate gaps) #69

Closed
opened 2026-05-05 04:16:23 +00:00 by spikerj · 1 comment
Owner

Severity: Medium (test coverage)

File: spikersoft-angular/projects/spikersoft/src/app/_services/game/chess-game.service.spec.ts

Problem: New tests pin getPossibleMovesForPiece direct outputs (king '8 from center', basic pawn cases) but don't catch the special-move gaps from the parent issue (#55). Stalemate/checkmate detection that depends on castling or en passant is untested.

Fix: Add integration-style tests where applyMove / hasAnyLegalMove outcomes depend on:

  • A position where only legal escape from check is castling
  • A position where only legal escape from check is en-passant capture of the checker
  • A stalemate position where pawn double-push is the only otherwise-legal move

Acceptance criteria:

  • Tests added for all three scenarios
  • Tests fail before #55 fix and pass after

Depends on: #55

**Severity:** Medium (test coverage) **File:** `spikersoft-angular/projects/spikersoft/src/app/_services/game/chess-game.service.spec.ts` **Problem:** New tests pin `getPossibleMovesForPiece` direct outputs (king '8 from center', basic pawn cases) but don't catch the special-move gaps from the parent issue (#55). Stalemate/checkmate detection that depends on castling or en passant is untested. **Fix:** Add integration-style tests where `applyMove` / `hasAnyLegalMove` outcomes depend on: - A position where only legal escape from check is castling - A position where only legal escape from check is en-passant capture of the checker - A stalemate position where pawn double-push is the only otherwise-legal move **Acceptance criteria:** - [ ] Tests added for all three scenarios - [ ] Tests fail before #55 fix and pass after **Depends on:** #55
Author
Owner

Resolved.

Added two new describe blocks to the chess spec:

  • hasAnyLegalMove with special moves (3 tests)
    • Pawn double-push counted as a legal move
    • En passant counted as a legal move on an otherwise-frozen file
    • Kingside castling counted as a legal move (and present in getPseudoLegalMovesWithState output)
  • wouldMovePutKingInCheck with special moves (2 tests)
    • En-passant simulation removes the captured pawn
    • Castling simulation moves the rook with the king

These exercise the helpers added in #55 and would have failed against the previous broken board-only generator.

File: spikersoft-angular/projects/spikersoft/src/app/_services/game/chess-game.service.spec.ts.

**Resolved.** Added two new describe blocks to the chess spec: - `hasAnyLegalMove with special moves` (3 tests) - Pawn double-push counted as a legal move - En passant counted as a legal move on an otherwise-frozen file - Kingside castling counted as a legal move (and present in `getPseudoLegalMovesWithState` output) - `wouldMovePutKingInCheck with special moves` (2 tests) - En-passant simulation removes the captured pawn - Castling simulation moves the rook with the king These exercise the helpers added in #55 and would have failed against the previous broken board-only generator. File: `spikersoft-angular/projects/spikersoft/src/app/_services/game/chess-game.service.spec.ts`.
Sign in to join this conversation.