Skip to content

Commit 2d64ffd

Browse files
FixiSonarQube duplication in scenario 12
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-21315-fobtregressiontests-scenario-12
2 parents 5cc1f47 + 36ba642 commit 2d64ffd

File tree

9 files changed

+265
-14
lines changed

9 files changed

+265
-14
lines changed

pages/alerts/alerts_page.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
4+
5+
class AlertsPage(BasePage):
6+
def __init__(self, page: Page):
7+
super().__init__(page)
8+
self.refresh_alerts_link = self.page.get_by_role("link", name="Refresh alerts")
9+
10+
def click_refresh_alerts(self) -> None:
11+
"""Clicks the 'Refresh Alerts' link to trigger an update of alert messages."""
12+
self.refresh_alerts_link.click()
13+
14+
def is_refresh_alerts_visible(self, timeout=5000) -> bool:
15+
"""Returns True if the 'Refresh Alerts' link is visible within the given timeout."""
16+
return self.refresh_alerts_link.is_visible(timeout=timeout)

pages/gfobt_test_kits/gfobt_test_kits_page.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class GFOBTTestKitsPage(BasePage):
88
def __init__(self, page: Page):
99
super().__init__(page)
1010
self.page = page
11-
11+
self.test_kits_header = self.page.get_by_text("gFOBT Test Kits")
1212
self.test_kit_logging_page = self.page.get_by_role(
1313
"link", name="Test Kit Logging"
1414
)
@@ -35,3 +35,9 @@ def go_to_test_kit_result_page(self) -> None:
3535
def go_to_create_qc_kit_page(self) -> None:
3636
"""Navigate to the Create QC Kit page."""
3737
self.click(self.create_qc_kit_page)
38+
39+
def open_test_kits_report(self) -> None:
40+
"""Clicks the 'Test Kits' header to open the corresponding report section."""
41+
self.click(self.test_kits_header)
42+
43+

pages/organisations/organisations_page.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,29 @@
22
from pages.base_page import BasePage
33
from typing import List
44

5+
56
class OrganisationsPage(BasePage):
67
"""Organisations Page locators, and methods for interacting with the page."""
78

89
def __init__(self, page: Page):
910
super().__init__(page)
11+
self.page = page
12+
self.org_and_site_details_link = self.page.get_by_role(
13+
"link", name="Organisation and Site Details"
14+
)
15+
self.list_all_orgs_link = self.page.get_by_role(
16+
"link", name="List All Organisations"
17+
)
18+
self.list_all_sites_link = self.page.get_by_role("link", name="List All Sites")
19+
self.surveillance_link = self.page.get_by_role(
20+
"link", name="Surveillance", exact=True
21+
)
22+
self.manage_surveillance_review_link = self.page.get_by_role(
23+
"link", name="Manage Surveillance Review"
24+
)
25+
self.surveillance_review_summary_header = self.page.get_by_text(
26+
"Surveillance Review Summary"
27+
)
1028

1129
# Organisations page links
1230
self.screening_centre_parameters_page = self.page.get_by_role(
@@ -50,6 +68,21 @@ def go_to_bureau_page(self) -> None:
5068
"""Clicks the 'Bureau' link."""
5169
self.click(self.bureau_page)
5270

71+
def navigate_to_surveillance_review_summary(self) -> None:
72+
"""Navigates through the organisation pages to the Surveillance Review Summary."""
73+
self.click(self.org_and_site_details_link)
74+
self.click(self.list_all_orgs_link)
75+
self.click_back_button()
76+
self.click(self.list_all_sites_link)
77+
for _ in range(3):
78+
self.click_back_button()
79+
self.click(self.surveillance_link)
80+
self.click(self.manage_surveillance_review_link)
81+
self.page.goto(
82+
"https://bcss-bcss-18680-ddc-bcss.k8s-nonprod.texasplatform.uk/surveillance/review/summary"
83+
)
84+
85+
5386
class OrganisationSwitchPage:
5487
"""Page Object Model for interacting with the Organisation Switch page."""
5588

@@ -120,5 +153,3 @@ def get_logged_in_text(self) -> str:
120153
str: The text indicating the logged-in user's role or name.
121154
"""
122155
return self.login_info.inner_text()
123-
124-

pages/screening_practitioner_appointments/screening_practitioner_appointments_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def __init__(self, page: Page):
1010
self.page = page
1111
# ScreeningPractitionerAppointments Page
1212
self.log_in_page = self.page.get_by_role("button", name="Log in")
13+
self.appointments_header = self.page.get_by_text("Screening Practitioner Appointments")
14+
1315
self.view_appointments_page = self.page.get_by_role(
1416
"link", name="View appointments"
1517
)
@@ -43,3 +45,9 @@ def go_to_patients_that_require_page(self) -> None:
4345
def go_to_set_availability_page(self) -> None:
4446
"""Click on the Set Availability link to navigate to the set availability page."""
4547
self.click(self.set_availability_link)
48+
49+
def open_appointments_report(self) -> None:
50+
"""Clicks the 'Appointments' header to open the related report section."""
51+
self.click(self.appointments_header)
52+
53+

pages/screening_subject_search/subject_screening_search_page.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pages.base_page import BasePage
44
from enum import Enum
55
from utils.calendar_picker import CalendarPicker
6+
from typing import Optional
67

78

89
class SubjectScreeningPage(BasePage):
@@ -65,6 +66,13 @@ def __init__(self, page: Page):
6566
"textarea[data-testid='reasonNote']"
6667
)
6768

69+
self.surname_field = self.page.locator("#A_C_Surname")
70+
self.forename_field = self.page.locator("#A_C_Forename")
71+
self.screening_status_dropdown = self.page.locator("#A_C_ScreeningStatus")
72+
self.episode_status_dropdown = self.page.locator("#A_C_EpisodeStatus")
73+
self.search_button = self.page.get_by_role("button", name="Search")
74+
self.back_link = self.page.get_by_role("link", name="Back", exact=True)
75+
6876
def click_clear_filters_button(self) -> None:
6977
"""Click the 'Clear Filters' button."""
7078
self.click(self.clear_filters_button)
@@ -206,6 +214,38 @@ def complete_send_kit_form(
206214

207215
logging.info("[KIT REQUEST] 'Send a kit' form submitted successfully")
208216

217+
def search_subject_with_args(
218+
self,
219+
surname: Optional[str] = None,
220+
forename: Optional[str] = None,
221+
screening_status: Optional[str] = None,
222+
episode_status: Optional[str] = None,
223+
) -> None:
224+
"""
225+
Searches for a subject using any combination of the provided criteria.
226+
227+
Args:
228+
surname (Optional[str]): Subject's surname.
229+
forename (Optional[str]): Subject's forename.
230+
screening_status (Optional[str]): Screening status code.
231+
episode_status (Optional[str]): Episode status code.
232+
"""
233+
# Fill in all provided fields before triggering any search
234+
if surname:
235+
self.surname_field.fill(surname)
236+
if forename:
237+
self.forename_field.fill(forename)
238+
if screening_status:
239+
self.screening_status_dropdown.select_option(screening_status)
240+
self.click(self.screening_status_dropdown)
241+
if episode_status:
242+
self.episode_status_dropdown.select_option(episode_status)
243+
244+
# Only click search if at least one field was filled
245+
if any([surname, forename, screening_status, episode_status]):
246+
self.click(self.search_button)
247+
self.click(self.back_link)
248+
209249

210250
class ScreeningStatusSearchOptions(Enum):
211251
"""Enum for Screening Status Search Options"""
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
4+
5+
class SurveillanceSummaryPage(BasePage):
6+
"""Page object for navigating to and interacting with the Surveillance Review Summary section."""
7+
8+
def __init__(self, page: Page):
9+
super().__init__(page)
10+
11+
# Locators
12+
self.org_and_site_details_link = self.page.get_by_role(
13+
"link", name="Organisation and Site Details"
14+
)
15+
self.list_all_orgs_link = self.page.get_by_role(
16+
"link", name="List All Organisations"
17+
)
18+
self.list_all_sites_link = self.page.get_by_role("link", name="List All Sites")
19+
self.surveillance_link = self.page.get_by_role(
20+
"link", name="Surveillance", exact=True
21+
)
22+
self.manage_surveillance_review_link = self.page.get_by_role(
23+
"link", name="Manage Surveillance Review"
24+
)
25+
self.surveillance_review_summary_header = self.page.get_by_text(
26+
"Surveillance Review Summary"
27+
)
28+
self.back_link = self.page.get_by_role("link", name="Back", exact=True)
29+
30+
def navigate_to_surveillance_review_summary(self):
31+
"""Navigates through multiple UI steps to reach the Surveillance Review Summary section."""
32+
self.click(self.org_and_site_details_link)
33+
self.click(self.list_all_orgs_link)
34+
self.click(self.back_link)
35+
self.click(self.list_all_sites_link)
36+
for _ in range(3):
37+
self.click(self.back_link)
38+
self.click(self.surveillance_link)
39+
self.click(self.manage_surveillance_review_link)

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ markers =
5353
colonoscopy_dataset_tests: tests that are part of the colonoscopy datasets test suite
5454
fobt_diagnosis_date_entry_tests: tests that are part of fobt subject episodes record diagnosis date
5555
spine_retrieval_search_tests: tests that are part of subject spine retrieval demographics
56+
hub_user_tests: tests that are part of the hub user test suite
5657
fobt_regression_tests: tests that are part of the fobt regression test suite

tests/regression/regression_tests/fobt_regression_tests/test_scenario_12.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ def test_scenario_12(page: Page) -> None:
167167
# Then there is a "S9" letter batch for my subject with the exact title "Invitation & Test Kit (FIT)"
168168
# When I process the open "S9" letter batch for my subject
169169
batch_processing(
170-
page, "S9", "Invitation & Test Kit (FIT)", "S10 - Invitation & Test Kit Sent"
170+
page=page,
171+
batch_type="S9",
172+
batch_description="Invitation & Test Kit (FIT)",
173+
latest_event_status="S10 - Invitation & Test Kit Sent",
171174
)
172175

173176
# When I log my subject's latest unlogged FIT kit
@@ -181,7 +184,9 @@ def test_scenario_12(page: Page) -> None:
181184
)
182185

183186
# When I read my subject's latest logged FIT kit as "ABNORMAL"
184-
FitKitLogged().read_latest_logged_kit(user_role, 2, fit_kit, "ABNORMAL")
187+
FitKitLogged().read_latest_logged_kit(
188+
user=user_role, kit_type=2, kit=fit_kit, kit_result="ABNORMAL"
189+
)
185190

186191
# Then my subject has been updated as follows:
187192
subject_assertion(nhs_no, {"latest event status": "A8 Abnormal"})
@@ -196,9 +201,9 @@ def test_scenario_12(page: Page) -> None:
196201
# And I set the practitioner appointment date to "today"
197202
# And I book the "earliest" available practitioner appointment on this date
198203
book_appointments(
199-
page,
200-
"BCS001 - Wolverhampton Bowel Cancer Screening Centre",
201-
"The Royal Hospital (Wolverhampton)",
204+
page=page,
205+
screening_centre="BCS001 - Wolverhampton Bowel Cancer Screening Centre",
206+
site="The Royal Hospital (Wolverhampton)",
202207
)
203208

204209
# Then my subject has been updated as follows:
@@ -308,7 +313,7 @@ def test_scenario_12(page: Page) -> None:
308313

309314
# Then my subject has been updated as follows:
310315
AdvanceFOBTScreeningEpisodePage(page).verify_latest_event_status_value(
311-
"A59 - Invited for Diagnostic Test"
316+
latest_event_status="A59 - Invited for Diagnostic Test"
312317
)
313318

314319
# When I select the advance episode option for "Attend Diagnostic Test"
@@ -323,8 +328,8 @@ def test_scenario_12(page: Page) -> None:
323328

324329
# Then my subject has been updated as follows:
325330
subject_assertion(
326-
nhs_no,
327-
{
331+
nhs_number=nhs_no,
332+
criteria={
328333
"latest event status": "A259 Attended Diagnostic Test",
329334
},
330335
)
@@ -705,7 +710,7 @@ def test_scenario_12(page: Page) -> None:
705710
"symptomatic procedure result": "Null",
706711
"screening referral type": "Null",
707712
}
708-
subject_assertion(nhs_no, criteria)
713+
subject_assertion(nhs_number=nhs_no, criteria=criteria)
709714

710715
# When I view the subject
711716
screening_subject_page_searcher.navigate_to_subject_summary_page(page, nhs_no)
@@ -715,7 +720,7 @@ def test_scenario_12(page: Page) -> None:
715720

716721
# And I select the advance episode option for "Non-neoplastic and Other Non-bowel Cancer Result"
717722
AdvanceFOBTScreeningEpisodePage(
718-
page
723+
page=page
719724
).click_non_neoplastic_and_other_non_bowel_cancer_result_button()
720725

721726
# And I set the Date of Symptomatic Procedure to "today"
@@ -725,7 +730,7 @@ def test_scenario_12(page: Page) -> None:
725730

726731
# And the Screening Interval is 24 months
727732
NonNeoplasticResultFromSymptomaticProcedurePage(page).assert_text_in_alert_textbox(
728-
"recall interval of 24 months"
733+
expected_text="recall interval of 24 months"
729734
)
730735

731736
# And I select test number 1

0 commit comments

Comments
 (0)