covered some test lacunae; gatekeeper now waits for +6 gamers to commit tokens to unblock game room

This commit is contained in:
Disco DeDisco
2026-03-13 22:51:42 -04:00
parent e0d1f51bf1
commit dddffd22d5
11 changed files with 121 additions and 8 deletions

View File

@@ -2,6 +2,8 @@ from selenium.webdriver.common.by import By
from .base import FunctionalTest
from apps.applets.models import Applet
from apps.epic.models import Room, GateSlot
from apps.lyric.models import User
class GatekeeperTest(FunctionalTest):
@@ -134,3 +136,43 @@ class GatekeeperTest(FunctionalTest):
len(self.browser.find_elements(By.CSS_SELECTOR, ".gate-slot.filled")), 2
)
)
def test_gate_opens_when_all_slots_filled(self):
# 1. Founder creates room
self.create_pre_authenticated_session("founder@test.io")
self.browser.get(self.live_server_url + "/gameboard/")
self.wait_for(
lambda: self.browser.find_element(By.ID, "id_new_game_name")
)
self.browser.find_element(By.ID, "id_new_game_name").send_keys("Dragon's Den")
self.browser.find_element(By.ID, "id_create_game_btn").click()
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()
self.wait_for(
lambda: self.browser.find_element(By.CSS_SELECTOR, ".gate-slot.filled")
)
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"
], start=2):
gamer = User.objects.create(email=email)
slot = room.gate_slots.get(slot_number=i)
slot.gamer = gamer
slot.status = GateSlot.FILLED
slot.save()
room.refresh_from_db()
room.gate_status = Room.OPEN
room.save()
# 3. 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)