Skip to content

Commit fb0bd59

Browse files
committed
Some refactoring
Updated some docstrings Updated assert_latest_event_status to be more robust Centralised SUBJECT VIEW logging by moving it into navigate_to_subject_summary_page
1 parent c9bd998 commit fb0bd59

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from playwright.sync_api import Page, expect, Locator
22
from pages.base_page import BasePage
33
from datetime import datetime
4-
from pages.communication_production.communications_production_page import CommunicationsProductionPage
4+
from pages.communication_production.communications_production_page import (
5+
CommunicationsProductionPage,
6+
)
57
from utils.calendar_picker import CalendarPicker
68
from utils.table_util import TableUtils
79
import logging
@@ -228,7 +230,10 @@ def select_first_active_batch(self) -> None:
228230
self.select_first_batch_row(self.table_selector, timeout_ms=10000)
229231

230232
def is_batch_present(self, batch_type: str) -> bool:
231-
"""Checks if a batch of the given type exists in the active batch list."""
233+
"""Checks if a batch of the given type exists in the active batch list.
234+
Args:
235+
batch_type (str): The type of the batch to check for e.g. "S1 - Pre-invitation (FIT)"
236+
"""
232237
locator = self.page.locator(
233238
f"{self.table_selector} tbody tr td", has_text=batch_type
234239
)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def navigate_to_spine_search(self) -> None:
331331
Navigates to the Spine Search screen by clicking the appropriate link
332332
and loading the target URL.
333333
"""
334-
#self.retrieve_data_link.click()
334+
# self.retrieve_data_link.click()
335335
self.click(self.retrieve_data_link)
336336
self.page.goto(self.spine_url)
337337

@@ -377,15 +377,17 @@ def assert_latest_event_status(self, expected_status: str) -> None:
377377
Asserts that the latest event status displayed in the summary table matches the expected value.
378378
379379
Args:
380-
expected_status (str): The expected event status (e.g., 'S9 Pre-invitation Sent').
380+
expected_status (str): The expected event status (e.g., 'S9 - Pre-invitation Sent').
381381
382382
Raises:
383383
AssertionError: If the status in the UI does not match the expected value.
384384
"""
385-
actual_status = self.latest_event_status_cell.inner_text().strip()
386-
assert actual_status == expected_status, (
387-
f"[LATEST EVENT STATUS MISMATCH] Expected '{expected_status}', but found '{actual_status}' in UI."
388-
)
385+
cell = self.get_latest_event_status_cell(expected_status)
386+
actual_status = cell.inner_text().strip()
387+
assert (
388+
actual_status == expected_status
389+
), f"[LATEST EVENT STATUS MISMATCH] Expected '{expected_status}', but found '{actual_status}' in UI."
390+
389391

390392
class ChangeScreeningStatusOptions(Enum):
391393
"""Enum for Change Screening Status options."""

tests/regression/regression_tests/fobt_regression_tests/test_scenario_2.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ def test_scenario_2(page: Page) -> None:
7070
"screening status": "Inactive",
7171
},
7272
)
73-
logging.info("[DB ASSERTIONS COMPLETE] Created subject's details checked in the DB")
73+
logging.info("[DB ASSERTIONS COMPLETE] Created subject details checked in the DB")
7474

7575
# Navigate to subject summary page in UI
7676
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
77-
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
7877

7978
# Assert subject details in the UI
8079
summary_page.assert_subject_age(66)
@@ -100,11 +99,10 @@ def test_scenario_2(page: Page) -> None:
10099
"Screening Status Reason": "Failsafe Trawl",
101100
},
102101
)
103-
logging.info("[DB ASSERTIONS COMPLETE]Updated subject details checked in the DB")
102+
logging.info("[DB ASSERTIONS COMPLETE] Updated subject details checked in the DB")
104103

105104
# Navigate to subject summary page in UI
106105
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
107-
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
108106

109107
# Assert subject details in the UI
110108
summary_page.assert_screening_status("Inactive")
@@ -180,7 +178,6 @@ def test_scenario_2(page: Page) -> None:
180178

181179
# Navigate to subject summary page in UI
182180
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
183-
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
184181

185182
# Assert subject details in the UI
186183
summary_page.assert_latest_event_status(
@@ -202,7 +199,6 @@ def test_scenario_2(page: Page) -> None:
202199

203200
# Navigate to subject summary page in UI
204201
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
205-
logging.info(f"[SUBJECT VIEW] Subject {nhs_no} loaded in UI")
206202

207203
# Assert subject details in the UI
208204
summary_page.assert_latest_event_status("S2 - Normal")

utils/fit_kit.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ def read_latest_logged_kit(
240240
) -> None:
241241
"""
242242
Reads the subject's latest logged FIT kit and updates its status/result.
243+
Args:
244+
user (UserRoleType): The user performing the action.
245+
kit_type (int): The type of the kit.
246+
kit (str): The FIT kit ID to be read.
247+
kit_result (str): The result of the kit reading. Valid values are "NORMAL", "ABNORMAL", "SPOILT", "TECHNICAL_FAILURE".
243248
"""
244249
logging.info("start: read_latest_logged_kit")
245250

@@ -300,7 +305,13 @@ def read_latest_logged_kit(
300305
logging.info("exit: read_latest_logged_kit")
301306

302307
def log_fit_kit(self, page: Page, nhs_no: str) -> str:
303-
"""Logs the FIT kit for a given subject."""
308+
"""Logs the FIT kit for a given subject.
309+
Args:
310+
page (Page): The Playwright page object.
311+
nhs_no (str): The NHS number of the subject.
312+
Returns:
313+
str: The FIT kit ID that was successfully logged.
314+
"""
304315
BasePage(page).click_main_menu_link()
305316
fit_kit = FitKitGeneration().get_fit_kit_for_subject_sql(nhs_no, False, False)
306317
BasePage(page).go_to_fit_test_kits_page()

0 commit comments

Comments
 (0)