Skip to content

Commit d7e394a

Browse files
committed
finished the scenario: basic active batch list functionality
1 parent b094b55 commit d7e394a

File tree

5 files changed

+125
-77
lines changed

5 files changed

+125
-77
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ def assert_column_sortable(self, column_name: str) -> None:
153153
def assert_column_filterable(self, column_name: str) -> None:
154154
"""Asserts that the specified column has a filter control in the second header row."""
155155
table = TableUtils(self.page, "table#batchList")
156-
column_index = table.get_column_index(column_name) - 1 # Convert 1-based to 0-based
156+
column_index = (
157+
table.get_column_index(column_name) - 1
158+
) # Convert 1-based to 0-based
157159

158160
filter_locator = (
159161
self.page.locator("table#batchList thead tr:nth-child(2) th")
@@ -164,6 +166,35 @@ def assert_column_filterable(self, column_name: str) -> None:
164166
filter_locator.count() > 0
165167
), f"Filter control not found for column '{column_name}'"
166168

169+
def assert_batch_table_visible(self) -> None:
170+
"""Asserts that the batch list table is present and rendered."""
171+
expect(self.page.locator("table#batchList")).to_be_visible()
172+
173+
def select_first_active_batch(self) -> None:
174+
"""Clicks the first batch ID link in the active batch list."""
175+
first_batch_link = self.page.locator("table#batchList tbody tr td.id a").first
176+
assert first_batch_link.count() > 0, "No active batch links found"
177+
first_batch_link.click()
178+
179+
def is_batch_present(self, batch_type: str) -> bool:
180+
"""Checks if a batch of the given type exists in the active batch list."""
181+
locator = self.page.locator(f"table#batchList tbody tr td", has_text=batch_type)
182+
return locator.count() > 0
183+
184+
def prepare_batch(self, batch_type: str) -> None:
185+
"""Finds and clicks the Prepare button for the specified batch type."""
186+
row = (
187+
self.page.locator("table#batchList tbody tr")
188+
.filter(has=self.page.locator("td", has_text=batch_type))
189+
.first
190+
)
191+
192+
prepare_button = row.locator("a", has_text="Prepare").first
193+
expect(prepare_button).to_be_visible()
194+
prepare_button.click()
195+
196+
# Optional: wait for row to disappear
197+
expect(row).not_to_be_visible(timeout=5000)
167198

168199

169200
class ArchivedBatchListPage(BatchListPage):

pages/communication_production/manage_active_batch_page.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3+
from playwright.sync_api import expect
34

45

56
class ManageActiveBatchPage(BasePage):
@@ -29,3 +30,9 @@ def click_retrieve_button(self) -> None:
2930
def click_confirm_button(self) -> None:
3031
"""Click the Confirm Printed button"""
3132
self.click(self.confirm_button)
33+
34+
def assert_batch_details_visible(self) -> None:
35+
"""Asserts that the Manage Active Batch screen has loaded by checking the page title."""
36+
page_title = self.page.locator("#page-title")
37+
expect(page_title).to_have_text("Manage Active Batch")
38+

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ markers =
4141
call_and_recall: tests that are part of the call and recall test suite
4242
subject_tests: tests that are part of the subject tests suite
4343
subject_search: tests that are part of the subject search test suite
44+
letters_tests: tests that are part of the letters test suite
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import pytest
2+
from playwright.sync_api import Page
3+
from pages.base_page import BasePage
4+
from pages.communication_production.communications_production_page import (
5+
CommunicationsProductionPage,
6+
)
7+
from pages.communication_production.batch_list_page import ActiveBatchListPage
8+
from utils.user_tools import UserTools
9+
from pages.communication_production.manage_active_batch_page import (
10+
ManageActiveBatchPage,
11+
)
12+
13+
14+
@pytest.fixture
15+
def select_user(page: Page):
16+
def _login_as(user_role: str):
17+
# Log in with the specified user
18+
UserTools.user_login(page, user_role)
19+
# Navigate to Active Batch List
20+
BasePage(page).go_to_communications_production_page()
21+
CommunicationsProductionPage(page).go_to_active_batch_list_page()
22+
return page
23+
24+
return _login_as
25+
26+
27+
@pytest.mark.letters_tests
28+
@pytest.mark.regression
29+
def test_headings_on_active_batch_list_screen(select_user) -> None:
30+
"""
31+
Scenario: Check headings on Active Batch List Screen
32+
Given I log in to BCSS "England" as user role "HubManager"
33+
When I view the active batch list
34+
Then the table contains a sortable and filterable column for "<Column Name>"
35+
"""
36+
page = select_user("Hub Manager at BCS01")
37+
batch_list_page = ActiveBatchListPage(page)
38+
39+
expected_columns = [
40+
"ID",
41+
"Type",
42+
"Original",
43+
"Event Code",
44+
"Description",
45+
"Batch Split By",
46+
"Screening Centre",
47+
"Status",
48+
"Priority",
49+
"Deadline",
50+
"Count",
51+
]
52+
53+
for column in expected_columns:
54+
# Step 1: Ensure the column is present
55+
batch_list_page.assert_column_present(column)
56+
57+
# Step 2: Assert sortable UI attribute is present
58+
batch_list_page.assert_column_sortable(column)
59+
60+
# Step 3: Assert filterable control is rendered
61+
batch_list_page.assert_column_filterable(column)
62+
63+
64+
@pytest.mark.letters_tests
65+
@pytest.mark.regression
66+
def test_navigation_to_manage_active_batch_screen(select_user) -> None:
67+
"""
68+
Scenario: Check navigation from Active Batch List Screen to Manage Active Batch Screen
69+
Given I log in to BCSS "England" as user role "HubManager"
70+
When I view the active batch list
71+
And I select an active batch
72+
Then I view the details of an active batch
73+
"""
74+
page = select_user("Hub Manager at BCS01")
75+
batch_list_page = ActiveBatchListPage(page)
76+
77+
# Step 1: Ensure the batch list table is visible
78+
batch_list_page.assert_batch_table_visible()
79+
80+
# Step 2: Click into the first available batch link (usually ID column)
81+
batch_list_page.select_first_active_batch()
82+
83+
# Step 3: Assert navigation to the Manage Active Batch page
84+
manage_batch_page = ManageActiveBatchPage(page)
85+
manage_batch_page.assert_batch_details_visible()

tests/regression/communications_production/test_basic_active_batch_list_functionality_regression.py

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)