Skip to content

Commit 870ac35

Browse files
Feature/bcss 19549 playwright compartment5 codegen (#30)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Starting of the code for compartment 5 using the playwright code gen ## Context <!-- Why is this change required? What problem does it solve? --> This change is to allow compartment 5 to be part of the automation script ## 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) - [x] 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. --------- Co-authored-by: AndyG <[email protected]>
1 parent 0a2f6d5 commit 870ac35

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ markers =
3333
compartment2: only for compartment 2
3434
compartment3: only for compartment 3
3535
compartment4: only for compartment 4
36+
compartment5: only for compartment 5
3637
compartment1_plan_creation: to run the plan creation for compartment 1
3738
vpn_required: for tests that require a VPN connection
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import pytest
2+
from playwright.sync_api import Page, expect
3+
from pages.logout.log_out_page import Logout
4+
from pages.base_page import BasePage
5+
from pages.screening_practitioner_appointments.screening_practitioner_appointments import (
6+
ScreeningPractitionerAppointmentsPage,
7+
)
8+
from pages.screening_subject_search.subject_screening_summary import (
9+
SubjectScreeningSummary,
10+
)
11+
from utils.user_tools import UserTools
12+
from utils.load_properties_file import PropertiesFile
13+
from utils.screening_subject_page_searcher import verify_subject_event_status_by_nhs_no
14+
from utils.calendar_picker import CalendarPicker
15+
from datetime import datetime, timedelta
16+
17+
18+
@pytest.fixture
19+
def smokescreen_properties() -> dict:
20+
return PropertiesFile().get_smokescreen_properties()
21+
22+
23+
@pytest.mark.vpn_required
24+
@pytest.mark.smokescreen
25+
@pytest.mark.compartment5
26+
def test_compartment_5(page: Page, smokescreen_properties: dict) -> None:
27+
"""
28+
This is the main compartment 5 method
29+
It involves marking the attendance of subjects to their screening practitioner appointments
30+
Then it invites them for colonoscopy
31+
Then it marks post investigation appointment as not required
32+
"""
33+
34+
# --------------
35+
# Attendance of Screening
36+
# Practitioner Clinic Appointment
37+
# --------------
38+
39+
# Log in as a Screening Centre user
40+
UserTools.user_login(page, "Screening Centre Manager at BCS001")
41+
42+
# From the Main Menu, choose the 'Screening Practitioner Appointments' and then 'View Appointments' option
43+
BasePage(page).go_to_screening_practitioner_appointments_page()
44+
ScreeningPractitionerAppointmentsPage(page).go_to_view_appointments_page()
45+
46+
# Select the Appointment Type, Site, Screening Practitioner and required date of the appointment and click 'View appointments on this day' button
47+
page.locator("#UI_APPOINTMENT_TYPE").select_option(label="Colonoscopy Assessment")
48+
page.locator("#UI_SCREENING_CENTRE").select_option(
49+
label="BCS001 - Wolverhampton Bowel Cancer Screening Centre"
50+
)
51+
page.locator("#UI_SITE").select_option(label="The Royal Hospital (Wolverhampton)")
52+
53+
page.get_by_role("button", name="View appointments on this day").click()
54+
page.get_by_role("button", name="Calendar").click()
55+
date_from_util = datetime(2025, 4, 28)
56+
CalendarPicker(page).v1_calender_picker(date_from_util)
57+
58+
# Select subject from inital test data util
59+
page.get_by_role("link", name="HAT-PIN UNTRUTH").click()
60+
61+
# Select Attendance radio button, tick Attended checkbox, set Attended Date to yesterday's (system) date and then press Save
62+
page.get_by_role("radio", name="Attendance").check()
63+
page.locator("#UI_ATTENDED").check()
64+
page.get_by_role("button", name="Calendar").click()
65+
CalendarPicker(page).v1_calender_picker(datetime.today() - timedelta(1))
66+
page.get_by_role("button", name="Save").click()
67+
expect(page.get_by_text("Record updated")).to_be_visible()
68+
69+
# Repeat for x Abnormal patients
70+
71+
# Navigate to the 'Subject Screening Summary' screen for the 1st Abnormal patient
72+
nhs_no = "9543076472" # Test NHS NO for Scaliding Cod
73+
verify_subject_event_status_by_nhs_no(
74+
page, nhs_no, "J10 - Attended Colonoscopy Assessment Appointment"
75+
)
76+
77+
# Click on 'Datasets' link
78+
page.get_by_role("link", name="Datasets").click()
79+
80+
# Click on 'Show Dataset' next to the Colonoscopy Assessment
81+
82+
# Populate Colonoscopy Assessment Details fields
83+
84+
# ASA Grade - I - Fit
85+
# Fit for Colonoscopy (SSP) - Yes
86+
87+
# Click 'Yes' for Dataset Complete?
88+
# Click Save Dataset button
89+
# Click Back
90+
page.get_by_role("link", name="Show Dataset").click()
91+
page.get_by_label("ASA Grade").select_option("17009")
92+
page.get_by_label("Fit for Colonoscopy (SSP)").select_option("17058")
93+
page.get_by_role("radio", name="Yes").check()
94+
page.locator("#UI_DIV_BUTTON_SAVE1").get_by_role(
95+
"button", name="Save Dataset"
96+
).click()
97+
BasePage(page).click_back_button()
98+
BasePage(page).click_back_button()
99+
# This brings you back to the subject screening summary page
100+
101+
# On the Subject Screening Summary click on the 'Advance FOBT Screening Episode' button and then click on the 'Suitable for Endoscopic Test' button
102+
# Click OK after message
103+
page.get_by_role("button", name="Advance FOBT Screening Episode").click()
104+
page.once("dialog", lambda dialog: dialog.accept())
105+
page.get_by_role("button", name="Suitable for Endoscopic Test").click()
106+
107+
# Enter a 'First Offered Appointment Date' (enter a date after the attended appt)
108+
page.get_by_role("button", name="Calendar").click()
109+
CalendarPicker(page).v1_calender_picker(datetime.today())
110+
111+
# Select 'Colonoscopy' from the 'Type of Test' from the drop down list
112+
page.locator("#UI_EXT_TEST_TYPE_2233").select_option(label="Colonoscopy")
113+
114+
# Click the 'Invite for Diagnostic Test >>' button
115+
# Click 'OK'
116+
page.once("dialog", lambda dialog: dialog.accept())
117+
page.get_by_role("button", name="Invite for Diagnostic Test >>").click()
118+
SubjectScreeningSummary(page).verify_latest_event_status_value(
119+
"A59 - Invited for Diagnostic Test"
120+
)
121+
122+
# Click 'Attend Diagnostic Test' button
123+
page.get_by_role("button", name="Attend Diagnostic Test").click()
124+
125+
# Select Colonoscopy from drop down list. Enter the actual appointment date as today's date and select 'Save'
126+
page.locator("#UI_CONFIRMED_TYPE_OF_TEST").select_option(label="Colonoscopy")
127+
page.get_by_role("button", name="Calendar").click()
128+
CalendarPicker(page).v1_calender_picker(datetime.today())
129+
page.get_by_role("button", name="Save").click()
130+
SubjectScreeningSummary(page).verify_latest_event_status_value(
131+
"A259 - Attended Diagnostic Test"
132+
)
133+
# Repeat above for x number of subjects
134+
135+
# Click on 'Advance FOBT Screening Episode' button for the 1st Abnormal patient
136+
verify_subject_event_status_by_nhs_no(
137+
page, nhs_no, "A259 - Attended Diagnostic Test"
138+
)
139+
page.get_by_role("button", name="Advance FOBT Screening Episode").click()
140+
141+
# Click 'Other Post-investigation Contact Required' button
142+
# Click 'OK'
143+
page.once("dialog", lambda dialog: dialog.accept())
144+
page.get_by_role("button", name="Other Post-investigation").click()
145+
expect(
146+
page.get_by_role(
147+
"cell", name="A361 - Other Post-investigation Contact Required", exact=True
148+
)
149+
).to_be_visible()
150+
151+
# Select 'Record other post-investigation contact' button
152+
page.get_by_role("button", name="Record other post-").click()
153+
154+
# Complete 'Contact Direction', To patient
155+
# 'Contact made between patient and', Selects the top option in the dropdown
156+
# 'Date of Patient Contact', Today
157+
# 'Duration', 01:00
158+
# 'Start Time', 11:00
159+
# 'End Time', 12:00
160+
# 'Discussion Record' TEST AUTOMATION
161+
# select 'Outcome' - 'Post-investigation Appointment Not Required' and click 'Save'
162+
page.locator("#UI_DIRECTION").select_option(label="To patient")
163+
page.locator("#UI_CALLER_ID").select_option(index=0)
164+
page.get_by_role("button", name="Calendar").click()
165+
CalendarPicker(page).v1_calender_picker(datetime.today())
166+
page.locator("#UI_START_TIME").click()
167+
page.locator("#UI_START_TIME").fill("11:00")
168+
page.locator("#UI_END_TIME").click()
169+
page.locator("#UI_END_TIME").fill("12:00")
170+
page.locator("#UI_COMMENT_ID").click()
171+
page.locator("#UI_COMMENT_ID").fill("Test Automation")
172+
page.locator("#UI_OUTCOME").select_option(
173+
label="Post-investigation Appointment Not Required"
174+
)
175+
page.get_by_role("button", name="Save").click()
176+
177+
verify_subject_event_status_by_nhs_no(
178+
page, nhs_no, "A361 - Other Post-investigation Contact Required"
179+
)
180+
181+
# Repeat above for x subjects
182+
183+
Logout(page).log_out()

0 commit comments

Comments
 (0)