43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
|
|
from selenium.webdriver.common.by import By
|
|||
|
|
|
|||
|
|
from .base import FunctionalTest
|
|||
|
|
from apps.applets.models import Applet
|
|||
|
|
|
|||
|
|
|
|||
|
|
class GatekeeperTest(FunctionalTest):
|
|||
|
|
def setUp(self):
|
|||
|
|
super().setUp()
|
|||
|
|
Applet.objects.get_or_create(
|
|||
|
|
slug="new-game", defaults={"name": "New Game", "context": "gameboard"}
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
def test_founder_creates_room_and_sees_gatekeeper(self):
|
|||
|
|
# 1. Log in, navigate to gameboard
|
|||
|
|
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(
|
|||
|
|
lambda: self.browser.find_element(By.ID, "id_applet_new_game")
|
|||
|
|
)
|
|||
|
|
self.browser.find_element(By.ID, "id_new_game_name").send_keys("Test Room")
|
|||
|
|
self.browser.find_element(By.ID, "id_create_game_btn").click()
|
|||
|
|
# 3. User is redirected to Gatekeeper page for new room
|
|||
|
|
self.wait_for(
|
|||
|
|
lambda: self.assertIn("/gameboard/room/", self.browser.current_url)
|
|||
|
|
)
|
|||
|
|
self.wait_for(
|
|||
|
|
lambda: self.assertIn("/gate/", self.browser.current_url)
|
|||
|
|
)
|
|||
|
|
# 4. Page shows room name, GATHERING status
|
|||
|
|
body = self.browser.find_element(By.TAG_NAME, "body")
|
|||
|
|
self.assertIn("Test Room", body.text)
|
|||
|
|
self.assertIn("GATHERING", body.text)
|
|||
|
|
# 5. Six token slots are visible
|
|||
|
|
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:]:
|
|||
|
|
self.assertIn("empty", slot.get_attribute("class"))
|