Sig select: _card-deck.scss extract, WS cursor fixes, own-role indicators, role icon refresh
- New _card-deck.scss: sig select styles moved out of _room.scss + _game-kit.scss - sig-select.js: 3 WS bug fixes — thumbs-up deferred to window.load (layout settled before getBoundingClientRect), hover cursor cleared for all cards on reservation (not just the reserved card), applyHover guards against already-reserved roles - Own-role indicators: gamer now sees their own role-coloured card outline + thumbs-up - Reservation glow: replaced blurry role+ninUser double-shadow with crisp 2px outline - Gravity qualifier: Graven text set to --terUser (matches Leavened/--quiUser pattern) - Role card SVGs refreshed; starter-role-Blank removed - FTs + Jasmine specs extended for sig select WS behaviour - setup_sig_session management command for multi-browser manual testing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
128
src/functional_tests/management/commands/setup_sig_session.py
Normal file
128
src/functional_tests/management/commands/setup_sig_session.py
Normal file
@@ -0,0 +1,128 @@
|
||||
"""
|
||||
Management command for manual multi-user sig-select testing.
|
||||
|
||||
Creates (or reuses) a room with all 6 gate slots filled, roles assigned,
|
||||
and table_status=SIG_SELECT. Prints one pre-auth URL per gamer so you can
|
||||
paste them into 6 Firefox Multi-Account Container tabs.
|
||||
|
||||
Usage:
|
||||
python src/manage.py setup_sig_session
|
||||
python src/manage.py setup_sig_session --base-url http://localhost:8000
|
||||
python src/manage.py setup_sig_session --room <uuid> # reuse existing room
|
||||
"""
|
||||
|
||||
from django.contrib.auth import BACKEND_SESSION_KEY, HASH_SESSION_KEY, SESSION_KEY
|
||||
from django.contrib.sessions.backends.db import SessionStore
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from apps.epic.models import DeckVariant, GateSlot, Room, TableSeat, TarotCard
|
||||
from apps.lyric.models import User
|
||||
|
||||
|
||||
GAMERS = [
|
||||
("founder@test.io", "discoman"),
|
||||
("amigo@test.io", "amigo"),
|
||||
("bud@test.io", "bud"),
|
||||
("pal@test.io", "pal"),
|
||||
("dude@test.io", "dude"),
|
||||
("bro@test.io", "bro"),
|
||||
]
|
||||
|
||||
ROLES = ["PC", "NC", "EC", "SC", "AC", "BC"]
|
||||
|
||||
|
||||
def _ensure_earthman():
|
||||
"""Return (or create) the Earthman DeckVariant with enough sig-deck cards seeded."""
|
||||
earthman, _ = DeckVariant.objects.get_or_create(
|
||||
slug="earthman",
|
||||
defaults={"name": "Earthman Deck", "card_count": 108, "is_default": True},
|
||||
)
|
||||
_NAME = {11: "Maid", 12: "Jack", 13: "Queen", 14: "King"}
|
||||
for suit in ("WANDS", "PENTACLES", "SWORDS", "CUPS"):
|
||||
for number in (11, 12, 13, 14):
|
||||
TarotCard.objects.get_or_create(
|
||||
deck_variant=earthman,
|
||||
slug=f"{_NAME[number].lower()}-of-{suit.lower()}-em",
|
||||
defaults={
|
||||
"arcana": "MINOR",
|
||||
"suit": suit,
|
||||
"number": number,
|
||||
"name": f"{_NAME[number]} of {suit.capitalize()}",
|
||||
},
|
||||
)
|
||||
return earthman
|
||||
|
||||
|
||||
def _make_session(user):
|
||||
session = SessionStore()
|
||||
session[SESSION_KEY] = str(user.pk)
|
||||
session[BACKEND_SESSION_KEY] = "apps.lyric.authentication.PasswordlessAuthenticationBackend"
|
||||
session[HASH_SESSION_KEY] = user.get_session_auth_hash()
|
||||
session.save()
|
||||
return session.session_key
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Set up a SIG_SELECT room and print pre-auth URLs for all six gamers"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("--base-url", default="http://localhost:8000")
|
||||
parser.add_argument("--room", default=None, help="UUID of an existing room to reuse")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
base_url = options["base_url"].rstrip("/")
|
||||
earthman = _ensure_earthman()
|
||||
|
||||
# ── Users ────────────────────────────────────────────────────────────
|
||||
users = []
|
||||
for email, _ in GAMERS:
|
||||
user, _ = User.objects.get_or_create(email=email)
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
if not user.equipped_deck:
|
||||
user.equipped_deck = earthman
|
||||
user.save()
|
||||
users.append(user)
|
||||
|
||||
# ── Room ─────────────────────────────────────────────────────────────
|
||||
if options["room"]:
|
||||
room = Room.objects.get(pk=options["room"])
|
||||
else:
|
||||
room = Room.objects.create(
|
||||
name="Sig Select Test Room",
|
||||
owner=users[0],
|
||||
visibility=Room.PUBLIC,
|
||||
)
|
||||
|
||||
# ── Gate slots ───────────────────────────────────────────────────────
|
||||
for i, user in enumerate(users, start=1):
|
||||
slot = room.gate_slots.get(slot_number=i)
|
||||
slot.gamer = user
|
||||
slot.status = GateSlot.FILLED
|
||||
slot.save()
|
||||
|
||||
room.gate_status = Room.OPEN
|
||||
room.save()
|
||||
|
||||
# ── Table seats + roles ──────────────────────────────────────────────
|
||||
for i, (user, role) in enumerate(zip(users, ROLES), start=1):
|
||||
TableSeat.objects.update_or_create(
|
||||
room=room, slot_number=i,
|
||||
defaults={"gamer": user, "role": role, "role_revealed": True},
|
||||
)
|
||||
|
||||
room.table_status = Room.SIG_SELECT
|
||||
room.save()
|
||||
|
||||
# ── Print URLs ───────────────────────────────────────────────────────
|
||||
room_path = f"/gameboard/room/{room.pk}/"
|
||||
self.stdout.write(f"\nRoom: {base_url}{room_path}\n")
|
||||
self.stdout.write(f"{'Container':<12} {'Email':<22} {'Role':<6} URL")
|
||||
self.stdout.write("─" * 100)
|
||||
|
||||
for (email, container), user, role in zip(GAMERS, users, ROLES):
|
||||
session_key = _make_session(user)
|
||||
url = f"{base_url}/lyric/dev-login/{session_key}/?next={room_path}"
|
||||
self.stdout.write(f"{container:<12} {email:<22} {role:<6} {url}")
|
||||
|
||||
self.stdout.write("")
|
||||
@@ -138,3 +138,234 @@ class SigSelectChannelsTest(ChannelsFunctionalTest):
|
||||
))
|
||||
return b
|
||||
|
||||
def _setup_sig_select_room(self):
|
||||
"""Create a full SIG_SELECT room; return (room, [user_pc, user_nc, ...])."""
|
||||
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="Cursor Colour Test", owner=founder)
|
||||
gamers = _fill_room_via_orm(room, emails)
|
||||
_assign_all_roles(room)
|
||||
return room, gamers
|
||||
|
||||
# ── SC1: NC hover → PC sees mid cursor active, coloured --priYl ────────── #
|
||||
|
||||
@tag('channels')
|
||||
def test_nc_hover_activates_mid_cursor_in_pc_browser(self):
|
||||
"""
|
||||
When NC (levity mid) hovers a card, PC (levity left) must see the
|
||||
--mid cursor become active, coloured --priYl (rgb 255 207 52).
|
||||
Verifies: WS broadcast pipeline + JS applyHover + CSS role colouring.
|
||||
"""
|
||||
room, gamers = self._setup_sig_select_room()
|
||||
room_url = self.live_server_url + f"/gameboard/room/{room.pk}/"
|
||||
|
||||
# ── Browser 1: PC (founder) ───────────────────────────────────────────
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(room_url)
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
|
||||
# ── Browser 2: NC (amigo) ─────────────────────────────────────────────
|
||||
browser2 = self._make_browser2("amigo@test.io")
|
||||
try:
|
||||
browser2.get(room_url)
|
||||
self.wait_for(lambda: browser2.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
|
||||
# Grab the first card ID visible in browser2's deck
|
||||
first_card = browser2.find_element(By.CSS_SELECTOR, ".sig-card")
|
||||
card_id = first_card.get_attribute("data-card-id")
|
||||
|
||||
# Hover over it — triggers sendHover() → WS broadcast
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
ActionChains(browser2).move_to_element(first_card).perform()
|
||||
|
||||
# ── Browser 1 should see --mid cursor go active (anchor carries class) ─
|
||||
mid_cursor_sel = f'.sig-card[data-card-id="{card_id}"] .sig-cursor--mid'
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, mid_cursor_sel + ".active"
|
||||
)
|
||||
)
|
||||
|
||||
# CSS colour check: portal float has data-role="NC" → --priYl = 255, 207, 52
|
||||
portal_sel = '.sig-cursor-float[data-role="NC"]'
|
||||
portal_cursor = self.browser.find_element(By.CSS_SELECTOR, portal_sel)
|
||||
color = self.browser.execute_script(
|
||||
"return window.getComputedStyle(arguments[0]).color",
|
||||
portal_cursor,
|
||||
)
|
||||
self.assertEqual(color, "rgb(255, 207, 52)", f"Expected --priYl colour for NC cursor, got {color}")
|
||||
|
||||
# ── Mouse-off: anchor class removed, portal float gone ────────────
|
||||
ActionChains(browser2).move_to_element(
|
||||
browser2.find_element(By.CSS_SELECTOR, ".sig-stage")
|
||||
).perform()
|
||||
self.wait_for(
|
||||
lambda: not self.browser.find_elements(
|
||||
By.CSS_SELECTOR, mid_cursor_sel + ".active"
|
||||
)
|
||||
)
|
||||
|
||||
finally:
|
||||
browser2.quit()
|
||||
|
||||
# ── SC2: NC reserves → PC sees card border coloured --priYl ──────────── #
|
||||
|
||||
@tag('channels')
|
||||
def test_nc_reservation_glows_priYl_in_pc_browser(self):
|
||||
"""
|
||||
When NC (levity mid) clicks OK on a card, PC must see that card's border
|
||||
coloured --priYl (rgb 255 207 52) via the data-reserved-by CSS selector.
|
||||
Verifies: sig_reserve view → WS broadcast → applyReservation → CSS glow.
|
||||
"""
|
||||
room, gamers = self._setup_sig_select_room()
|
||||
room_url = self.live_server_url + f"/gameboard/room/{room.pk}/"
|
||||
|
||||
# ── Browser 1: PC (founder) ───────────────────────────────────────────
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(room_url)
|
||||
self.wait_for(lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
|
||||
# ── Browser 2: NC (amigo) ─────────────────────────────────────────────
|
||||
browser2 = self._make_browser2("amigo@test.io")
|
||||
try:
|
||||
browser2.get(room_url)
|
||||
self.wait_for(lambda: browser2.find_element(By.CSS_SELECTOR, ".sig-overlay"))
|
||||
|
||||
# Get first card in B2's deck
|
||||
first_card = browser2.find_element(By.CSS_SELECTOR, ".sig-card")
|
||||
card_id = first_card.get_attribute("data-card-id")
|
||||
|
||||
# Click card body → .sig-focused → OK button appears
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
ActionChains(browser2).move_to_element(first_card).perform()
|
||||
first_card.click()
|
||||
|
||||
ok_btn = self.wait_for(
|
||||
lambda: browser2.find_element(By.CSS_SELECTOR, ".sig-focused .sig-ok-btn")
|
||||
)
|
||||
ok_btn.click()
|
||||
|
||||
# ── B1 should see the card's border turn --priYl ──────────────────
|
||||
reserved_card_sel = f'.sig-card[data-card-id="{card_id}"]'
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, reserved_card_sel + '[data-reserved-by="NC"]'
|
||||
)
|
||||
)
|
||||
|
||||
reserved_card = self.browser.find_element(By.CSS_SELECTOR, reserved_card_sel)
|
||||
border_color = self.browser.execute_script(
|
||||
"return window.getComputedStyle(arguments[0]).borderTopColor",
|
||||
reserved_card,
|
||||
)
|
||||
self.assertEqual(
|
||||
border_color, "rgb(255, 207, 52)",
|
||||
f"Expected --priYl border for NC reservation, got {border_color}",
|
||||
)
|
||||
|
||||
finally:
|
||||
browser2.quit()
|
||||
|
||||
|
||||
|
||||
# ── Polarity theming: qualifier text + no correspondence ─────────────────────
|
||||
|
||||
class SigSelectThemeTest(FunctionalTest):
|
||||
"""Polarity-qualifier display (Graven/Leavened) and correspondence suppression.
|
||||
No WebSocket needed — stage updates are local; uses plain FunctionalTest."""
|
||||
|
||||
EMAILS = [
|
||||
"founder@test.io", "amigo@test.io", "bud@test.io",
|
||||
"pal@test.io", "dude@test.io", "bro@test.io",
|
||||
]
|
||||
|
||||
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):
|
||||
founder, _ = User.objects.get_or_create(email=self.EMAILS[0])
|
||||
room = Room.objects.create(name="Theme Test", owner=founder)
|
||||
_fill_room_via_orm(room, self.EMAILS)
|
||||
_assign_all_roles(room)
|
||||
return room
|
||||
|
||||
def _hover_card(self, css):
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
card = self.browser.find_element(By.CSS_SELECTOR, css)
|
||||
ActionChains(self.browser).move_to_element(card).perform()
|
||||
return card
|
||||
|
||||
# ── ST1: Levity (Leavened) qualifier ──────────────────────────────────── #
|
||||
|
||||
def test_levity_non_major_card_shows_leavened_above(self):
|
||||
"""Hovering a non-major card in the levity overlay shows 'Leavened' in
|
||||
qualifier-above and nothing in qualifier-below."""
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io") # PC = levity
|
||||
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._hover_card('.sig-card[data-arcana="Minor Arcana"]')
|
||||
|
||||
above = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-qualifier-above")
|
||||
)
|
||||
self.assertEqual(above.text, "Leavened")
|
||||
below = self.browser.find_element(By.CSS_SELECTOR, ".sig-qualifier-below")
|
||||
self.assertEqual(below.text, "")
|
||||
|
||||
def test_levity_major_card_shows_leavened_below(self):
|
||||
"""Hovering a major arcana card in the levity overlay shows 'Leavened' in
|
||||
qualifier-below and nothing in qualifier-above."""
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("founder@test.io") # PC = levity
|
||||
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._hover_card('.sig-card[data-arcana="Major Arcana"]')
|
||||
|
||||
below = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-qualifier-below")
|
||||
)
|
||||
self.assertEqual(below.text, "Leavened")
|
||||
above = self.browser.find_element(By.CSS_SELECTOR, ".sig-qualifier-above")
|
||||
self.assertEqual(above.text, "")
|
||||
|
||||
# ── ST2: Gravity (Graven) qualifier ───────────────────────────────────── #
|
||||
|
||||
def test_gravity_non_major_card_shows_graven_above(self):
|
||||
"""EC (bud) sees the gravity overlay; hovering a non-major card shows 'Graven'."""
|
||||
room = self._setup_sig_room()
|
||||
self.create_pre_authenticated_session("bud@test.io") # EC = gravity
|
||||
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._hover_card('.sig-card[data-arcana="Minor Arcana"]')
|
||||
|
||||
above = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".sig-qualifier-above")
|
||||
)
|
||||
self.assertEqual(above.text, "Graven")
|
||||
|
||||
# ── ST3: Correspondence not shown ─────────────────────────────────────── #
|
||||
|
||||
def test_correspondence_not_shown_in_sig_select(self):
|
||||
"""The Minchiate-equivalence field must always be blank on the stage 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"))
|
||||
|
||||
# Hover any card — correspondence should remain empty regardless
|
||||
self._hover_card(".sig-card")
|
||||
self.wait_for(lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, ".sig-stage-card"
|
||||
))
|
||||
corr = self.browser.find_element(By.CSS_SELECTOR, ".fan-card-correspondence")
|
||||
self.assertEqual(corr.text, "")
|
||||
|
||||
Reference in New Issue
Block a user