Skip to content

test: add functional tests and restructure test suite#77

Merged
FlorentPoinsaut merged 2 commits intomainfrom
test/functional-tests
Apr 29, 2026
Merged

test: add functional tests and restructure test suite#77
FlorentPoinsaut merged 2 commits intomainfrom
test/functional-tests

Conversation

@FlorentPoinsaut
Copy link
Copy Markdown
Member

Summary

Adds a two-layer test architecture and functional (end-to-end) tests that were previously missing.

Changes

Structure

  • tests/unit/ — existing 7 test files moved here (renames only, logic unchanged)
  • tests/functional/ — new directory with 2 new test files
  • tests/conftest.py — shared helpers (FakeScorer, make_ctx, make_bot) and pytest fixtures, eliminating duplicated helpers across unit test files

New: tests/functional/test_game_flow.py

End-to-end game scenarios at the bot + game layer (no overlay, no network):

  • Complete game lifecycle (start → guesses → win)
  • Multi-player competition
  • Difficulty flow (setdifficulty + start)
  • hint / status commands
  • solution command
  • Guess edge cases (duplicates, invalid chars, too long, cooldown)

New: tests/functional/test_bot_overlay.py

Bot ↔ overlay WebSocket integration — verifies the JSON payload received by a real WebSocket client after each bot command:

  • start → client receives status: running
  • guess → client receives updated attempt_count
  • Winning guess → client receives status: found + target_word
  • solution → client receives status: found
  • Late-connecting client receives cached state immediately

README

Testing section updated to document the two-layer structure and per-layer run commands.

Test results

284 passed in 1.92s — 92% coverage

No Twitch network connection or Word2Vec model required.

- Split tests/ into tests/unit/ (existing) and tests/functional/ (new)
- Add tests/conftest.py with shared FakeScorer, make_ctx, make_bot helpers
  and pytest fixtures, eliminating duplicate helpers across unit test files
- Add tests/functional/test_game_flow.py: end-to-end game scenarios
  (full game lifecycle, difficulty flow, hint/status, solution, edge cases)
- Add tests/functional/test_bot_overlay.py: bot ↔ overlay integration
  verifying JSON payloads received by a real WebSocket client after each
  bot command (start, guess, win, solution, late-connect cache)
- Update README.md Testing section to document the two-layer structure

All 284 tests pass, 92% coverage. No network or Word2Vec model required.
- test_hint_shows_sorted_leaderboard: assert '1. cha', '2. ch', '3. c '
  instead of substring checks that could match sub-words
- test_status_shows_attempt_count: assert '2 attempt' instead of bare '2'
- test_guess_broadcasts_updated_attempt_count: also assert last_guess.word
  and last_guess.user to verify the full overlay payload
- Merge redundant TestOverlayWebSocketWithBot into TestBotOverlayIntegration
  (both classes were connecting a real WS client after the previous refactor)
- Add TestOverlayWebSocketMultiClient.test_broadcast_reaches_all_connected_clients
  to exercise the 'for ws in set(self._clients)' broadcast loop
@FlorentPoinsaut FlorentPoinsaut merged commit 6814874 into main Apr 29, 2026
2 checks passed
@FlorentPoinsaut FlorentPoinsaut deleted the test/functional-tests branch April 29, 2026 09:02
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