diff --git a/src/functional_tests/test_game_room_select_sea.py b/src/functional_tests/test_game_room_select_sea.py index f4fa907..0455c99 100644 --- a/src/functional_tests/test_game_room_select_sea.py +++ b/src/functional_tests/test_game_room_select_sea.py @@ -92,19 +92,29 @@ class PickSeaAsyncTransitionTest(ChannelsFunctionalTest): """) def test_pick_sea_btn_visible_after_sky_confirm(self): - """Confirming sky reloads the room to the hex w. DRAW SEA replacing - CAST SKY; the sea overlay is NOT auto-opened.""" + """Confirming sky lands the room on the hex w. DRAW SEA in place of CAST + SKY; the sea overlay is NOT auto-opened. (A direct-POST confirm has no + captured chart on this browser, so _onSkyConfirmed reloads to the server- + rendered DRAW SEA hex; the felt-save path eases there via the cascade.)""" self.create_pre_authenticated_session("founder@test.io") self.browser.get(self.room_url) - # Sky not yet confirmed — CAST SKY btn present. + # Sky not yet confirmed — CAST SKY is the live (non --out) phase btn. self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sky_btn")) self._confirm_sky() - # Page reloads → hex shows DRAW SEA in place of CAST SKY. - self.wait_for(lambda: self.browser.find_element(By.ID, "id_pick_sea_btn")) - self.assertEqual(self.browser.find_elements(By.ID, "id_pick_sky_btn"), []) + # DRAW SEA becomes the live phase btn; CAST SKY stays in the phase-stack + # but goes --out (the buttons cross-fade in one grid cell now, so the + # stale CAST SKY is hidden via the class, not removed from the DOM). + self.wait_for(lambda: self.assertNotIn( + "hex-phase-btn--out", + self.browser.find_element(By.ID, "id_pick_sea_btn").get_attribute("class"), + )) + self.assertIn( + "hex-phase-btn--out", + self.browser.find_element(By.ID, "id_pick_sky_btn").get_attribute("class"), + ) # Sea overlay is NOT auto-opened — it only appears once the gamer # clicks DRAW SEA. diff --git a/src/templates/apps/gameboard/_partials/_sky_overlay.html b/src/templates/apps/gameboard/_partials/_sky_overlay.html index e6bf4a5..2c538e4 100644 --- a/src/templates/apps/gameboard/_partials/_sky_overlay.html +++ b/src/templates/apps/gameboard/_partials/_sky_overlay.html @@ -542,14 +542,19 @@ } // ── Sky confirmed (self-targeted WS) ────────────────────────────────────── - // The acting gamer's own SAVE .then() already revealed the wheel; the WS - // event just re-asserts the saved state (idempotent). No reload — the gamer - // lingers on the saved wheel; the gear NVM does the navigation back to the - // hex (now DRAW SEA). A second browser of the same seat with no captured - // chart no-ops here (rare) and reconciles on its next load. - + // Two cases: + // • This browser captured the chart (the gamer saved via the felt) → the + // save .then() already ran the cascade; this WS re-fire is idempotent + // (re-asserts the saved state, no second cascade, no reload). + // • No captured chart (a direct POST confirm, or another browser of the same + // seat) → the cascade can't run, so reload to land on the server-rendered + // DRAW SEA hex (the pre-cascade behaviour, preserved for these paths). function _onSkyConfirmed() { - _activateSavedState(); + if (_lastChartData) { + _activateSavedState(); + } else { + window.location.reload(); + } } // ── DEL btn — JS-injected after the wheel paints; absent on a blank modal