From 3c4f23b09503cceaf6c4c0898f64c3c26c8641c7 Mon Sep 17 00:00:00 2001 From: Delilah Date: Thu, 4 Jun 2026 21:10:51 -0400 Subject: [PATCH] test(webhost): cover all active lobby states in dashboard aggregation Add TestGetDashboardData.test_all_active_lobby_states_counted, which builds OPEN/GENERATING/DONE/LOCKED lobbies for one session and asserts open_lobbies == 4 plus the exact open_lobbies_sub ordering. Closes the mutation gap where dropping LOCKED(3) from _ACTIVE_LOBBY_STATES, or mishandling the locked_count sub-string branch, passed undetected (no test created a state=3 lobby). Test-side only; no product code changed. Co-Authored-By: Claude Opus 4.8 --- test/webhost/test_dashboard.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/webhost/test_dashboard.py b/test/webhost/test_dashboard.py index 416198354..20e66631d 100644 --- a/test/webhost/test_dashboard.py +++ b/test/webhost/test_dashboard.py @@ -133,6 +133,25 @@ def test_closed_lobbies_excluded_from_count(self, app): # Only the OPEN lobby counts — CLOSED ones are stripped. assert data.stats.open_lobbies == 1 + def test_all_active_lobby_states_counted(self, app): + # OPEN, GENERATING, DONE, and LOCKED are all "active" (only CLOSED is + # excluded), and the sub-string lists them in the order the source builds. + from WebHostLib.models import ( + Lobby, LOBBY_OPEN, LOBBY_GENERATING, LOBBY_DONE, LOBBY_LOCKED, db, commit, + ) + + session = uuid4() + with app.app_context(): + Lobby(title="open", owner=session, state=LOBBY_OPEN, meta="{}") + Lobby(title="generating", owner=session, state=LOBBY_GENERATING, meta="{}") + Lobby(title="done", owner=session, state=LOBBY_DONE, meta="{}") + Lobby(title="locked", owner=session, state=LOBBY_LOCKED, meta="{}") + commit() + data = get_dashboard_data(session) + + assert data.stats.open_lobbies == 4 + assert data.stats.open_lobbies_sub == "1 open · 1 generating · 1 locked · 1 done" + def test_returns_dashboard_data_dataclass( self, app, room_factory, lobby_factory, seed_factory ):