Skip to content

Commit 5fd87b1

Browse files
Merge branch 'main' of github.com:NHSDigital/bcss-playwright into feature/BCSS-20444-compartment-6-data-management
2 parents 66dc514 + 7f5f78a commit 5fd87b1

File tree

3 files changed

+68
-21
lines changed

3 files changed

+68
-21
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from playwright.sync_api import Page, expect, Locator
2+
from pages.base_page import BasePage
3+
from enum import StrEnum
4+
5+
6+
class DiagnosticTestOutcomePage(BasePage):
7+
"""Diagnostic Test Outcome Page locators and methods for interacting with the page."""
8+
9+
def __init__(self, page: Page):
10+
super().__init__(page)
11+
self.page = page
12+
# Diagnostic Test Outcome- page locators
13+
self.test_outcome_dropdown = self.page.get_by_label(
14+
"Outcome of Diagnostic Test"
15+
)
16+
self.save_button = self.page.get_by_role("button", name="Save")
17+
18+
def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
19+
"""
20+
Verify that the diagnostic test outcome is visible.
21+
22+
Args:
23+
outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
24+
"""
25+
expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
26+
27+
def select_test_outcome_option(self, option: str) -> None:
28+
"""Select an option from the Outcome of Diagnostic Test dropdown.
29+
30+
Args:
31+
option (str): option (str): The option to select from the Outcome Of Diagnostic Test options.
32+
"""
33+
self.test_outcome_dropdown.select_option(option)
34+
35+
def click_save_button(self) -> None:
36+
"""Click the 'Save' button."""
37+
self.click(self.save_button)
38+
39+
40+
class OutcomeOfDiagnosticTest(StrEnum):
41+
"""Enum for outcome of diagnostic test options."""
42+
43+
FAILED_TEST_REFER_ANOTHER = "20363"
44+
REFER_SYMPTOMATIC = "20366"
45+
REFER_SURVEILLANCE = "20365"
46+
INVESTIGATION_COMPLETE = "20360"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest-playwright>=0.5.1
1+
pytest-playwright>=0.7.0
22
pytest-html>=4.1.1
33
pytest-json-report>=1.5.0
44
pytest-playwright-axe>=4.10.3

tests/smokescreen/test_compartment_6.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
from pages.screening_subject_search.record_diagnosis_date_page import (
1818
RecordDiagnosisDatePage,
1919
)
20+
from pages.screening_subject_search.diagnostic_test_outcome_page import (
21+
DiagnosticTestOutcomePage,OutcomeOfDiagnosticTest
22+
)
2023
from pages.datasets.investigation_dataset_page import (
2124
InvestigationDatasetsPage,
2225
SiteLookupOptions,
@@ -216,10 +219,9 @@ def after_high_risk_result(page: Page) -> None:
216219
AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
217220

218221
# The following code is on the diagnostic test outcome page
219-
expect(page.get_by_role("cell", name="High-risk findings").nth(1)).to_be_visible()
220-
page.get_by_label("Outcome of Diagnostic Test").select_option("20365")
221-
page.get_by_role("button", name="Save").click()
222-
222+
DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome("High-risk findings")
223+
DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.REFER_SURVEILLANCE)
224+
DiagnosticTestOutcomePage(page).click_save_button()
223225

224226
def after_lnpcp_result(page: Page) -> None:
225227
InvestigationDatasetsPage(page).expect_text_to_be_visible("LNPCP")
@@ -235,10 +237,9 @@ def after_lnpcp_result(page: Page) -> None:
235237
AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
236238

237239
# The following code is on the diagnostic test outcome page
238-
expect(page.get_by_role("cell", name="LNPCP").nth(1)).to_be_visible()
239-
page.get_by_label("Outcome of Diagnostic Test").select_option("20365")
240-
page.get_by_role("button", name="Save").click()
241-
240+
DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome("LNPCP")
241+
DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.REFER_SURVEILLANCE)
242+
DiagnosticTestOutcomePage(page).click_save_button()
242243

243244
def handover_subject_to_symptomatic_care(page: Page) -> None:
244245
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
@@ -247,7 +248,7 @@ def handover_subject_to_symptomatic_care(page: Page) -> None:
247248
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
248249

249250
# The following code is on the advance fobt screening episode page
250-
page.get_by_role("button", name="Handover into Symptomatic Care").click()
251+
AdvanceFOBTScreeningEpisodePage(page).click_handover_into_symptomatic_care_button()
251252

252253
# The following code is on the handover into symptomatic care page
253254
HandoverIntoSymptomaticCarePage(page).select_referral_dropdown_option("20445")
@@ -281,7 +282,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
281282

282283
# This needs to be repeated for two subjects, one old and one not - High Risk Result
283284
# Older patient
284-
nhs_no = "9577049095"
285+
nhs_no = "9772286785"
285286
go_to_investigation_datasets_page(page, nhs_no)
286287

287288
# The following code is on the investigation datasets page
@@ -296,7 +297,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
296297
handover_subject_to_symptomatic_care(page)
297298

298299
# Younger patient
299-
nhs_no = "9567180636"
300+
nhs_no = "9802397318"
300301
go_to_investigation_datasets_page(page, nhs_no)
301302

302303
# The following code is on the investigation datasets page
@@ -326,7 +327,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
326327

327328
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
328329
# Older patient
329-
nhs_no = "9237051190"
330+
nhs_no = "9359523194"
330331
go_to_investigation_datasets_page(page, nhs_no)
331332

332333
# The following code is on the investigation datasets page
@@ -341,7 +342,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
341342
handover_subject_to_symptomatic_care(page)
342343

343344
# Younger patient
344-
nhs_no = "9564243211"
345+
nhs_no = "9828941813"
345346
go_to_investigation_datasets_page(page, nhs_no)
346347

347348
# The following code is on the investigation datasets page
@@ -358,7 +359,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
358359
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
359360

360361
# The following code is on the advance fobt screening episode page
361-
page.get_by_role("button", name="Record Diagnosis Date").click()
362+
AdvanceFOBTScreeningEpisodePage(page).click_record_diagnosis_date_button()
362363

363364
# The following code is on the record diagnosis date page
364365
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
@@ -369,7 +370,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
369370
)
370371

371372
# This needs to be repeated for 1 subject, age does not matter - Normal Result
372-
nhs_no_normal = "9648226105"
373+
nhs_no_normal = "9852356488"
373374
go_to_investigation_datasets_page(page, nhs_no_normal)
374375

375376
# The following code is on the investigation datasets page
@@ -396,11 +397,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
396397
AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
397398

398399
# The following code is on the diagnostic test outcome page
399-
expect(
400-
page.get_by_role("cell", name="Normal (No Abnormalities").nth(1)
401-
).to_be_visible()
402-
page.get_by_label("Outcome of Diagnostic Test").select_option("20360")
403-
page.get_by_role("button", name="Save").click()
400+
DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome(
401+
"Normal (No Abnormalities"
402+
)
403+
DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.INVESTIGATION_COMPLETE)
404+
DiagnosticTestOutcomePage(page).click_save_button()
404405

405406
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
406407
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"

0 commit comments

Comments
 (0)