Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions classes/subject_selection_criteria_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ class SubjectSelectionCriteriaKey(Enum):
SUBJECT_HAS_DIAGNOSTIC_TESTS = ("subject has diagnostic tests", False, False)
SUBJECT_HAS_EPISODES = ("subject has episodes", False, False)
SUBJECT_HAS_EVENT_STATUS = ("subject has event status", False, False)
SUBJECT_IS_DUE_FOR_INVITE = ("subject is due for invite", False, False)
SUBJECT_DOES_NOT_HAVE_EVENT_STATUS = (
"subject does not have event status",
False,
Expand Down
43 changes: 43 additions & 0 deletions classes/temporary_address_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class TemporaryAddressType:
"""
Utility class for handling temporary address type values.

Members:
YES: Represents a 'yes' value.
NO: Represents a 'no' value.
EXPIRED: Represents an 'expired' value.
CURRENT: Represents a 'current' value.
FUTURE: Represents a 'future' value.

Methods:
from_description(description: str) -> str:
Returns the normalized value for a given description.
Raises ValueError if the description is not recognized.
"""

YES = "yes"
NO = "no"
EXPIRED = "expired"
CURRENT = "current"
FUTURE = "future"

_valid = {YES, NO, EXPIRED, CURRENT, FUTURE}

@classmethod
def from_description(cls, description: str) -> str:
"""
Returns the normalized value for a given description.

Args:
description (str): The input description to normalize.

Returns:
str: 'yes', 'no', 'expired', 'current', 'future'.

Raises:
ValueError: If the description is not recognized as 'yes', 'no', 'expired', 'current', 'future'.
"""
key = description.strip().lower()
if key not in cls._valid:
raise ValueError(f"Expected 'yes', 'no', 'expired', 'current', 'future', got: '{description}'")
return key
3 changes: 3 additions & 0 deletions pages/base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def main_menu_header_is_displayed(self) -> None:
"""
expect(self.main_menu__header).to_contain_text(self.main_menu_string)

def page_title_contains_text(self, text: str) -> None:
self.bowel_cancer_screening_page_title_contains_text(text)

def bowel_cancer_screening_page_title_contains_text(self, text: str) -> None:
"""Asserts that the page title contains the specified text.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from enum import Enum
from playwright.sync_api import Page, expect
from pages.base_page import BasePage
from datetime import datetime
from utils.calendar_picker import CalendarPicker
from utils.nhs_number_tools import NHSNumberTools
from utils.table_util import TableUtils
import logging


class SubjectsToBeInvitedWithTemporaryAddressPage(BasePage):
"""Subjects To Be Invited with Temporary Address Page locators, and methods for interacting with the page."""

def __init__(self, page: Page):
super().__init__(page)
self.page = page

self.title = "Subjects To Be Invited with Temporary Address";
self.nhs_filter = self.page.locator("#nhsNumberFilter")

self.subjects_to_be_invited_with_temporary_address_report_page = self.page.get_by_role("link", name="Subjects To Be Invited with Temporary Address")
self.report_table = TableUtils(page, "#tobeinvitedtemporaryaddress")

def go_to_page(self) -> None:
logging.info(f"Go to '{self.title}'")
""f"Click the '{self.title}' link."""
self.click(self.subjects_to_be_invited_with_temporary_address_report_page)

def verify_page_title(self) -> None:
logging.info(f"Verify title as '{self.title}'")
""f"Verifies that the {self.title} page title is displayed correctly."""
self.page_title_contains_text(self.title)

def filter_by_nhs_number(self, search_text: str) -> None:
logging.info(f"filter_by_nhs_number : {search_text}")
"""Enter text in the NHS Number filter and press Enter"""
self.nhs_filter.fill(search_text)
self.nhs_filter.press("Enter")

def assertRecordsVisible(self, nhs_no: str, expected_visible: bool) -> None:
logging.info(f"Attempting to check if records for {nhs_no} are visible : {expected_visible}")

subject_summary_link = self.page.get_by_role(
"link", name = NHSNumberTools().spaced_nhs_number(nhs_no)
)

logging.info(f"subject_summary_link.is_visible() : {subject_summary_link.is_visible()}")
if (
expected_visible != subject_summary_link.is_visible()
):
raise ValueError(
f"Record for {NHSNumberTools().spaced_nhs_number(nhs_no)} does not have expected visibility : {expected_visible}. Was in fact {subject_summary_link.is_visible()}."
)

def filterByReviewed(self, filter_value: str) -> None:
logging.info(f"Filter reviewed column by : {filter_value}")

filter_box = self.page.locator("#reviewedFilter")
filter_box.click()
filter_box.select_option(filter_value)

def reviewSubject(self, nhs_no: str, reviewed: bool) -> None:
logging.info(f"Mark subject {nhs_no} as reviewed: {reviewed}")

row = self.page.locator(f'tr:has-text("{NHSNumberTools().spaced_nhs_number(nhs_no)}")')
last_cell = row.get_by_role("cell").nth(-1)
checkbox = last_cell.get_by_role("checkbox")
checkbox.set_checked(reviewed)

def click_subject_link(self, nhs_no: str) -> None:
subject_summary_link = self.page.get_by_role(
"link", name = NHSNumberTools().spaced_nhs_number(nhs_no)
)
subject_summary_link.click()
10 changes: 9 additions & 1 deletion pages/screening_subject_search/subject_demographic_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
from pages.base_page import BasePage
from datetime import datetime
from utils.calendar_picker import CalendarPicker

import logging

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

def __init__(self, page: Page):
super().__init__(page)
self.page = page

self.title = "Subject Demographic";

# Subject Demographic - page filters
self.forename_field = self.page.get_by_role("textbox", name="Forename")
self.surname_field = self.page.get_by_role("textbox", name="Surname")
Expand Down Expand Up @@ -54,6 +57,11 @@ def __init__(self, page: Page):
"#UI_SUBJECT_ALT_POSTCODE_0"
)

def verify_page_title(self) -> None:
logging.info(f"Verify title as '{self.title}'")
""f"Verifies that the {self.title} page title is displayed correctly."""
self.page_title_contains_text(self.title)

def is_forename_filled(self) -> bool:
"""
Checks if the forename textbox contains a value.
Expand Down
Loading