Skip to content

Commit 2a2a265

Browse files
Feature/bcss 22023 surveillanceregressiontests scenario 10 (#163)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Migrating scenario 10 from SurveillanceRegressionTests into playwright, along with any relevant methods. ## Context <!-- Why is this change required? What problem does it solve? --> Migrating scenario 10 from SurveillanceRegressionTests into playwright, along with any relevant methods. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent fe7d8c3 commit 2a2a265

File tree

6 files changed

+703
-8
lines changed

6 files changed

+703
-8
lines changed

investigation_dataset_ui_app/dataset_fields.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
},
353353
{
354354
"key": "polyp appears fully resected endoscopically",
355-
"type": "YesNoOptions",
355+
"type": "YesNoUncertainOptions",
356356
"description": "Whether the polyp appears fully resected endoscopically",
357357
"optional": true
358358
}

pages/datasets/investigation_dataset_page.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,22 @@ def __init__(self, page: Page):
9393
self.visible_search_text_input = self.page.locator(
9494
'input[id^="UI_SEARCH_"]:visible'
9595
)
96+
self.diagnostic_test_result = self.page.locator(
97+
"#datasetContent > div:nth-child(1) > div:nth-child(7) > span.userInput"
98+
)
9699

97100
# Repeat strings:
98101
self.bowel_preparation_administered_string = "Bowel Preparation Administered"
99102
self.antibiotics_administered_string = "Antibiotics Administered"
100103
self.other_drugs_administered_string = "Other Drugs Administered"
101104

105+
# Other:
106+
self.list_of_multi_line_fields = [
107+
"failure reasons",
108+
"early complications",
109+
"late complications",
110+
]
111+
102112
def select_site_lookup_option(self, option: str) -> None:
103113
"""
104114
This method is designed to select a site from the site lookup options.
@@ -628,7 +638,7 @@ def get_dataset_section(self, dataset_section_name: str) -> Optional[Locator]:
628638
Args:
629639
dataset_section_name (str): The name of the dataset section to locate.
630640
Returns:
631-
Optioanl[Locator]: A Playwright Locator for the matching section if visible, or None if not found or not visible.
641+
Optional[Locator]: A Playwright Locator for the matching section if visible, or None if not found or not visible.
632642
"""
633643
logging.info(f"START: Looking for section '{dataset_section_name}'")
634644

@@ -1172,6 +1182,17 @@ def get_drug_dosage_text_locator(self, drug_type: str, drug_number: int) -> Loca
11721182
locator_prefix = "#HILITE_spanAntibioticDosageUnit"
11731183
return self.page.locator(f"{locator_prefix}{drug_number}")
11741184

1185+
def assert_test_result(self, expected_text: str) -> None:
1186+
"""
1187+
Asserts that the text in the test result matches the expected text.
1188+
Args:
1189+
expected_text (str): The text expected to be found in the element.
1190+
"""
1191+
actual_text = self.diagnostic_test_result.inner_text().strip()
1192+
assert (
1193+
actual_text.lower() == expected_text.lower()
1194+
), f"Expected '{expected_text}', but found '{actual_text}'"
1195+
11751196

11761197
def normalize_label(text: str) -> str:
11771198
"""

pages/screening_subject_search/advance_episode_page.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def __init__(self, page: Page):
147147
self.date_of_symptomatic_procedure_input = self.page.get_by_role(
148148
"textbox", name="Date of Symptomatic Procedure"
149149
)
150+
self.initiate_close_button = self.page.get_by_role(
151+
"button", name="Initiate Close"
152+
)
150153

151154
# Contact recording locators
152155
self.contact_direction_dropdown = self.page.get_by_label("Contact Direction")
@@ -209,6 +212,10 @@ def click_other_post_investigation_button(self) -> None:
209212
"""Click the 'Other Post-investigation' button."""
210213
self.safe_accept_dialog(self.other_post_investigation_button)
211214

215+
def click_initiate_close_button(self) -> None:
216+
"""Click the 'Initiate Close' button."""
217+
self.safe_accept_dialog(self.initiate_close_button)
218+
212219
def get_latest_event_status_cell(self, latest_event_status: str) -> Locator:
213220
"""Get the cell containing the latest event status."""
214221
return self.page.get_by_role("cell", name=latest_event_status, exact=True)

pages/screening_subject_search/diagnostic_test_outcome_page.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import logging
2-
from click import option
31
from playwright.sync_api import Page, expect, Locator
42
from pages.base_page import BasePage
53
from enum import StrEnum
4+
from typing import List
65

76

87
class ReferralProcedureType(StrEnum):
@@ -69,6 +68,22 @@ def select_test_outcome_option(self, option: str) -> None:
6968
"""
7069
self.test_outcome_dropdown.select_option(option)
7170

71+
def test_outcome_dropdown_contains_options(self, options: List[str]) -> None:
72+
"""
73+
Asserts that all provided options are present in the Outcome of Diagnostic Test dropdown.
74+
75+
Args:
76+
options (List[str]): List of option strings to check.
77+
"""
78+
dropdown_options = [
79+
opt.inner_text()
80+
for opt in self.test_outcome_dropdown.locator("option").all()
81+
]
82+
for item in options:
83+
assert (
84+
item in dropdown_options
85+
), f"Dropdown is missing expected option: '{item}'"
86+
7287
def verify_reason_for_symptomatic_referral(self, symptomatic_reason: str) -> None:
7388
"""
7489
Verify reason for symptomatic referral is visible.

pages/screening_subject_search/handover_into_symptomatic_care_page.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@ def __init__(self, page: Page):
1515
self.calendar_button = self.page.get_by_role("button", name="Calendar")
1616
self.consultant_link = self.page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK")
1717
self.practitioner_dropdown = self.page.locator("#UI_SCREENING_PRACTITIONER")
18+
self.non_screening_practitioner_link = self.page.locator(
19+
"#UI_NS_PRACTITIONER_PIO_SELECT_LINK"
20+
)
1821
self.notes_textbox = self.page.get_by_role("textbox", name="Notes")
1922
self.save_button = self.page.get_by_role("button", name="Save")
2023
self.cease_from_program_dropdown = self.page.locator(
2124
"#UI_CEASE_FROM_PROGRAM_ID"
2225
)
2326
self.mdt_date_field = self.page.locator("#UI_MDT_DATE")
2427
self.site_dropdown = self.page.locator("#UI_NS_SITE_SELECT_LINK")
28+
self.date_responsibility_accepted_field = self.page.locator("#UI_OTHER_DATE")
29+
self.select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
2530

2631
def select_referral_dropdown_option(self, value: str) -> None:
2732
"""
@@ -34,12 +39,26 @@ def select_referral_dropdown_option(self, value: str) -> None:
3439

3540
def select_practitioner_from_index(self, practitioner_index: int) -> None:
3641
"""
37-
Select the first option from the Practitioner dropdown.
42+
Select the an option from the Practitioner dropdown via index.
3843
Args:
3944
practitioner_index (int): The index of the practitioner to select.
4045
"""
4146
self.practitioner_dropdown.select_option(index=practitioner_index)
4247

48+
def select_non_screening_practitioner_link(self, practitioner_index: int) -> None:
49+
"""
50+
Select the a non screening practitioner from the non screening practitioner dropdown.
51+
Args:
52+
practitioner_index (int): The index of the non screening practitioner to select.
53+
"""
54+
self.non_screening_practitioner_link.click()
55+
self.select_locator.first.wait_for(state="visible")
56+
57+
# Find all option elements inside the select and click the one at the given index
58+
option_elements = self.select_locator.first.locator("option")
59+
option_elements.nth(practitioner_index).wait_for(state="visible")
60+
self.click(option_elements.nth(practitioner_index))
61+
4362
def click_calendar_button(self) -> None:
4463
"""Click the calendar button to open the calendar picker."""
4564
self.click(self.calendar_button)
@@ -56,6 +75,20 @@ def select_consultant(self, value: str) -> None:
5675
option_locator.wait_for(state="visible")
5776
self.click(option_locator)
5877

78+
def select_consultant_from_index(self, consultant_index: int) -> None:
79+
"""
80+
Select the a consultant from the consultant dropdown.
81+
Args:
82+
consultant_index (int): The index of the consultant to select.
83+
"""
84+
self.click(self.consultant_link)
85+
self.select_locator.first.wait_for(state="visible")
86+
87+
# Find all option elements inside the select and click the one at the given index
88+
option_elements = self.select_locator.first.locator("option")
89+
option_elements.nth(consultant_index).wait_for(state="visible")
90+
self.click(option_elements.nth(consultant_index))
91+
5992
def fill_notes(self, notes: str) -> None:
6093
"""
6194
Fill the 'Notes' textbox with the provided text.
@@ -88,6 +121,16 @@ def enter_mdt_date(self, date: datetime) -> None:
88121
"""
89122
CalendarPicker(self.page).calendar_picker_ddmmyyyy(date, self.mdt_date_field)
90123

124+
def enter_date_responsibility_accepted_field(self, date: datetime) -> None:
125+
"""
126+
Enters a date into the 'Date Responsibility Accepted' field
127+
Args:
128+
date (datetime): The date to enter.
129+
"""
130+
CalendarPicker(self.page).calendar_picker_ddmmyyyy(
131+
date, self.date_responsibility_accepted_field
132+
)
133+
91134
def select_site_dropdown_option_index(self, index: int) -> None:
92135
"""
93136
Select a given option from the site dropdown.
@@ -96,11 +139,10 @@ def select_site_dropdown_option_index(self, index: int) -> None:
96139
value (str): The value of the option you want to select
97140
"""
98141
self.click(self.site_dropdown)
99-
select_locator = self.page.locator('select[id^="UI_RESULTS_"]:visible')
100-
select_locator.first.wait_for(state="visible")
142+
self.select_locator.first.wait_for(state="visible")
101143

102144
# Find all option elements inside the select and click the one at the given index
103-
option_elements = select_locator.first.locator("option")
145+
option_elements = self.select_locator.first.locator("option")
104146
option_elements.nth(index).wait_for(state="visible")
105147
self.click(option_elements.nth(index))
106148

@@ -118,3 +160,20 @@ def fill_with_cancer_details(self) -> None:
118160
self.fill_notes("Handover notes for Cancer scenario")
119161
self.click_save_button()
120162
self.page.wait_for_timeout(500) # Timeout to allow subject to update in the DB.
163+
164+
def perform_referral_to_specific_clinician_scenario(self) -> None:
165+
"""
166+
Complete the Handover into Symptomatic Care form with the Referral to Specific Clinician scenario:
167+
Referral: Referral to Specific Clinician
168+
Date Responsibility Accepted: Today
169+
Non Screening Consultant: Last option
170+
Non Screening Practitioner: Last option
171+
Note: Handover notes - referral to Specific Clinician
172+
"""
173+
self.select_referral_dropdown_option("Referral to Specific Clinician")
174+
self.enter_date_responsibility_accepted_field(datetime.today())
175+
self.select_consultant_from_index(-1)
176+
self.select_non_screening_practitioner_link(-1)
177+
self.fill_notes("Handover notes - referral to Specific Clinician")
178+
self.click_save_button()
179+
self.page.wait_for_timeout(500) # Timeout to allow subject to update in the DB.

0 commit comments

Comments
 (0)