various styling & structural changes to unify site themes; token-drop interaction changes across epic urls & views
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import time
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
|
||||
from .base import FunctionalTest
|
||||
@@ -20,7 +22,7 @@ class GatekeeperTest(FunctionalTest):
|
||||
|
||||
def test_founder_creates_room_and_sees_gatekeeper(self):
|
||||
# 1. Log in, navigate to gameboard
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url + "/gameboard/")
|
||||
# 2. New Game applet has room name input, create button
|
||||
self.wait_for(
|
||||
@@ -39,14 +41,16 @@ class GatekeeperTest(FunctionalTest):
|
||||
body = self.browser.find_element(By.TAG_NAME, "body")
|
||||
self.assertIn("Test Room", body.text)
|
||||
self.assertIn("GATHERING GAMERS", body.text)
|
||||
# 5. Six token slots are visible
|
||||
# 5. Six token slot circles are visible, all empty
|
||||
slots = self.browser.find_elements(By.CSS_SELECTOR, ".gate-slot")
|
||||
self.assertEqual(len(slots), 6)
|
||||
# 6. Slot 1 has Drop Token btn; slots 2–6 show as empty
|
||||
slot_1 = slots[0]
|
||||
slot_1.find_element(By.CSS_SELECTOR, ".drop-token-btn")
|
||||
for slot in slots[1:]:
|
||||
for slot in slots:
|
||||
self.assertIn("empty", slot.get_attribute("class"))
|
||||
# 6. Shared coin slot is present; no individual drop buttons
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".token-slot")
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".drop-token-btn")), 0
|
||||
)
|
||||
|
||||
def test_founder_drops_token_and_slot_fills(self):
|
||||
# 1. Set up: log in, create room, arrive at gatekeeper
|
||||
@@ -60,20 +64,25 @@ class GatekeeperTest(FunctionalTest):
|
||||
self.wait_for(
|
||||
lambda: self.assertIn("/gate/", self.browser.current_url)
|
||||
)
|
||||
# 2. Founder clicks Drop Token on slot 1
|
||||
drop_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".drop-token-btn")
|
||||
# 2. Founder clicks Insert Token via the shared coin slot
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
# 3. Slot 1 (lowest) now shows OK button; slot is reserved
|
||||
ok_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, ".gate-slot[data-slot='1'] .btn-confirm"
|
||||
)
|
||||
)
|
||||
drop_btn.click()
|
||||
|
||||
# 3. Slot 1 now filled; drop btn gone
|
||||
# 4. Founder clicks OK → slot fills
|
||||
ok_btn.click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".gate-slot.filled")
|
||||
)
|
||||
slots = self.browser.find_elements(By.CSS_SELECTOR, ".gate-slot")
|
||||
self.assertIn("filled", slots[0].get_attribute("class"))
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".drop-token-btn")), 0
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".btn-confirm")), 0
|
||||
)
|
||||
|
||||
def test_room_appears_in_my_games_after_creation(self):
|
||||
@@ -96,9 +105,9 @@ class GatekeeperTest(FunctionalTest):
|
||||
self.assertIn("Dragon's Den", my_games.text)
|
||||
|
||||
def test_second_gamer_drops_token_into_open_slot(self):
|
||||
# 1. Founder creates room, fills slot 1
|
||||
# 1. Founder creates room, confirms slot 1
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(self.live_server_url +"/gameboard/")
|
||||
self.browser.get(self.live_server_url + "/gameboard/")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_new_game_name")
|
||||
)
|
||||
@@ -108,11 +117,16 @@ class GatekeeperTest(FunctionalTest):
|
||||
lambda: self.assertIn("/gate/", self.browser.current_url)
|
||||
)
|
||||
room_url = self.browser.current_url
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".drop-token-btn").click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".btn-confirm")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".gate-slot.filled")
|
||||
)
|
||||
# 2. Founder invites friend via email (duplicate invite logic from My Notes applet)
|
||||
# 2. Founder invites friend
|
||||
invite_input = self.wait_for(
|
||||
lambda: self.browser.find_element(By.ID, "id_invite_email")
|
||||
)
|
||||
@@ -125,14 +139,16 @@ class GatekeeperTest(FunctionalTest):
|
||||
lambda: self.browser.find_element(By.ID, "id_applet_my_games")
|
||||
)
|
||||
self.assertIn("Dragon's Den", my_games.text)
|
||||
# 3. Friend follows link to gatekeeper
|
||||
# 4. Friend follows link to gatekeeper
|
||||
self.browser.find_element(By.LINK_TEXT, "Dragon's Den").click()
|
||||
# 4. Friend sees drop btn on open slot
|
||||
drop_btn = self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".drop-token-btn")
|
||||
)
|
||||
drop_btn.click()
|
||||
# 5. Now two slots filled
|
||||
# 5. Friend drops token via coin slot and confirms
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".btn-confirm")
|
||||
).click()
|
||||
# 6. Now two slots filled
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".gate-slot.filled")), 2
|
||||
@@ -151,12 +167,17 @@ class GatekeeperTest(FunctionalTest):
|
||||
self.wait_for(
|
||||
lambda: self.assertIn("/gate/", self.browser.current_url)
|
||||
)
|
||||
room_url = self.browser.current_url
|
||||
# 2. Fill all 6 slots directly via ORM (founder + 5 extras)
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".drop-token-btn").click()
|
||||
# 2. Founder confirms slot 1 via coin slot
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".btn-confirm")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".gate-slot.filled")
|
||||
)
|
||||
# 3. Fill slots 2–6 directly via ORM
|
||||
room = Room.objects.get(name="Dragon's Den")
|
||||
for i, email in enumerate([
|
||||
"g2@test.io", "g3@test.io", "g4@test.io", "g5@test.io", "g6@test.io"
|
||||
@@ -169,15 +190,12 @@ class GatekeeperTest(FunctionalTest):
|
||||
room.refresh_from_db()
|
||||
room.gate_status = Room.OPEN
|
||||
room.save()
|
||||
# 3. Gatekeeper disappears via htmx
|
||||
# 4. Gatekeeper disappears via htmx
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".gate-modal")), 0
|
||||
)
|
||||
)
|
||||
# Restore the following once room built
|
||||
# body = self.browser.find_element(By.TAG_NAME, "body")
|
||||
# self.assertIn("OPEN", body.text)
|
||||
|
||||
def test_owner_can_delete_room_via_gear_menu(self):
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
@@ -237,3 +255,124 @@ class GatekeeperTest(FunctionalTest):
|
||||
slot.refresh_from_db()
|
||||
self.assertEqual(slot.status, "EMPTY")
|
||||
self.assertIsNone(slot.gamer)
|
||||
|
||||
|
||||
class CoinSlotTest(FunctionalTest):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
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"}
|
||||
)
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.founder = User.objects.get(email="founder@test.io")
|
||||
self.room = Room.objects.create(name="Coin Room", owner=self.founder)
|
||||
self.gate_url = self.live_server_url + f"/gameboard/room/{self.room.id}/gate/"
|
||||
|
||||
def test_coin_slot_active_for_eligible_gamer(self):
|
||||
# Gamer with no slot arrives at gatekeeper — coin slot is active
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-slot.active")
|
||||
)
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
|
||||
def test_drop_token_reserves_lowest_empty_slot(self):
|
||||
# Gamer drops token; slot 1 (lowest) becomes reserved with OK button
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, ".gate-slot[data-slot='1'] .btn-confirm"
|
||||
)
|
||||
)
|
||||
slot = self.room.gate_slots.get(slot_number=1)
|
||||
slot.refresh_from_db()
|
||||
self.assertEqual(slot.status, GateSlot.RESERVED)
|
||||
self.assertEqual(slot.gamer, self.founder)
|
||||
|
||||
def test_confirm_fills_slot_and_removes_ok_button(self):
|
||||
# Drop then confirm → slot 1 FILLED, OK button gone
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".btn-confirm")
|
||||
).click()
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".gate-slot.filled")
|
||||
)
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".btn-confirm")), 0
|
||||
)
|
||||
slot = self.room.gate_slots.get(slot_number=1)
|
||||
slot.refresh_from_db()
|
||||
self.assertEqual(slot.status, GateSlot.FILLED)
|
||||
|
||||
def test_gamer_can_reject_pending_token(self):
|
||||
# Drop then reject via Push to Reject → slot remains empty
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
# Push to Reject appears in coin slot
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-reject-btn")
|
||||
).click()
|
||||
# Slot 1 still empty; coin slot active again
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-slot.active")
|
||||
)
|
||||
slot = self.room.gate_slots.get(slot_number=1)
|
||||
slot.refresh_from_db()
|
||||
self.assertEqual(slot.status, GateSlot.EMPTY)
|
||||
|
||||
def test_coin_slot_locked_while_another_token_is_pending(self):
|
||||
# Pre-set slot 1 as RESERVED by a different user
|
||||
other = User.objects.create(email="other@test.io")
|
||||
slot = self.room.gate_slots.get(slot_number=1)
|
||||
slot.gamer = other
|
||||
slot.status = GateSlot.RESERVED
|
||||
slot.reserved_at = timezone.now()
|
||||
slot.save()
|
||||
# Current user (founder) sees coin slot locked
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-slot.locked")
|
||||
)
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".token-insert-btn")), 0
|
||||
)
|
||||
|
||||
def test_last_gamer_sees_pick_roles_button(self):
|
||||
# Fill slots 1–5 via ORM; slot 6 empty
|
||||
for i, email in enumerate([
|
||||
"g1@test.io", "g2@test.io", "g3@test.io", "g4@test.io", "g5@test.io"
|
||||
], start=1):
|
||||
gamer = User.objects.create(email=email)
|
||||
slot = self.room.gate_slots.get(slot_number=i)
|
||||
slot.gamer = gamer
|
||||
slot.status = GateSlot.FILLED
|
||||
slot.save()
|
||||
# Founder (no slot yet) drops token → gets slot 6
|
||||
self.browser.get(self.gate_url)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".token-insert-btn")
|
||||
).click()
|
||||
# Slot 6 shows PICK ROLES instead of OK
|
||||
self.wait_for(
|
||||
lambda: self.assertIn(
|
||||
"PICK ROLES",
|
||||
self.browser.find_element(
|
||||
By.CSS_SELECTOR, ".gate-slot[data-slot='6']"
|
||||
).text,
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, ".btn-confirm")), 0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user