test: cover BoardState and public auth-endpoint contracts#22
Open
UberMetroid wants to merge 1 commit into
Open
test: cover BoardState and public auth-endpoint contracts#22UberMetroid wants to merge 1 commit into
UberMetroid wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --checkstep; clippy is intentionally not gated becausetests/container_smoke.rshas pre-existing warnings on master that would fail -D warnings.cargo check --workspace,cargo test --workspace(149 tests, 0 failures), andcargo fmt --checkall pass locally.