Repository: NHSDigital/bcss-playwright
Pull request #67: Feature/bcss 20477 c6 pom diagnostic test outcome page
Author: login: mepr1
Labels: name: enhancement
description: New feature or request
Created: 2025-05-14T12:09:57Z | Merged: 2025-05-14T16:39:24Z

<!-- markdownlint-disable-next-line first-line-heading -->
## Description

New POM for the  diagnostic test outcome page

## Context
Allowing for the locators in this page to be reused

## 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
- [ ] I have added tests to cover my changes (where appropriate)
- [ ] 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.



Diff:
diff --git a/pages/screening_subject_search/diagnostic_test_outcome_page.py b/pages/screening_subject_search/diagnostic_test_outcome_page.py
new file mode 100644
index 00000000..c2274f49
--- /dev/null
+++ b/pages/screening_subject_search/diagnostic_test_outcome_page.py
@@ -0,0 +1,46 @@
+from playwright.sync_api import Page, expect, Locator
+from pages.base_page import BasePage
+from enum import StrEnum
+
+
+class DiagnosticTestOutcomePage(BasePage):
+    """Diagnostic Test Outcome Page locators and methods for interacting with the page."""
+
+    def __init__(self, page: Page):
+        super().__init__(page)
+        self.page = page
+        # Diagnostic Test Outcome- page locators
+        self.test_outcome_dropdown = self.page.get_by_label(
+            "Outcome of Diagnostic Test"
+        )
+        self.save_button = self.page.get_by_role("button", name="Save")
+
+    def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
+        """
+        Verify that the diagnostic test outcome is visible.
+
+        Args:
+            outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
+        """
+        expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
+
+    def select_test_outcome_option(self, option: str) -> None:
+        """Select an option from the Outcome of Diagnostic Test dropdown.
+
+        Args:
+            option (str): option (str): The option to select from the Outcome Of Diagnostic Test options.
+        """
+        self.test_outcome_dropdown.select_option(option)
+
+    def click_save_button(self) -> None:
+        """Click the 'Save' button."""
+        self.click(self.save_button)
+
+
+class OutcomeOfDiagnosticTest(StrEnum):
+    """Enum for outcome of diagnostic test options."""
+
+    FAILED_TEST_REFER_ANOTHER = "20363"
+    REFER_SYMPTOMATIC = "20366"
+    REFER_SURVEILLANCE = "20365"
+    INVESTIGATION_COMPLETE = "20360"
diff --git a/tests/smokescreen/test_compartment_6.py b/tests/smokescreen/test_compartment_6.py
index 6a8795cb..569206e9 100644
--- a/tests/smokescreen/test_compartment_6.py
+++ b/tests/smokescreen/test_compartment_6.py
@@ -17,6 +17,9 @@
 from pages.screening_subject_search.record_diagnosis_date_page import (
     RecordDiagnosisDatePage,
 )
+from pages.screening_subject_search.diagnostic_test_outcome_page import (
+    DiagnosticTestOutcomePage,OutcomeOfDiagnosticTest
+)
 from pages.datasets.investigation_dataset_page import (
     InvestigationDatasetsPage,
     SiteLookupOptions,
@@ -216,10 +219,9 @@ def after_high_risk_result(page: Page) -> None:
     AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
 
     # The following code is on the diagnostic test outcome page
-    expect(page.get_by_role("cell", name="High-risk findings").nth(1)).to_be_visible()
-    page.get_by_label("Outcome of Diagnostic Test").select_option("20365")
-    page.get_by_role("button", name="Save").click()
-
+    DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome("High-risk findings")
+    DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.REFER_SURVEILLANCE)
+    DiagnosticTestOutcomePage(page).click_save_button()
 
 def after_lnpcp_result(page: Page) -> None:
     InvestigationDatasetsPage(page).expect_text_to_be_visible("LNPCP")
@@ -235,10 +237,9 @@ def after_lnpcp_result(page: Page) -> None:
     AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
 
     # The following code is on the diagnostic test outcome page
-    expect(page.get_by_role("cell", name="LNPCP").nth(1)).to_be_visible()
-    page.get_by_label("Outcome of Diagnostic Test").select_option("20365")
-    page.get_by_role("button", name="Save").click()
-
+    DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome("LNPCP")
+    DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.REFER_SURVEILLANCE)
+    DiagnosticTestOutcomePage(page).click_save_button()
 
 def handover_subject_to_symptomatic_care(page: Page) -> None:
     SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
@@ -247,7 +248,7 @@ def handover_subject_to_symptomatic_care(page: Page) -> None:
     SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
 
     # The following code is on the advance fobt screening episode page
-    page.get_by_role("button", name="Handover into Symptomatic Care").click()
+    AdvanceFOBTScreeningEpisodePage(page).click_handover_into_symptomatic_care_button()
 
     # The following code is on the handover into symptomatic care page
     HandoverIntoSymptomaticCarePage(page).select_referral_dropdown_option("20445")
@@ -281,7 +282,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
 
     # This needs to be repeated for two subjects, one old and one not - High Risk Result
     # Older patient
-    nhs_no = "9577049095"
+    nhs_no = "9772286785"
     go_to_investigation_datasets_page(page, nhs_no)
 
     # The following code is on the investigation datasets page
@@ -296,7 +297,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
     handover_subject_to_symptomatic_care(page)
 
     # Younger patient
-    nhs_no = "9567180636"
+    nhs_no = "9802397318"
     go_to_investigation_datasets_page(page, nhs_no)
 
     # The following code is on the investigation datasets page
@@ -326,7 +327,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
 
     # This needs to be repeated for two subjects, one old and one not - LNPCP Result
     # Older patient
-    nhs_no = "9237051190"
+    nhs_no = "9359523194"
     go_to_investigation_datasets_page(page, nhs_no)
 
     # The following code is on the investigation datasets page
@@ -341,7 +342,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
     handover_subject_to_symptomatic_care(page)
 
     # Younger patient
-    nhs_no = "9564243211"
+    nhs_no = "9828941813"
     go_to_investigation_datasets_page(page, nhs_no)
 
     # The following code is on the investigation datasets page
@@ -358,7 +359,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
     SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
 
     # The following code is on the advance fobt screening episode page
-    page.get_by_role("button", name="Record Diagnosis Date").click()
+    AdvanceFOBTScreeningEpisodePage(page).click_record_diagnosis_date_button()
 
     # The following code is on the record diagnosis date page
     RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
@@ -369,7 +370,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
     )
 
     # This needs to be repeated for 1 subject, age does not matter - Normal Result
-    nhs_no_normal = "9648226105"
+    nhs_no_normal = "9852356488"
     go_to_investigation_datasets_page(page, nhs_no_normal)
 
     # The following code is on the investigation datasets page
@@ -396,11 +397,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
     AdvanceFOBTScreeningEpisodePage(page).click_enter_diagnostic_test_outcome_button()
 
     # The following code is on the diagnostic test outcome page
-    expect(
-        page.get_by_role("cell", name="Normal (No Abnormalities").nth(1)
-    ).to_be_visible()
-    page.get_by_label("Outcome of Diagnostic Test").select_option("20360")
-    page.get_by_role("button", name="Save").click()
+    DiagnosticTestOutcomePage(page).verify_diagnostic_test_outcome(
+        "Normal (No Abnormalities"
+    )
+    DiagnosticTestOutcomePage(page).select_test_outcome_option(OutcomeOfDiagnosticTest.INVESTIGATION_COMPLETE)
+    DiagnosticTestOutcomePage(page).click_save_button()
 
     SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
         "A318 - Post-investigation Appointment NOT Required - Result Letter Created"


Reviews:
user: login: adrianoaru-nhs
state: APPROVED
author_association: NONE
submitted_at: 2025-05-14T12:40:25Z
user: login: adrianoaru-nhs
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-05-14T12:41:23Z
user: login: mepr1
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-14T13:21:58Z
user: login: adrianoaru-nhs
state: CHANGES_REQUESTED
author_association: NONE
submitted_at: 2025-05-14T13:24:01Z
user: login: adrianoaru-nhs
state: APPROVED
author_association: NONE
submitted_at: 2025-05-14T13:43:27Z
user: login: Andyg79
state: APPROVED
author_association: NONE
submitted_at: 2025-05-14T15:10:38Z

Review comments:
diff_hunk: @@ -0,0 +1,42 @@
+from playwright.sync_api import Page, expect, Locator
+from pages.base_page import BasePage
+from enum import StrEnum
+
+
+class DiagnosticTestOutcomePage(BasePage):
+    """Diagnostic Test Outcome Page locators and methods for interacting with the page."""
+
+    def __init__(self, page: Page):
+        super().__init__(page)
+        self.page = page
+        # Diagnostic Test Outcome- page locators
+        self.test_outcome_dropdown = self.page.get_by_label(
+            "Outcome of Diagnostic Test"
+        )
+        self.save_button = self.page.get_by_role("button", name="Save")
+
+    def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
+        """
+        Verify that the diagnostic test outcome is visible.
+
+        Args:
+            outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
+        """
+        expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
+
+    def select_test_outcome_option(self, option: str) -> None:
+        """Select an option from the Outcome of Diagnostic Test dropdown."""
+        self.test_outcome_dropdown.select_option(option)
path: pages/screening_subject_search/diagnostic_test_outcome_page.py
user: login: adrianoaru-nhs
body: In the docstring include the arguments
created_at: 2025-05-14T12:41:20Z
author_association: NONE
diff_hunk: @@ -0,0 +1,42 @@
+from playwright.sync_api import Page, expect, Locator
+from pages.base_page import BasePage
+from enum import StrEnum
+
+
+class DiagnosticTestOutcomePage(BasePage):
+    """Diagnostic Test Outcome Page locators and methods for interacting with the page."""
+
+    def __init__(self, page: Page):
+        super().__init__(page)
+        self.page = page
+        # Diagnostic Test Outcome- page locators
+        self.test_outcome_dropdown = self.page.get_by_label(
+            "Outcome of Diagnostic Test"
+        )
+        self.save_button = self.page.get_by_role("button", name="Save")
+
+    def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
+        """
+        Verify that the diagnostic test outcome is visible.
+
+        Args:
+            outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
+        """
+        expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
+
+    def select_test_outcome_option(self, option: str) -> None:
+        """Select an option from the Outcome of Diagnostic Test dropdown."""
+        self.test_outcome_dropdown.select_option(option)
path: pages/screening_subject_search/diagnostic_test_outcome_page.py
user: login: mepr1
body: updated
created_at: 2025-05-14T13:21:58Z
author_association: NONE
diff_hunk: @@ -0,0 +1,46 @@
+from playwright.sync_api import Page, expect, Locator
+from pages.base_page import BasePage
+from enum import StrEnum
+
+
+class DiagnosticTestOutcomePage(BasePage):
+    """Diagnostic Test Outcome Page locators and methods for interacting with the page."""
+
+    def __init__(self, page: Page):
+        super().__init__(page)
+        self.page = page
+        # Diagnostic Test Outcome- page locators
+        self.test_outcome_dropdown = self.page.get_by_label(
+            "Outcome of Diagnostic Test"
+        )
+        self.save_button = self.page.get_by_role("button", name="Save")
+
+    def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
+        """
+        Verify that the diagnostic test outcome is visible.
+
+        Args:
+            outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
+        """
+        expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
+
+    def select_test_outcome_option(self, option: str) -> None:
+        """Select an option from the Outcome of Diagnostic Test dropdown.
+
+        Args:
+        option (str): option (str): The option to select from the Outcome Of Diagnostic Test options.
path: pages/screening_subject_search/diagnostic_test_outcome_page.py
user: login: adrianoaru-nhs
body: Can this be indented please (line 31)
created_at: 2025-05-14T13:23:27Z
author_association: NONE
diff_hunk: @@ -0,0 +1,46 @@
+from playwright.sync_api import Page, expect, Locator
+from pages.base_page import BasePage
+from enum import StrEnum
+
+
+class DiagnosticTestOutcomePage(BasePage):
+    """Diagnostic Test Outcome Page locators and methods for interacting with the page."""
+
+    def __init__(self, page: Page):
+        super().__init__(page)
+        self.page = page
+        # Diagnostic Test Outcome- page locators
+        self.test_outcome_dropdown = self.page.get_by_label(
+            "Outcome of Diagnostic Test"
+        )
+        self.save_button = self.page.get_by_role("button", name="Save")
+
+    def verify_diagnostic_test_outcome(self, outcome_name: str) -> None:
+        """
+        Verify that the diagnostic test outcome is visible.
+
+        Args:
+            outcome_name (str): The accessible name or visible text of the test outcome cell to verify.
+        """
+        expect(self.page.get_by_role("cell", name=outcome_name).nth(1)).to_be_visible()
+
+    def select_test_outcome_option(self, option: str) -> None:
+        """Select an option from the Outcome of Diagnostic Test dropdown.
+
+        Args:
+        option (str): option (str): The option to select from the Outcome Of Diagnostic Test options.
+        """
+        self.test_outcome_dropdown.select_option(option)
+
+    def click_save_button(self) -> None:
+        """Click the 'Save' button."""
+        self.click(self.save_button)
+
+
+class OutcomeOfDiagnosticTest(StrEnum):
+    """Enum for outcome of diagnostic test options."""
+
+    Failed_Test_Refer_Another = "20363"
+    Refer_Symptomatic = "20366"
+    Refer_Surveillance = "20365"
+    Investigation_Complete = "20360"
path: pages/screening_subject_search/diagnostic_test_outcome_page.py
user: login: adrianoaru-nhs
body: All the Variable names should be capitalised.
created_at: 2025-05-14T13:23:55Z
author_association: NONE

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-05-14T16:08:24Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=NHSDigital_bcss-playwright&pullRequest=67) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=NHSDigital_bcss-playwright&pullRequest=67&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=NHSDigital_bcss-playwright&pullRequest=67&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=NHSDigital_bcss-playwright&pullRequest=67&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=NHSDigital_bcss-playwright&pullRequest=67&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=NHSDigital_bcss-playwright&pullRequest=67&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=NHSDigital_bcss-playwright&pullRequest=67)


author_association: NONE