You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document enumerates every automated test in the repository and what each case covers.
Keep it in sync whenever you add, rename, or delete tests.
Running Tests
make test runs the full suite: Node controller/unit tests, backend pytest suites (unit + e2e), and the database checks.
make front-test executes the Node test runner against frontend/tests/*.mjs.
make backend-test runs pytest for everything under backend/tests (unit + integration, excluding e2e-only and prod-only targets).
make backend-test-e2e scopes pytest to backend/tests/e2e.
make backend-test-prod enables the prod marker (equivalent to pytest --prod-smoke -m prod backend/tests); requires PROD_FRONTEND_BASE_URL, PROD_API_BASE_URL, and PROD_MONGO_URI to be set or resolvable via .env files.
make db-test runs the Mongo port safety checks in db/tests.
Pytest Configuration & Fixtures
pytest.ini registers the prod marker used by production smoke tests.
backend/tests/conftest.py exposes:
--prod-smoke / RUN_PROD_SMOKE flagging to opt into prod tests.
An api_client fixture that spins up the FastAPI app with stubbed Mongo + Moxfield clients (stored at app.state.stub_db).
Frontend Tests
frontend/tests/config.test.mjs
Test
What it verifies
generate-config falls back to defaults without env files
Running frontend/scripts/generate-config.mjs in an empty temp directory produces fallback values (GOOGLE_CLIENT_ID, API_BASE_URL).
generate-config honours values provided in env files
The generator reads .env entries when present and emits them into the runtime config.
frontend/tests/moxfield.test.mjs
Test
What it verifies
validateMoxfieldHandle accepts valid usernames
Accepts uppercase, lowercase, underscore, and dash handles.
validateMoxfieldHandle rejects invalid usernames
Rejects empty, too-short, spaced, or punctuated handles.
normalizeMoxfieldDeck extracts metadata from backend payloads
Normalises deck payloads and counts cards from board lists.
deckMatchesIdentifier recognises legacy and public deck identifiers
Candidate extraction includes both legacy IDs and new public IDs; matcher resolves either.
createCardSnapshot preserves core card data for fast detail rendering
Card snapshots strip extraneous fields while keeping deck context, pricing, and quantities.
createDeckSnapshot serialises decks with sanitised boards for fast rendering
Deck snapshots trim raw board data, clean prices, and standardise metadata.
collectDeckBoards normalises board dictionaries from Moxfield
Converts dict-based board payloads into ordered arrays while preserving counts.
Deck personalizations handle encoded deck IDs containing / and can be retrieved afterwards.
backend/tests/test_play_data.py
Test
What it verifies
test_create_playgroup_and_list
Creating a playgroup returns an ID and initial list call shows zero games.
test_record_game_updates_history_and_playgroup
Recording a game stores rankings, decks, and updates playgroup metadata.
test_list_games_filters_by_playgroup_identifier
Game listing filters by playgroup_id and returns all games when unfiltered.
test_record_game_creates_playgroup_when_missing
Recording a game with only a name auto-creates the playgroup.
test_playgroup_detail_includes_stats_and_members
Playgroup detail reports aggregated stats and member list after updates.
test_linking_tracked_player_updates_games
Linking a stored player to a Google identity updates historic game records and availability listings.
backend/tests/e2e/test_platform_e2e.py
All tests run with AnyIO's asyncio backend using stubbed Mongo and Moxfield clients.
Test
What it verifies
test_full_platform_flow
Exercises the primary user journey: profile sync, deck caching, personalization, player linking, playgroup creation, game recording, social follow/unfollow, and cache pruning.
test_deck_cache_warmup_flow
Cache endpoints return 404 until live sync happens, then reflect deck deletions.
test_playgroup_update_and_delete_flow
Playgroups support updates (name + members) and hard deletes clean up listings.
test_guest_player_validation_flow
Guest player endpoints enforce name validation, reject bad links, and delete cleanly.
test_public_profile_privacy_flow
Social search respects privacy, follows private/public users, and hides private profile fetches.
test_deck_personalization_missing_returns_404
Missing deck personalizations return HTTP 404 and listing returns an empty set.
test_game_record_validation_errors
Game recording enforces minimum players, complete rankings, and existing playgroups.
test_linking_player_updates_game_history
Linking a guest player retrofits stored games with the linked user's metadata.
test_moxfield_error_handling
Upstream Moxfield errors map to HTTP 404 (not found) or 502 (generic failure) across decks and summaries.
backend/tests/prod/test_prod_smoke.py
Runs only under the prod marker (make backend-test-prod or pytest --prod-smoke).
Test
What it verifies
test_frontend_serves_index
Production frontend base URL returns a non-empty HTML response.
test_api_healthcheck_is_healthy
Production API /health endpoint responds with {"status": "ok"}.
test_mongo_ping_succeeds
Production MongoDB URI accepts a ping command via Motor.
Database Tests
db/tests/test_ports.py
Test
What it verifies
test_env_example_uses_custom_mongo_port
.env.example advertises the custom Mongo port (47017).
test_makefile_mongo_port_matches_env
Makefile default MONGO_PORT matches the documented custom port.