Skip to content

test: add websocket and http functional tests - #600

Merged
saffronjam merged 1 commit into
mainfrom
feat/websocket-functional-tests
Oct 10, 2026
Merged

saffronjam merged 1 commit into
mainfrom
feat/websocket-functional-tests

Conversation

@saffronjam

Copy link
Copy Markdown
Collaborator

tl;dr: Adds functional tests that drive the real server over HTTP and real WebSocket connections, and fixes the bugs they found. Backend coverage goes from 66.8% to 78.7%; the WebSocket layer from 12% to 82%.

Details

The server wiring moves into internal/app so main and the new test/e2e suites run exactly the same server.

  • New test/e2e harness and suites:
    • full games from lobby to final scores, and every first-action corporation
    • a contract for every client message type: junk payloads from every kind of sender, with a test that fails if a registered type has no cases
    • privacy of hands and pending choices
    • device switching, kick and end game
    • stalled clients, panics and shutdown; concurrent clients under -race; every HTTP route
  • WebSocket core rewrite:
    • sends never block, and a client that stops reading is disconnected instead of stalling every game
    • a panicking handler answers with an error instead of killing the server
    • a player's state reaches every connected device, and closing an old tab no longer drops or disconnects them
    • joining and spectating bind the connection only after they succeed
    • nothing leaks on shutdown
  • Fixed:
    • victory-point history raced live game changes; it now reads the game on the hub goroutine
    • the public games list showed the first player's hand
    • duplicate patents or starting choices were accepted
    • project-funding seats charged more than their cost
    • Home Schooled granted bonus tags squared
    • malformed JSON frames dropped the connection; unknown history filters returned 200
  • Admin commands now need a development-mode game and a player; new games default to development mode off
  • Error replies use one shape, ErrorPayload, which names the failed request; the frontend's error handlers match on it
  • Removed dead protocol:
    • legacy standard-project messages, WebSocket create-game and join-game
    • action-success, full-state, and the client-sendable player-disconnected and spectator-disconnected
    • unused core and utils code
  • Existing tests:
    • deleted the fake broadcaster test and the dead test/helpers package
    • removed sleeps and un-skipped the free-trade test
    • rewrote tests that asserted nothing or asserted bugs
    • made 314 error checks name the expected error, which exposed five tests passing for the wrong reason
    • testutil returns copies of cards
  • just backend test now runs with -race -shuffle=on; test logging is quiet by default

- Share production app wiring with end-to-end tests and strengthen existing assertions
- Rework connection lifecycle and device bindings, disconnect slow clients, unify request errors and remove unused protocol
- Fix private hand exposure, dev-mode access, VP enrichment races, duplicate selections, seat overpayment and bonus tag scaling
@saffronjam
saffronjam merged commit 67780d4 into main Oct 10, 2026
9 checks passed
@saffronjam
saffronjam deleted the feat/websocket-functional-tests branch October 10, 2026 19:30
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