Skip to content

Commit a64f996

Browse files
committed
test(lua): assert paused field instead of timing in endless play
The endless-mode regression test asserted elapsed < 5s, a flaky wall-clock check that measures speed rather than game state. Rewrite it to assert paused=false on the endless play via the new GameState field. Verified red against the pre-fix play.lua (paused=true failure) and green with the fix restored.
1 parent c27477c commit a64f996

1 file changed

Lines changed: 10 additions & 19 deletions

File tree

tests/lua/endpoints/test_play.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Tests for src/lua/endpoints/play.lua"""
22

3-
import time
4-
53
import httpx
64

75
from tests.lua.conftest import (
@@ -89,15 +87,13 @@ def test_play_valid_cards_and_game_over(self, client: httpx.Client) -> None:
8987
assert_gamestate_response(response, state="GAME_OVER")
9088

9189
def test_play_endless_mode_after_won(self, client: httpx.Client) -> None:
92-
"""Endless-mode play stays responsive after winning ante 8.
93-
94-
Winning the ante-8 boss raises the win overlay and pauses the game.
95-
``play`` must dismiss that overlay so the game keeps running on turbo
96-
time; otherwise the bot is left in a paused session where every
97-
subsequent endless play crawls on wall-clock time.
90+
"""Endless-mode play runs unpaused after winning ante 8.
9891
99-
Driven live rather than via a save/load fixture: ``load`` resets the
100-
run and discards the paused/overlay state, which would mask the bug.
92+
Winning the ante-8 boss raises the win overlay and pauses the game
93+
(``G.SETTINGS.paused = true``). ``play`` must dismiss that overlay so
94+
the endless run keeps running on turbo time; otherwise the game is
95+
left paused indefinitely and every subsequent play reports
96+
``paused=true``.
10197
"""
10298
# Drive to the ante-8 boss and win it.
10399
api(client, "menu")
@@ -121,17 +117,12 @@ def test_play_endless_mode_after_won(self, client: httpx.Client) -> None:
121117
assert_gamestate_response(entering, state="SELECTING_HAND")
122118
assert entering["result"]["won"] is True
123119

124-
# An endless play must stay responsive. If the win overlay was left
125-
# up, the game stays paused and this runs on wall-clock time (~9s
126-
# instead of ~2s) — a permanently degraded bot session.
127-
start = time.monotonic()
120+
# An endless play must run unpaused. If the win overlay was left up,
121+
# the game stays paused forever and the response reports paused=true.
128122
response = api(client, "play", {"cards": [0, 1, 2, 3, 4]})
129-
elapsed = time.monotonic() - start
130123
assert_gamestate_response(response)
131-
assert response["result"]["won"] is True
132-
assert elapsed < 5, (
133-
f"endless play took {elapsed:.1f}s — game left paused after win "
134-
"(win overlay not dismissed)"
124+
assert response["result"]["paused"] is False, (
125+
"endless play left the game paused — win overlay not dismissed"
135126
)
136127

137128

0 commit comments

Comments
 (0)