Skip to content

test: cover BoardState and public auth-endpoint contracts#22

Open
UberMetroid wants to merge 1 commit into
masterfrom
test-coverage-pr
Open

test: cover BoardState and public auth-endpoint contracts#22
UberMetroid wants to merge 1 commit into
masterfrom
test-coverage-pr

Conversation

@UberMetroid

Copy link
Copy Markdown
Collaborator

Adds 20 deterministic frontend BoardState tests covering sector dimensions, mine count, first-click safety, adjacency, recursive zero-reveal flood, flag handling, mine loss, win detection, and terminal-state no-ops. Adds 10 backend integration tests covering POST /api/logout (cookie cleared, session revoked, idempotent, no session-id leak), GET /api/config and GET /api/pin-required (unauthenticated, accurate fields, no PIN echo), the 64 KiB body limit on /api/leaderboard, and the 64-char PIN length ceiling. CI gains a cargo fmt --check step; clippy is intentionally not gated because tests/container_smoke.rs has pre-existing warnings on master that would fail -D warnings.

cargo check --workspace, cargo test --workspace (149 tests, 0 failures), and cargo fmt --check all pass locally.

Frontend (frontend/src/components/scan_logic.rs):
- Split generate_mines into a deterministic generate_mines_with that takes
  a caller-supplied RNG; reveal_cell now delegates to reveal_cell_with so
  the first-click path is testable without js_sys::Math::random.
- Add a cfg(test) module exercising sector dimensions, mine count, first-
  click safety (no mine in the 3x3 around the start cell across corners,
  edges, and the center for several RNG seeds), adjacency correctness
  against independent neighbor counts, recursive zero-reveal flood,
  flagged-cell skipping, mine reveal setting Lost and exposing all
  mines, terminal-state no-ops for reveal/toggle, win detection when
  the last non-mine is revealed, and RNG determinism.

Backend (backend/tests/auth_endpoints.rs):
- Cover POST /api/logout: cookie cleared, session revoked, idempotent,
  no session-id echo in the response body.
- Cover GET /api/config and GET /api/pin-required: both unauthenticated,
  required/length accurate, configured PIN never echoed.
- Verify the 64 KiB body limit applies to /api/leaderboard as well as
  /api/verify-pin, and that /api/verify-pin rejects PINs above the
  64-character ceiling.

CI (.github/workflows/ci.yml):
- cargo test --workspace was already wired up; add a cargo fmt --check
  step to catch formatting drift. clippy is not gated because pre-existing
  warnings in tests/container_smoke.rs would fail -D warnings on master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant