added PICK SKY ready gate: SigReservation.ready + countdown_remaining fields, Room.SKY_SELECT status + sig_select_started_at, sig_ready + sig_confirm views, WS notifiers for countdown_start/cancel/polarity_room_done/pick_sky_available, migration 0031, PICK SKY btn in hex center at SKY_SELECT, tray cell 2 sig card placeholder; FTs SRG1-8 written (pending JS/consumer)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -370,3 +370,389 @@ class SigSelectThemeTest(FunctionalTest):
|
||||
))
|
||||
corr = self.browser.find_element(By.CSS_SELECTOR, ".fan-card-correspondence")
|
||||
self.assertEqual(corr.text, "")
|
||||
|
||||
|
||||
# ── TAKE SIG / WAIT NO — ready gate ──────────────────────────────────────────
|
||||
#
|
||||
# TAKE SIG (.btn.btn-primary) appears at the bottom-left corner of the card
|
||||
# stage preview once a gamer has clicked OK on a card (SigReservation exists).
|
||||
# Clicking it sets the gamer's status to ready and changes the btn to WAIT NO.
|
||||
# WAIT NO cancels the ready status and reverts back to TAKE SIG.
|
||||
#
|
||||
# When all three gamers in a polarity WS room are ready, a 12-second countdown
|
||||
# starts. Any WAIT NO during the countdown cancels it; the saved remaining time
|
||||
# is resumed when all three are ready again. When the countdown completes
|
||||
# (client POSTs sig_confirm) the polarity group returns to the table hex.
|
||||
# When both polarity groups have confirmed, PICK SKY btn appears in the hex
|
||||
# center for all six gamers.
|
||||
#
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
class SigReadyGateTest(FunctionalTest):
|
||||
"""Single-browser tests for TAKE SIG / WAIT NO btn."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.browser.set_window_size(800, 1200)
|
||||
Applet.objects.get_or_create(
|
||||
slug="new-game", defaults={"name": "New Game", "context": "gameboard"}
|
||||
)
|
||||
Applet.objects.get_or_create(
|
||||
slug="my-games", defaults={"name": "My Games", "context": "gameboard"}
|
||||
)
|
||||
|
||||
def _setup_sig_room(self):
|
||||
emails = [
|
||||
"founder@test.io", "amigo@test.io", "bud@test.io",
|
||||
"pal@test.io", "dude@test.io", "bro@test.io",
|
||||
]
|
||||
founder, _ = User.objects.get_or_create(email=emails[0])
|
||||
room = Room.objects.create(name="Ready Gate Test", owner=founder)
|
||||
_fill_room_via_orm(room, emails)
|
||||
_assign_all_roles(room)
|
||||
return room
|
||||
|
||||
def _click_ok_on_any_card(self):
|
||||
"""Click the first sig card to stage it, then click OK."""
|
||||
card = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-card")
|
||||
)
|
||||
card.click()
|
||||
ok_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-ok-btn")
|
||||
)
|
||||
ok_btn.click()
|
||||
|
||||
# ── SRG1: TAKE SIG btn not visible before OK ──────────────────────── #
|
||||
|
||||
def test_take_sig_btn_not_visible_before_ok_click(self):
|
||||
"""TAKE SIG must be absent until the gamer has OK'd a card."""
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
|
||||
take_sig_btns = self.browser.find_elements(By.ID, "id_take_sig_btn")
|
||||
self.assertEqual(len(take_sig_btns), 0)
|
||||
|
||||
# ── SRG2: TAKE SIG btn appears after OK ──────────────────────────── #
|
||||
|
||||
def test_take_sig_btn_appears_after_ok_click(self):
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
self._click_ok_on_any_card()
|
||||
|
||||
take_sig_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
)
|
||||
self.assertIn("TAKE SIG", take_sig_btn.text.upper())
|
||||
|
||||
# ── SRG3: TAKE SIG → WAIT NO ─────────────────────────────────────── #
|
||||
|
||||
def test_take_sig_btn_becomes_wait_no_after_click(self):
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
self._click_ok_on_any_card()
|
||||
|
||||
take_sig_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
)
|
||||
take_sig_btn.click()
|
||||
|
||||
wait_no_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
)
|
||||
self.assertIn("WAIT NO", wait_no_btn.text.upper())
|
||||
|
||||
# ── SRG4: WAIT NO → TAKE SIG ─────────────────────────────────────── #
|
||||
|
||||
def test_wait_no_reverts_to_take_sig(self):
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
self._click_ok_on_any_card()
|
||||
|
||||
btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
)
|
||||
btn.click() # → WAIT NO
|
||||
self.wait_for(lambda: "WAIT NO" in self.browser.find_element(
|
||||
By.ID, "id_take_sig_btn").text.upper()
|
||||
)
|
||||
btn = self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
btn.click() # → TAKE SIG again
|
||||
|
||||
reverted = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_take_sig_btn")
|
||||
)
|
||||
self.assertIn("TAKE SIG", reverted.text.upper())
|
||||
|
||||
|
||||
@tag("channels")
|
||||
class SigReadyCountdownChannelsTest(ChannelsFunctionalTest):
|
||||
"""Multi-browser WebSocket tests for the polarity-room countdown and PICK SKY."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.browser.set_window_size(800, 1200)
|
||||
Applet.objects.get_or_create(
|
||||
slug="new-game", defaults={"name": "New Game", "context": "gameboard"}
|
||||
)
|
||||
Applet.objects.get_or_create(
|
||||
slug="my-games", defaults={"name": "My Games", "context": "gameboard"}
|
||||
)
|
||||
|
||||
def _make_browser_for(self, email):
|
||||
session_key = create_pre_authenticated_session(email)
|
||||
options = webdriver.FirefoxOptions()
|
||||
if os.environ.get("HEADLESS"):
|
||||
options.add_argument("--headless")
|
||||
b = webdriver.Firefox(options=options)
|
||||
b.get(self.live_server_url + "/404_no_such_url/")
|
||||
b.add_cookie(dict(
|
||||
name=django_settings.SESSION_COOKIE_NAME,
|
||||
value=session_key,
|
||||
path="/",
|
||||
))
|
||||
return b
|
||||
|
||||
def _setup_sig_select_room(self):
|
||||
emails = [
|
||||
"founder@test.io", "amigo@test.io", "bud@test.io",
|
||||
"pal@test.io", "dude@test.io", "bro@test.io",
|
||||
]
|
||||
founder, _ = User.objects.get_or_create(email=emails[0])
|
||||
room = Room.objects.create(name="Countdown Test", owner=founder)
|
||||
_fill_room_via_orm(room, emails)
|
||||
_assign_all_roles(room)
|
||||
return room, emails
|
||||
|
||||
# ── SRG5: countdown appears when all three polarity ready ─────────── #
|
||||
|
||||
@tag("channels")
|
||||
def test_countdown_element_appears_when_all_three_levity_gamers_ready(self):
|
||||
"""When PC, NC, and SC each click TAKE SIG the countdown becomes visible."""
|
||||
room, emails = self._setup_sig_select_room()
|
||||
levity_emails = [emails[0], emails[1], emails[3]] # PC, NC, SC
|
||||
browsers = []
|
||||
try:
|
||||
for email in levity_emails:
|
||||
b = self._make_browser_for(email)
|
||||
b.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
browsers.append(b)
|
||||
|
||||
# Each levity gamer OK's a card then clicks TAKE SIG
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-card"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-card").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-ok-btn"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-ok-btn").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_take_sig_btn"), browser=b
|
||||
)
|
||||
b.find_element(By.ID, "id_take_sig_btn").click()
|
||||
|
||||
# All three browsers should now see the countdown
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_sig_countdown"), browser=b
|
||||
)
|
||||
finally:
|
||||
for b in browsers:
|
||||
b.quit()
|
||||
|
||||
# ── SRG6: countdown disappears when WAIT NO clicked ──────────────── #
|
||||
|
||||
@tag("channels")
|
||||
def test_countdown_disappears_when_any_levity_gamer_clicks_wait_no(self):
|
||||
"""Any WAIT NO during the countdown cancels it for all three browsers."""
|
||||
room, emails = self._setup_sig_select_room()
|
||||
levity_emails = [emails[0], emails[1], emails[3]]
|
||||
browsers = []
|
||||
try:
|
||||
for email in levity_emails:
|
||||
b = self._make_browser_for(email)
|
||||
b.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
browsers.append(b)
|
||||
|
||||
# All go ready
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-card"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-card").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-ok-btn"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-ok-btn").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_take_sig_btn"), browser=b
|
||||
)
|
||||
b.find_element(By.ID, "id_take_sig_btn").click()
|
||||
|
||||
# Confirm countdown started for all
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_sig_countdown"), browser=b
|
||||
)
|
||||
|
||||
# PC clicks WAIT NO
|
||||
browsers[0].find_element(By.ID, "id_take_sig_btn").click()
|
||||
|
||||
# Countdown element should disappear for all three
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: len(b.find_elements(By.ID, "id_sig_countdown")) == 0,
|
||||
browser=b,
|
||||
)
|
||||
finally:
|
||||
for b in browsers:
|
||||
b.quit()
|
||||
|
||||
# ── SRG7: PICK SKY btn appears after both polarity groups confirm ─── #
|
||||
|
||||
@tag("channels")
|
||||
def test_pick_sky_btn_appears_in_hex_after_both_groups_confirm(self):
|
||||
"""Once both levity and gravity countdowns complete, all six browsers
|
||||
see the PICK SKY btn in the table hex center."""
|
||||
# This test drives the full flow end-to-end but uses ORM shortcuts
|
||||
# to set all-ready state for one polarity, letting the other complete
|
||||
# via the UI, to keep execution time manageable.
|
||||
room, emails = self._setup_sig_select_room()
|
||||
# Pre-confirm gravity via ORM: set significators on EC/AC/BC seats
|
||||
from apps.epic.models import TarotCard, DeckVariant
|
||||
earthman = DeckVariant.objects.get(slug="earthman")
|
||||
grav_roles = ["EC", "AC", "BC"]
|
||||
grav_suits = ["GRAILS", "BLADES", "CROWNS"]
|
||||
for role, suit in zip(grav_roles, grav_suits):
|
||||
card = TarotCard.objects.get(
|
||||
deck_variant=earthman, arcana="MIDDLE", suit=suit, number=11
|
||||
)
|
||||
seat = room.table_seats.get(role=role)
|
||||
seat.significator = card
|
||||
seat.save()
|
||||
|
||||
levity_emails = [emails[0], emails[1], emails[3]]
|
||||
browsers = []
|
||||
try:
|
||||
for email in levity_emails:
|
||||
b = self._make_browser_for(email)
|
||||
b.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
browsers.append(b)
|
||||
|
||||
# All levity gamers OK and TAKE SIG
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-card"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-card").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-ok-btn"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-ok-btn").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_take_sig_btn"), browser=b
|
||||
)
|
||||
b.find_element(By.ID, "id_take_sig_btn").click()
|
||||
|
||||
# Wait for countdown to expire or be confirmed; PICK SKY appears in hex
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_pick_sky_btn"), browser=b
|
||||
)
|
||||
finally:
|
||||
for b in browsers:
|
||||
b.quit()
|
||||
|
||||
# ── SRG8: first-done group sees waiting message ───────────────────── #
|
||||
|
||||
@tag("channels")
|
||||
def test_first_done_polarity_sees_other_group_settling_message(self):
|
||||
"""After levity confirms but gravity hasn't yet, levity gamers see
|
||||
'Gravity settling . . .' on the dormant hex."""
|
||||
room, emails = self._setup_sig_select_room()
|
||||
levity_emails = [emails[0], emails[1], emails[3]]
|
||||
browsers = []
|
||||
try:
|
||||
for email in levity_emails:
|
||||
b = self._make_browser_for(email)
|
||||
b.get(self.live_server_url + f"/gameboard/room/{room.pk}/")
|
||||
browsers.append(b)
|
||||
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-card"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-card").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.CSS_SELECTOR, ".sig-ok-btn"), browser=b
|
||||
)
|
||||
b.find_element(By.CSS_SELECTOR, ".sig-ok-btn").click()
|
||||
self.wait_for(
|
||||
lambda: b.find_element(By.ID, "id_take_sig_btn"), browser=b
|
||||
)
|
||||
b.find_element(By.ID, "id_take_sig_btn").click()
|
||||
|
||||
# Wait for levity confirm → hex revealed, waiting message visible
|
||||
for b in browsers:
|
||||
self.wait_for(
|
||||
lambda: "settling" in b.find_element(
|
||||
By.ID, "id_hex_waiting_msg"
|
||||
).text.lower(),
|
||||
browser=b,
|
||||
)
|
||||
finally:
|
||||
for b in browsers:
|
||||
b.quit()
|
||||
|
||||
|
||||
# ── SKY OVERLAY (natal wheel) — DEFERRED / PENDING PYSWISS ──────────────────
|
||||
#
|
||||
# These FTs outline the sky overlay behavior but are left as stubs.
|
||||
# The sky overlay will be built after the PySwiss microservice (step 18)
|
||||
# and the D3 natal wheel implementation. A prototype already exists and
|
||||
# will be reviewed before these tests are filled in.
|
||||
#
|
||||
# class PickSkyTrayFlowTest(FunctionalTest):
|
||||
#
|
||||
# def test_pick_sky_btn_opens_tray_with_sig_card_in_slot_2(self):
|
||||
# """Clicking PICK SKY opens #id_tray; tray cell 2 shows the gamer's
|
||||
# sig card icon (Blank.svg placeholder until card-specific icons land)."""
|
||||
# ...
|
||||
#
|
||||
# def test_tray_close_dismisses_sig_overlay_and_reveals_hex(self):
|
||||
# """After tray closes the sig select modal is gone and the table hex
|
||||
# is visible again."""
|
||||
# ...
|
||||
#
|
||||
# def test_sky_overlay_appears_over_hex_after_tray_closes(self):
|
||||
# """The sky overlay (#id_sky_overlay) appears over the hex once the
|
||||
# tray animation completes."""
|
||||
# ...
|
||||
#
|
||||
# def test_sky_overlay_prompts_for_input_date(self):
|
||||
# """The sky overlay contains a date input field for natal wheel
|
||||
# calculation via the PySwiss microservice API."""
|
||||
# ...
|
||||
#
|
||||
# def test_sky_overlay_renders_natal_wheel_for_given_date(self):
|
||||
# """Submitting a date triggers a D3-drawn natal wheel (pyswisseph
|
||||
# data). Each house/planet is individually navigable."""
|
||||
# ...
|
||||
#
|
||||
# def test_sky_overlay_accessible_during_play_for_timeframe_changes(self):
|
||||
# """During IN_GAME phase a gamer can reopen the sky overlay to change
|
||||
# the timeframe or check aspects presiding over the current scene."""
|
||||
# ...
|
||||
#
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user