Skip to content

Commit 237b847

Browse files
committed
refactoring
1 parent de168a9 commit 237b847

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def enter_type_filter(self, option_text: str) -> None:
101101
self.type_filter.select_option(label=option_text)
102102
logging.info(f"[FILTER] Type filter set to '{option_text}'")
103103

104-
105104
def enter_original_filter(self, search_text: str) -> None:
106105
self.original_filter.fill(search_text)
107106
self.original_filter.press("Enter")
@@ -200,19 +199,19 @@ def get_open_original_batch_row(self) -> Locator | None:
200199
Returns:
201200
Locator of the matching <tr> element, or None if not found.
202201
"""
203-
rows = self.page.locator(f"{self.table_selector} tbody tr")
204-
for i in range(rows.count()):
205-
row = rows.nth(i)
206-
type_cell = row.locator("td").nth(1) # Assuming Type is 2nd column
207-
status_cell = row.locator("td").nth(8) # Assuming Status is 9th column
202+
table = TableUtils(self.page, "table#batchList")
203+
row_count = table.get_row_count()
208204

205+
for i in range(row_count):
206+
row_data = table.get_row_data_with_headers(i)
209207
if (
210-
"Original" in type_cell.inner_text()
211-
and "Open" in status_cell.inner_text()
208+
row_data.get("Type", "").strip() == "Original"
209+
and row_data.get("Status", "").strip() == "Open"
212210
):
213-
return row
211+
return table.pick_row(i)
214212
return None
215213

214+
216215
def assert_s83f_batch_present(self) -> None:
217216
self.enter_type_filter("Original")
218217
self.enter_event_code_filter("S83")
@@ -232,9 +231,8 @@ def __init__(self, page: Page):
232231

233232
def select_first_archived_batch(self) -> None:
234233
"""Clicks the first batch ID link in the archived batch list."""
235-
first_batch_link = self.page.locator(
236-
f"{self.table_selector} tbody tr td.id a"
237-
).first
234+
first_batch_link = self.page.locator("table#batchList tbody tr td.id a").first
235+
first_batch_link.wait_for(timeout=10000)
238236
assert first_batch_link.count() > 0, "No archived batch links found"
239237
first_batch_link.click()
240238

@@ -310,8 +308,9 @@ def assert_letter_component_present(self, letter_type: str, format: str) -> None
310308
match_found = True
311309
break
312310

313-
assert match_found, f"Letter type '{letter_type}' with format '{format}' not found"
314-
311+
assert (
312+
match_found
313+
), f"Letter type '{letter_type}' with format '{format}' not found"
315314

316315
def get_first_subject_nhs_number(self) -> str:
317316
"""
@@ -322,11 +321,12 @@ def get_first_subject_nhs_number(self) -> str:
322321
"""
323322
table_utils = TableUtils(self.page, "table#letterBatchDetails")
324323
row_data = table_utils.get_row_data_with_headers(0) # First row (0-based index)
325-
324+
326325
nhs_number = row_data.get("NHS Number")
327326
if not nhs_number:
328-
raise RuntimeError("NHS Number not found in the first row of the letter batch table")
327+
raise RuntimeError(
328+
"NHS Number not found in the first row of the letter batch table"
329+
)
329330

330331
logging.info(f"Retrieved NHS number from batch: {nhs_number}")
331332
return nhs_number
332-

pages/communication_production/manage_active_batch_page.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def click_confirm_button(self) -> None:
3535
def assert_active_batch_details_visible(self) -> None:
3636
"""Asserts that the Manage Active Batch screen has loaded by checking the page title."""
3737
page_title = self.page.locator("#page-title")
38+
page_title.wait_for(timeout=10000)
3839
expect(page_title).to_have_text("Manage Active Batch")
3940

4041
def retrieve_and_confirm_letters(self) -> None:

tests/regression/communications_production/test_basic_active_batch_list_functionality.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ def test_navigation_to_manage_active_batch_screen(select_user) -> None:
8282

8383
# Step 3: Assert navigation to the Manage Active Batch page
8484
manage_batch_page = ManageActiveBatchPage(page)
85-
manage_batch_page.assert_batch_details_visible()
85+
manage_batch_page.assert_active_batch_details_visible()

tests/regression/communications_production/test_basic_manage_archived_batch_functionality.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _login_as(user_role: str):
2929

3030
return _login_as
3131

32-
32+
@pytest.mark.wip
3333
@pytest.mark.letters_tests
3434
@pytest.mark.regression
3535
def test_reprint_and_archive_letter_batch(select_user) -> None:
@@ -89,6 +89,7 @@ def test_reprint_and_archive_letter_batch(select_user) -> None:
8989
manage_archived_page.confirm_archived_message_visible()
9090

9191

92+
@pytest.mark.wip
9293
@pytest.mark.letters_tests
9394
@pytest.mark.regression
9495
def test_check_that_s1_has_supplementary_batches(select_user) -> None:

0 commit comments

Comments
 (0)