Skip to content

Commit 56070d6

Browse files
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-21318-fobtregressiontests-scenario-15
# Conflicts: # classes/repositories/subject_repository.py # pages/screening_subject_search/advance_fobt_screening_episode_page.py # utils/oracle/subject_selection_query_builder.py
2 parents a5b4752 + cea68c5 commit 56070d6

12 files changed

+1357
-57
lines changed

classes/repositories/subject_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ def there_is_letter_batch_for_subject(
244244
sql_query = """ SELECT lb.batch_id
245245
FROM lett_batch_records lbr
246246
INNER JOIN lett_batch lb
247-
ON lb.batch_id = lbr.batch_id
247+
ON lb.batch_id = lbr.batch_id
248248
INNER JOIN valid_values ld
249-
ON ld.valid_value_id = lb.description_id
249+
ON ld.valid_value_id = lb.description_id
250250
INNER JOIN valid_values lbs
251-
ON lbs.valid_value_id = lb.status_id
251+
ON lbs.valid_value_id = lb.status_id
252252
WHERE lb.batch_state_id = 12018
253253
AND lbr.screening_subject_id = :subject_id
254254
AND lbs.allowed_value = :batch_code

pages/screening_subject_search/advance_fobt_screening_episode_page.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ def __init__(self, page: Page):
114114
"button",
115115
name="Refer Another Diagnostic Test after return from Symptomatic Referral",
116116
)
117+
self.refer_to_survelliance_after_symptomatic_referral_button = (
118+
self.page.get_by_role(
119+
"button", name="Refer to Surveillance after Symptomatic Referral"
120+
)
121+
)
122+
self.redirect_to_rerecord_the_outcome_of_symptomatic_referral_button = (
123+
self.page.get_by_role(
124+
"button",
125+
name="Redirect to Re-record the Outcome of Symptomatic Referral",
126+
)
127+
)
117128
self.redirect_to_establish_suitability_for_diagnostic_tests_button = (
118129
self.page.get_by_role(
119130
"button",
@@ -141,6 +152,9 @@ def __init__(self, page: Page):
141152
self.ct_colonography_test_type_dropdown = self.page.locator(
142153
"#UI_EXT_TEST_TYPE_38"
143154
)
155+
self.lnpcp_result_from_symptomatic_procedure_button = self.page.get_by_role(
156+
"button", name="LNPCP Result from Symptomatic Procedure"
157+
)
144158

145159
def click_suitable_for_endoscopic_test_button(self) -> None:
146160
"""Click the 'Suitable for Endoscopic Test' button."""
@@ -444,6 +458,26 @@ def click_refer_another_diagnostic_test_after_return_from_symptomatic_referral_b
444458
self.refer_another_diagnostic_test_after_return_from_symptomatic_referral_button
445459
)
446460

461+
def click_lnpcp_result_from_symptomatic_procedure_button(self) -> None:
462+
"""Click the 'LNPCP Result from Symptomatic Procedure' button."""
463+
self.safe_accept_dialog(self.lnpcp_result_from_symptomatic_procedure_button)
464+
465+
def click_refer_to_survelliance_after_symptomatic_referral_button(
466+
self,
467+
) -> None:
468+
"""Click the 'Refer to Surveillance after Symptomatic Referral' button."""
469+
self.safe_accept_dialog(
470+
self.refer_to_survelliance_after_symptomatic_referral_button
471+
)
472+
473+
def click_redirect_to_rerecord_the_outcome_of_symptomatic_referral_button(
474+
self,
475+
) -> None:
476+
"""Click the 'Redirect to Re-record the Outcome of Symptomatic Referral' button."""
477+
self.safe_accept_dialog(
478+
self.redirect_to_rerecord_the_outcome_of_symptomatic_referral_button
479+
)
480+
447481
def click_redirect_to_establish_suitability_for_diagnostic_tests_button(
448482
self,
449483
) -> None:

pages/screening_subject_search/diagnostic_test_outcome_page.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def __init__(self, page: Page):
3939
self.test_outcome_dropdown = self.page.get_by_label(
4040
"Outcome of Diagnostic Test"
4141
)
42+
self.reason_for_sympptomatic_referral_dropdown = self.page.get_by_label(
43+
"Reason for Symptomatic Referral"
44+
)
4245
self.save_button = self.page.get_by_role("button", name="Save")
4346
self.referral_procedure_dropdown = self.page.locator(
4447
"#UI_REFERRAL_PROCEDURE_TYPE"
@@ -66,6 +69,25 @@ def select_test_outcome_option(self, option: str) -> None:
6669
"""
6770
self.test_outcome_dropdown.select_option(option)
6871

72+
def verify_reason_for_symptomatic_referral(self, symptomatic_reason: str) -> None:
73+
"""
74+
Verify reason for symptomatic referral is visible.
75+
76+
Args:
77+
symptomatic_reason(str): The accessible name or visible text of the symptomatic reason cell to verify.
78+
"""
79+
expect(
80+
self.page.get_by_role("cell", name=symptomatic_reason).nth(1)
81+
).to_be_visible()
82+
83+
def select_reason_for_symptomatic_referral_option(self, option: str) -> None:
84+
"""Select an option from the reason for symptomatic referral dropdown.
85+
86+
Args:
87+
option (str): option (str): The option to select from the Reason For Symptomatic Referral options.
88+
"""
89+
self.reason_for_sympptomatic_referral_dropdown.select_option(option)
90+
6991
def click_save_button(self) -> None:
7092
"""Click the 'Save' button."""
7193
self.click(self.save_button)
@@ -99,3 +121,11 @@ class OutcomeOfDiagnosticTest(StrEnum):
99121
REFER_SURVEILLANCE = "20365"
100122
INVESTIGATION_COMPLETE = "20360"
101123
REFER_ANOTHER_DIAGNOSTIC_TEST = "20364"
124+
125+
126+
class ReasonForSymptomaticReferral(StrEnum):
127+
"""Enum for Symptomatic Referral reason options."""
128+
129+
POLYP_EXCISION = "203011"
130+
CORRECTIVE_SURGERY = "203012"
131+
SUSPECTED_CANCER_SURGERY = "203013"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from playwright.sync_api import Page
2+
from pages.screening_subject_search.result_from_symptomatic_procedure_page import (
3+
ResultFromSymptomaticProcedurePage,
4+
)
5+
6+
7+
class LnpcpResultFromSymptomaticProcedure(ResultFromSymptomaticProcedurePage):
8+
"""LNPCP specific implementation of Result from Symptomatic Procedure Page."""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,14 @@
1-
from datetime import datetime
21
from playwright.sync_api import Page
3-
from pages.base_page import BasePage
4-
from utils.calendar_picker import CalendarPicker
2+
from pages.screening_subject_search.result_from_symptomatic_procedure_page import (
3+
ResultFromSymptomaticProcedurePage,
4+
)
55

66

7-
class NonNeoplasticResultFromSymptomaticProcedurePage(BasePage):
8-
"""Non Neoplastic Result From Symptomatic Procedure Page locators, and methods for interacting with the page."""
7+
class NonNeoplasticResultFromSymptomaticProcedurePage(
8+
ResultFromSymptomaticProcedurePage
9+
):
10+
"""Non-Neoplastic specific implementation of Result from Symptomatic Procedure Page."""
911

1012
def __init__(self, page: Page):
1113
super().__init__(page)
12-
# Non Neoplastic Result From Symptomatic Procedure - page locators
13-
self.date_of_symptomatic_procedure_calendar_button = self.page.locator(
14-
"#UI_SURGERY_DATE__LinkOrButton"
15-
)
16-
self.alert_textbox = self.page.locator("#UI_SPAN_RECALL_TEXT")
17-
self.all_tests = self.page.locator("#UI_ID_RECALL_ANCHOR_DATE_EXT_TEST_ID")
18-
self.save_button = self.page.get_by_role("button", name="Save")
19-
20-
def click_date_of_symptomatic_procedure_calendar_button(self) -> None:
21-
"""Click the date of symptomatic procedure calendar button."""
22-
self.click(self.date_of_symptomatic_procedure_calendar_button)
23-
24-
def enter_date_of_symptomatic_procedure(self, date: datetime) -> None:
25-
"""
26-
Enter the date of the symptomatic procedure.
27-
Args:
28-
date (datetime): The date to be entered in the date of symptomatic procedure field. Example: datetime(2023, 10, 25)
29-
"""
30-
self.click_date_of_symptomatic_procedure_calendar_button()
31-
CalendarPicker(self.page).v1_calender_picker(date)
32-
33-
def assert_text_in_alert_textbox(self, expected_text: str) -> None:
34-
"""
35-
Assert that the expected text is present in the alert textbox.
36-
Args:
37-
expected_text (str): The text expected to be found in the alert textbox. Example: "This is a test alert"
38-
"""
39-
actual_text = self.alert_textbox.inner_text()
40-
assert (
41-
expected_text in actual_text
42-
), f"Expected text '{expected_text}' not found in alert textbox. Actual text: '{actual_text}'"
43-
44-
def select_test_number(self, test_number: int) -> None:
45-
"""
46-
Select a test from the all tests dropdown by its index.
47-
Args:
48-
test_number (int): The index of the test to select (1-based index). Example: if you want to select the 1st test pass in 1
49-
"""
50-
self.click(self.all_tests.nth(test_number - 1))
51-
52-
def click_save_button(self) -> None:
53-
"""Click the 'Save' button."""
54-
self.click(self.save_button)
14+
self.page = page
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 ReferToMDTPage(BasePage):
8+
"""Refer to MDT 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+
14+
# Refer MDT page - page locators
15+
self.mdt_discussion_date_field = self.page.locator("#UI_MDT_DATE_LinkOrButton")
16+
self.mdt_location = self.page.locator("#UI_NS_SITE_SELECT_LINK")
17+
self.visible_ui_results_string = 'select[id^="UI_RESULTS_"]:visible'
18+
self.record_MDT_appointment_button = self.page.locator(
19+
'[name="UI_BUTTON_SAVE"]'
20+
)
21+
22+
def enter_date_in_Mdt_discussion_date_field(self, date: datetime) -> None:
23+
"""
24+
Enters a date in the MDT discussion date field.
25+
Args:
26+
date (datetime): The date to enter in the field.
27+
"""
28+
self.click(self.mdt_discussion_date_field)
29+
CalendarPicker(self.page).v2_calendar_picker(date)
30+
self.mdt_discussion_date_field.press("Tab")
31+
32+
def select_mdt_location_lookup(self, option: int) -> None:
33+
"""
34+
This method is designed to select an option from the MDT location lookup dropdown.
35+
Args:
36+
option (int): The index of the option to select (0-based).
37+
"""
38+
self.click(self.mdt_location)
39+
select_locator = self.page.locator(self.visible_ui_results_string)
40+
select_locator.first.wait_for(state="visible")
41+
# Find all option elements inside the select and click the one at the given index
42+
option_elements = select_locator.first.locator("option")
43+
option_elements.nth(option).wait_for(state="visible")
44+
self.click(option_elements.nth(option))
45+
46+
def click_record_MDT_appointment_button(self) -> None:
47+
"""Clicks the record MDT appointment button."""
48+
self.click(self.record_MDT_appointment_button)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from datetime import datetime
2+
from playwright.sync_api import Page
3+
from pages.base_page import BasePage
4+
from utils.calendar_picker import CalendarPicker
5+
6+
7+
class ResultFromSymptomaticProcedurePage(BasePage):
8+
"""Base class for Result from Symptomatic Procedure pages with common locators and methods."""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
13+
# Result from Symptomatic Procedure Page - page locators
14+
self.date_of_symptomatic_procedure_calendar_button = self.page.locator(
15+
"#UI_SURGERY_DATE__LinkOrButton"
16+
)
17+
self.alert_textbox = self.page.locator("#UI_SPAN_RECALL_TEXT")
18+
self.all_tests = self.page.locator(
19+
"[id^='UI_ID_RECALL_ANCHOR_DATE_EXT_TEST_ID']"
20+
)
21+
self.save_button = self.page.get_by_role("button", name="Save")
22+
23+
def click_date_of_symptomatic_procedure_calendar_button(self) -> None:
24+
"""Click the date of symptomatic procedure calendar button."""
25+
self.click(self.date_of_symptomatic_procedure_calendar_button)
26+
27+
def enter_date_of_symptomatic_procedure(self, date: datetime) -> None:
28+
"""
29+
Enter the date of the symptomatic procedure.
30+
Args:
31+
date (datetime): The date to be entered in the date of symptomatic procedure field. Example: datetime(2023, 10, 25)
32+
"""
33+
self.click_date_of_symptomatic_procedure_calendar_button()
34+
CalendarPicker(self.page).v1_calender_picker(date)
35+
36+
def assert_text_in_alert_textbox(self, expected_text: str) -> None:
37+
"""
38+
Assert that the expected text is present in the alert textbox.
39+
Args:
40+
expected_text (str): The text expected to be found in the alert textbox. Example: "This is a test alert"
41+
"""
42+
actual_text = self.alert_textbox.inner_text()
43+
assert (
44+
expected_text in actual_text
45+
), f"Expected text '{expected_text}' not found in alert textbox. Actual text: '{actual_text}'"
46+
47+
def select_test_number(self, test_number: int) -> None:
48+
"""
49+
Select a test from the all tests dropdown by its index.
50+
Args:
51+
test_number (int): The index of the test to select (1-based index). Example: if you want to select the 1st test pass in 1
52+
"""
53+
self.click(self.all_tests.nth(test_number - 1))
54+
55+
def click_save_button(self) -> None:
56+
"""Click the 'Save' button."""
57+
self.click(self.save_button)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ def change_screening_status(self, status_option: str, reason_option: str) -> Non
446446
self.click_update_subject_data()
447447
self.page.wait_for_timeout(1000)
448448

449+
def assert_reopen_episode_button_not_visible(self) -> None:
450+
"""Assert that the 'Reopen FOBT Screening Episode' button is not visible"""
451+
expect(self.reopen_fobt_screening_episode_button).not_to_be_visible()
452+
449453

450454
class ChangeScreeningStatusOptions(StrEnum):
451455
"""Enum for Change Screening Status options."""

tests/regression/regression_tests/fobt_regression_tests/test_scenario_12.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@
5757
YesNoOptions,
5858
EndoscopyLocationOptions,
5959
)
60-
from pages.screening_subject_search.non_neoplastic_result_from_symptomatic_procedure_page import (
61-
NonNeoplasticResultFromSymptomaticProcedurePage,
62-
)
60+
from pages.screening_subject_search.non_neoplastic_result_from_symptomatic_procedure_page import (NonNeoplasticResultFromSymptomaticProcedurePage)
6361
from utils.subject_demographics import SubjectDemographicUtil
6462
from pages.screening_subject_search.reopen_fobt_screening_episode_page import (
6563
ReopenFOBTScreeningEpisodePage,

0 commit comments

Comments
 (0)