Skip to content

Commit 7596eea

Browse files
Merge branch 'main' of https://github.com/NHSDigital/bcss-playwright into feature/BCSS-20478-c6-pom-handover-into-symptomatic-care-page
2 parents 1f91908 + 6742386 commit 7596eea

File tree

9 files changed

+1216
-233
lines changed

9 files changed

+1216
-233
lines changed

docs/utility-guides/BatchProcessing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ This will call the other two functions in order to successfully process a batch.
4343
- Type: `str`
4444
- This is the description of the batch. For example: **Pre-invitation (FIT)** or **Post-investigation Appointment NOT Required**
4545
- `latest_event_status`:
46-
- Type: `str`
47-
- This is the status the subject will get updated to after the batch has been processed. It is used to check that the subject has been updated to the correct status after a batch has been printed
46+
- Type: `str | None`
47+
- This is the status the subject will get updated to after the batch has been processed. It is used to check that the subject has been updated to the correct status after a batch has been printed. If there are multiple different status in the same batch, provide them all in a list.
4848

4949
#### Optional Arguments
5050

pages/datasets/investigation_dataset_page.py

Lines changed: 834 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
from datetime import datetime
4+
from utils.calendar_picker import CalendarPicker
5+
6+
7+
class RecordDiagnosisDatePage(BasePage):
8+
"""Record Diagnosis Date Page locators, and methods for interacting with the page."""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
13+
# Record Diagnosis Date - page locators
14+
self.diagnosis_date_field = self.page.locator("#diagnosisDate")
15+
self.save_button = self.page.get_by_role("button", name="Save")
16+
17+
def enter_date_in_diagnosis_date_field(self, date: datetime) -> None:
18+
"""
19+
Enters a date in the diagnosis date field.
20+
Args:
21+
date (datetime): The date to enter in the field.
22+
"""
23+
self.click(self.diagnosis_date_field)
24+
CalendarPicker(self.page).v2_calendar_picker(date)
25+
self.diagnosis_date_field.press("Enter")
26+
27+
def click_save_button(self) -> None:
28+
"""Clicks the save button."""
29+
self.click(self.save_button)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def __init__(self, page: Page):
5656
"button", name="Advance FOBT Screening Episode"
5757
)
5858

59+
def wait_for_page_title(self) -> None:
60+
"""Waits for the page to be the Subject Screening Summary"""
61+
self.subject_screening_summary.wait_for()
62+
5963
def verify_result_contains_text(self, text) -> None:
6064
"""Verify that the result contains the given text."""
6165
expect(self.display_rs).to_contain_text(text)
@@ -84,17 +88,37 @@ def verify_latest_event_status_header(self) -> None:
8488
"""Verify that the latest event status header is visible."""
8589
expect(self.latest_event_status).to_be_visible()
8690

87-
def verify_latest_event_status_value(self, latest_event_status: str) -> None:
91+
def verify_latest_event_status_value(self, latest_event_status: str | list) -> None:
8892
"""Verify that the latest event status value is visible."""
89-
logging.info(f"Verifying subject has the status: {latest_event_status}")
90-
latest_event_status_cell = self.get_latest_event_status_cell(
93+
self.wait_for_page_title()
94+
latest_event_status_locator = self.get_visible_status_from_list(
9195
latest_event_status
9296
)
97+
status = latest_event_status_locator.inner_text()
98+
logging.info(f"Verifying subject has the status: {status}")
9399
try:
94-
expect(latest_event_status_cell).to_be_visible()
95-
logging.info(f"Subject has the status: {latest_event_status}")
100+
expect(latest_event_status_locator).to_be_visible()
101+
logging.info(f"Subject has the status: {status}")
96102
except Exception:
97-
pytest.fail(f"Subject does not have the status: {latest_event_status}")
103+
pytest.fail(f"Subject does not have the status: {status}")
104+
105+
def get_visible_status_from_list(self, latest_event_status) -> Locator:
106+
"""
107+
Get the first visible status from the latest event status string or list.
108+
109+
Args:
110+
latest_event_status (str | list): The latest event status to check.
111+
112+
Returns:
113+
Locator: The locator for the first visible status.
114+
"""
115+
if isinstance(latest_event_status, str):
116+
latest_event_status = [latest_event_status]
117+
for status in latest_event_status:
118+
locator = self.page.get_by_role("cell", name=status, exact=True)
119+
if locator.is_visible():
120+
return locator
121+
logging.error("Unable to find any of the listed statuses")
98122

99123
def click_subjects_events_notes(self) -> None:
100124
"""Click on the 'Subject Events & Notes' link."""

0 commit comments

Comments
 (0)