Skip to content

Commit 2cda009

Browse files
committed
copy changes from broken branch
1 parent 62254ec commit 2cda009

File tree

9 files changed

+476
-31
lines changed

9 files changed

+476
-31
lines changed

classes/subject_selection_criteria_key.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class SubjectSelectionCriteriaKey(Enum):
276276
SUBJECT_HAS_DIAGNOSTIC_TESTS = ("subject has diagnostic tests", False, False)
277277
SUBJECT_HAS_EPISODES = ("subject has episodes", False, False)
278278
SUBJECT_HAS_EVENT_STATUS = ("subject has event status", False, False)
279+
SUBJECT_IS_DUE_FOR_INVITE = ("subject is due for invite", False, False)
279280
SUBJECT_DOES_NOT_HAVE_EVENT_STATUS = (
280281
"subject does not have event status",
281282
False,

classes/temporary_address_type.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class TemporaryAddressType:
2+
"""
3+
Utility class for handling temporary address type values.
4+
5+
Members:
6+
YES: Represents a 'yes' value.
7+
NO: Represents a 'no' value.
8+
EXPIRED: Represents an 'expired' value.
9+
CURRENT: Represents a 'current' value.
10+
FUTURE: Represents a 'future' value.
11+
12+
Methods:
13+
from_description(description: str) -> str:
14+
Returns the normalized value for a given description.
15+
Raises ValueError if the description is not recognized.
16+
"""
17+
18+
YES = "yes"
19+
NO = "no"
20+
EXPIRED = "expired"
21+
CURRENT = "current"
22+
FUTURE = "future"
23+
24+
_valid = {YES, NO, EXPIRED, CURRENT, FUTURE}
25+
26+
@classmethod
27+
def from_description(cls, description: str) -> str:
28+
"""
29+
Returns the normalized value for a given description.
30+
31+
Args:
32+
description (str): The input description to normalize.
33+
34+
Returns:
35+
str: 'yes', 'no', 'expired', 'current', 'future'.
36+
37+
Raises:
38+
ValueError: If the description is not recognized as 'yes', 'no', 'expired', 'current', 'future'.
39+
"""
40+
key = description.strip().lower()
41+
if key not in cls._valid:
42+
raise ValueError(f"Expected 'yes', 'no', 'expired', 'current', 'future', got: '{description}'")
43+
return key

pages/base_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ def main_menu_header_is_displayed(self) -> None:
134134
"""
135135
expect(self.main_menu__header).to_contain_text(self.main_menu_string)
136136

137+
def page_title_contains_text(self, text: str) -> None:
138+
self.bowel_cancer_screening_page_title_contains_text(text)
139+
137140
def bowel_cancer_screening_page_title_contains_text(self, text: str) -> None:
138141
"""Asserts that the page title contains the specified text.
139142
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from enum import Enum
2+
from playwright.sync_api import Page, expect
3+
from pages.base_page import BasePage
4+
from datetime import datetime
5+
from utils.calendar_picker import CalendarPicker
6+
from utils.nhs_number_tools import NHSNumberTools
7+
from utils.table_util import TableUtils
8+
import logging
9+
10+
11+
class SubjectsToBeInvitedWithTemporaryAddressPage(BasePage):
12+
"""Subjects To Be Invited with Temporary Address Page locators, and methods for interacting with the page."""
13+
14+
def __init__(self, page: Page):
15+
super().__init__(page)
16+
self.page = page
17+
18+
self.title = "Subjects To Be Invited with Temporary Address";
19+
self.nhs_filter = self.page.locator("#nhsNumberFilter")
20+
21+
self.subjects_to_be_invited_with_temporary_address_report_page = self.page.get_by_role("link", name="Subjects To Be Invited with Temporary Address")
22+
self.report_table = TableUtils(page, "#tobeinvitedtemporaryaddress")
23+
24+
def go_to_page(self) -> None:
25+
logging.info(f"Go to '{self.title}'")
26+
""f"Click the '{self.title}' link."""
27+
self.click(self.subjects_to_be_invited_with_temporary_address_report_page)
28+
29+
def verify_page_title(self) -> None:
30+
logging.info(f"Verify title as '{self.title}'")
31+
""f"Verifies that the {self.title} page title is displayed correctly."""
32+
self.page_title_contains_text(self.title)
33+
34+
def filter_by_nhs_number(self, search_text: str) -> None:
35+
logging.info(f"filter_by_nhs_number : {search_text}")
36+
"""Enter text in the NHS Number filter and press Enter"""
37+
self.nhs_filter.fill(search_text)
38+
self.nhs_filter.press("Enter")
39+
40+
def assertRecordsVisible(self, nhs_no: str, expectedVisible: bool) -> None:
41+
logging.info(f"Attempting to check if records for {nhs_no} are visible : {expectedVisible}")
42+
43+
subject_summary_link = self.page.get_by_role(
44+
"link", name = NHSNumberTools().spaced_nhs_number(nhs_no)
45+
)
46+
47+
logging.info(f"subject_summary_link.is_visible() : {subject_summary_link.is_visible()}")
48+
if (
49+
expectedVisible != subject_summary_link.is_visible()
50+
):
51+
raise ValueError(
52+
f"Record for {NHSNumberTools().spaced_nhs_number(nhs_no)} does not have expected visibility : {expectedVisible}. Was in fact {subject_summary_link.is_visible()}."
53+
)
54+
55+
def filterByReviewed(self, filterValue: str) -> None:
56+
logging.info(f"Filter reviewed column by : {filterValue}")
57+
58+
filterBox = self.page.locator("#reviewedFilter")
59+
filterBox.click()
60+
filterBox.select_option(filterValue)
61+
62+
def reviewSubject(self, nhs_no: str, reviewed: bool) -> None:
63+
logging.info(f"Mark subject {nhs_no} as reviewed: {reviewed}")
64+
65+
row = self.page.locator(f'tr:has-text("{NHSNumberTools().spaced_nhs_number(nhs_no)}")')
66+
lastCell = row.get_by_role("cell").nth(-1)
67+
checkbox = lastCell.get_by_role("checkbox")
68+
checkbox.set_checked(reviewed)
69+
70+
def click_subject_link(self, nhs_no: str) -> None:
71+
subject_summary_link = self.page.get_by_role(
72+
"link", name = NHSNumberTools().spaced_nhs_number(nhs_no)
73+
)
74+
subject_summary_link.click()

pages/screening_subject_search/subject_demographic_page.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
from pages.base_page import BasePage
33
from datetime import datetime
44
from utils.calendar_picker import CalendarPicker
5-
5+
import logging
66

77
class SubjectDemographicPage(BasePage):
88
"""Subject Demographic Page locators, and methods for interacting with the page."""
99

1010
def __init__(self, page: Page):
1111
super().__init__(page)
1212
self.page = page
13+
14+
self.title = "Subject Demographic";
15+
1316
# Subject Demographic - page filters
1417
self.forename_field = self.page.get_by_role("textbox", name="Forename")
1518
self.surname_field = self.page.get_by_role("textbox", name="Surname")
@@ -54,6 +57,11 @@ def __init__(self, page: Page):
5457
"#UI_SUBJECT_ALT_POSTCODE_0"
5558
)
5659

60+
def verify_page_title(self) -> None:
61+
logging.info(f"Verify title as '{self.title}'")
62+
""f"Verifies that the {self.title} page title is displayed correctly."""
63+
self.page_title_contains_text(self.title)
64+
5765
def is_forename_filled(self) -> bool:
5866
"""
5967
Checks if the forename textbox contains a value.

0 commit comments

Comments
 (0)