demo'd old inventory area in room.html to make way for new content (hex table now centered in view); old test suite now targets Role card in #id_tray cells where appropriate, or skips Sig card select until aforementioned new feature deployed; new scripts & jasmine tests too; removed one irrelevant test case from apps.epic.tests.ITs.test_views.SelectRoleViewTest
This commit is contained in:
@@ -216,14 +216,7 @@ class RoleSelectTest(FunctionalTest):
|
||||
)
|
||||
)
|
||||
|
||||
# 7. Role card appears in inventory
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, "#id_inv_role_card .card"
|
||||
)
|
||||
)
|
||||
|
||||
# 8. Card stack returns to table centre
|
||||
# 7. Card stack returns to table centre
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".card-stack")
|
||||
)
|
||||
@@ -323,46 +316,6 @@ class RoleSelectTest(FunctionalTest):
|
||||
cards = self.browser.find_elements(By.CSS_SELECTOR, "#id_role_select .card")
|
||||
self.assertEqual(len(cards), 5)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Test 3d — Previously selected roles appear in inventory on re-entry#
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_previously_selected_roles_shown_in_inventory_on_re_entry(self):
|
||||
"""A multi-slot gamer who already chose some roles should see those
|
||||
role cards pre-populated in the inventory when they re-enter the room."""
|
||||
from apps.epic.models import TableSeat
|
||||
founder, _ = User.objects.get_or_create(email="founder@test.io")
|
||||
room = Room.objects.create(name="Inventory Re-entry Test", owner=founder)
|
||||
_fill_room_via_orm(room, [
|
||||
"founder@test.io", "founder@test.io",
|
||||
"bud@test.io", "pal@test.io", "dude@test.io", "bro@test.io",
|
||||
])
|
||||
room.table_status = Room.ROLE_SELECT
|
||||
room.save()
|
||||
|
||||
for slot in room.gate_slots.order_by("slot_number"):
|
||||
TableSeat.objects.create(
|
||||
room=room, gamer=slot.gamer, slot_number=slot.slot_number,
|
||||
)
|
||||
# Founder's first slot has already chosen BC
|
||||
TableSeat.objects.filter(room=room, slot_number=1).update(role="BC")
|
||||
|
||||
room_url = f"{self.live_server_url}/gameboard/room/{room.id}/gate/"
|
||||
self.create_pre_authenticated_session("founder@test.io")
|
||||
self.browser.get(room_url)
|
||||
|
||||
# Inventory should contain exactly one pre-rendered card for BC
|
||||
inv_cards = self.wait_for(
|
||||
lambda: self.browser.find_elements(
|
||||
By.CSS_SELECTOR, "#id_inv_role_card .card"
|
||||
)
|
||||
)
|
||||
self.assertEqual(len(inv_cards), 1)
|
||||
self.assertIn(
|
||||
"BUILDER",
|
||||
inv_cards[0].text.upper(),
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Test 4 — Click-away dismisses fan without selecting #
|
||||
# ------------------------------------------------------------------ #
|
||||
@@ -392,17 +345,13 @@ class RoleSelectTest(FunctionalTest):
|
||||
# Click the backdrop (outside the fan)
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".role-select-backdrop").click()
|
||||
|
||||
# Modal closes; stack still present; inventory still empty
|
||||
# Modal closes; stack still present
|
||||
self.wait_for(
|
||||
lambda: self.assertEqual(
|
||||
len(self.browser.find_elements(By.ID, "id_role_select")), 0
|
||||
)
|
||||
)
|
||||
self.browser.find_element(By.CSS_SELECTOR, ".card-stack")
|
||||
self.assertEqual(
|
||||
len(self.browser.find_elements(By.CSS_SELECTOR, "#id_inv_role_card .card")),
|
||||
0
|
||||
)
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
@@ -529,17 +478,9 @@ class RoleSelectTest(FunctionalTest):
|
||||
|
||||
self.browser.refresh()
|
||||
|
||||
# All role cards in inventory are face-up
|
||||
face_up_cards = self.wait_for(
|
||||
lambda: self.browser.find_elements(
|
||||
By.CSS_SELECTOR, "#id_inv_role_card .card.face-up"
|
||||
)
|
||||
)
|
||||
self.assertGreater(len(face_up_cards), 0)
|
||||
|
||||
# Partner indicator is visible
|
||||
# Sig deck is present (page has transitioned to SIG_SELECT)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, ".partner-indicator")
|
||||
lambda: self.browser.find_element(By.ID, "id_sig_deck")
|
||||
)
|
||||
|
||||
|
||||
@@ -590,12 +531,13 @@ class RoleSelectTrayTest(FunctionalTest):
|
||||
self.confirm_guard()
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# T1 — Portrait: role card at topmost grid square, tray opens #
|
||||
# T1 — Portrait: role card marks first cell; tray opens then closes #
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
def test_portrait_role_card_enters_topmost_grid_square(self):
|
||||
"""Portrait: after confirming a role, a .tray-role-card is the first child
|
||||
of #id_tray_grid (topmost cell) and the tray is open."""
|
||||
"""Portrait: after confirming a role the first .tray-cell gets
|
||||
.tray-role-card; the grid still has exactly 8 cells; and the tray
|
||||
opens briefly then closes once the arc-in animation completes."""
|
||||
self.browser.set_window_size(390, 844)
|
||||
room = self._make_room()
|
||||
self.create_pre_authenticated_session("slot1@test.io")
|
||||
@@ -604,34 +546,42 @@ class RoleSelectTrayTest(FunctionalTest):
|
||||
self.wait_for(lambda: self.browser.find_element(By.ID, "id_tray_wrap"))
|
||||
self._select_role()
|
||||
|
||||
# Card appears in the grid.
|
||||
# First cell receives the role card class.
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, "#id_tray_grid .tray-role-card"
|
||||
)
|
||||
)
|
||||
|
||||
# It is the first child — topmost in portrait.
|
||||
is_first = self.browser.execute_script("""
|
||||
var card = document.querySelector('#id_tray_grid .tray-role-card');
|
||||
return card !== null && card === card.parentElement.firstElementChild;
|
||||
result = self.browser.execute_script("""
|
||||
var grid = document.getElementById('id_tray_grid');
|
||||
var card = grid.querySelector('.tray-role-card');
|
||||
return {
|
||||
isFirst: card !== null && card === grid.firstElementChild,
|
||||
count: grid.children.length,
|
||||
role: card ? card.dataset.role : null
|
||||
};
|
||||
""")
|
||||
self.assertTrue(is_first, "Role card should be the first child of #id_tray_grid")
|
||||
self.assertTrue(result["isFirst"], "Role card should be the first cell")
|
||||
self.assertEqual(result["count"], 8, "Grid should still have exactly 8 cells")
|
||||
self.assertTrue(result["role"], "First cell should carry data-role")
|
||||
|
||||
# Tray is open.
|
||||
self.assertTrue(
|
||||
self.browser.execute_script("return Tray.isOpen()"),
|
||||
"Tray should be open after role selection"
|
||||
# Tray closes after the animation sequence.
|
||||
self.wait_for(
|
||||
lambda: self.assertFalse(
|
||||
self.browser.execute_script("return Tray.isOpen()"),
|
||||
"Tray should close after the arc-in sequence"
|
||||
)
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# T2 — Landscape: role card at leftmost grid square, tray opens #
|
||||
# T2 — Landscape: same contract in landscape #
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
@tag('two-browser')
|
||||
def test_landscape_role_card_enters_leftmost_grid_square(self):
|
||||
"""Landscape: after confirming a role, a .tray-role-card is the first child
|
||||
of #id_tray_grid (leftmost cell) and the tray is open."""
|
||||
"""Landscape: the first .tray-cell gets .tray-role-card; grid has
|
||||
8 cells; tray opens then closes."""
|
||||
self.browser.set_window_size(844, 390)
|
||||
room = self._make_room()
|
||||
self.create_pre_authenticated_session("slot1@test.io")
|
||||
@@ -640,24 +590,28 @@ class RoleSelectTrayTest(FunctionalTest):
|
||||
self.wait_for(lambda: self.browser.find_element(By.ID, "id_tray_wrap"))
|
||||
self._select_role()
|
||||
|
||||
# Card appears in the grid.
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, "#id_tray_grid .tray-role-card"
|
||||
)
|
||||
)
|
||||
|
||||
# It is the first child — leftmost in landscape.
|
||||
is_first = self.browser.execute_script("""
|
||||
var card = document.querySelector('#id_tray_grid .tray-role-card');
|
||||
return card !== null && card === card.parentElement.firstElementChild;
|
||||
result = self.browser.execute_script("""
|
||||
var grid = document.getElementById('id_tray_grid');
|
||||
var card = grid.querySelector('.tray-role-card');
|
||||
return {
|
||||
isFirst: card !== null && card === grid.firstElementChild,
|
||||
count: grid.children.length
|
||||
};
|
||||
""")
|
||||
self.assertTrue(is_first, "Role card should be the first child of #id_tray_grid")
|
||||
self.assertTrue(result["isFirst"], "Role card should be the first cell")
|
||||
self.assertEqual(result["count"], 8, "Grid should still have exactly 8 cells")
|
||||
|
||||
# Tray is open.
|
||||
self.assertTrue(
|
||||
self.browser.execute_script("return Tray.isOpen()"),
|
||||
"Tray should be open after role selection"
|
||||
self.wait_for(
|
||||
lambda: self.assertFalse(
|
||||
self.browser.execute_script("return Tray.isOpen()"),
|
||||
"Tray should close after the arc-in sequence"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -189,12 +189,9 @@ class SigSelectTest(FunctionalTest):
|
||||
)
|
||||
)
|
||||
|
||||
# Founder's significator appears in their inventory
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR, "#id_inv_sig_card .card"
|
||||
)
|
||||
)
|
||||
# TODO: sig card should appear in the tray (tray.placeCard for sig phase)
|
||||
# once sig-select.js is updated to call Tray.placeCard instead of
|
||||
# appending to the removed #id_inv_sig_card inventory element.
|
||||
|
||||
# Active seat advances to NC
|
||||
self.wait_for(
|
||||
|
||||
Reference in New Issue
Block a user