Skip to content

Commit 2970c30

Browse files
Feature/bcss 20228 compartment 4 codegen (#22)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This is adding compartment 4 using the codegen to generate the necessary code. Where possible I have used existing POMs and added comments to sections where new utils or loops are required. Note: This will not work if we were to run it due to having hard coded NHS numbers which have since been progressed to future episodes. However the SQL query to return the relevant NHS Numbers has been added as a comment ## Context <!-- Why is this change required? What problem does it solve? --> This add C4 to the repo so that we can run these as part of the smokescreen tests. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [ ] 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. The NHS Numbers used in the code are test data and are not actual NHS Numbers
1 parent 4f82c28 commit 2970c30

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import logging
2+
import pytest
3+
from playwright.sync_api import Page, expect
4+
from pages.logout.log_out_page import Logout
5+
from pages.base_page import BasePage
6+
from utils.user_tools import UserTools
7+
from utils.load_properties_file import PropertiesFile
8+
from utils.calendar_picker import CalendarPicker
9+
from utils.batch_processing import batch_processing
10+
from datetime import datetime
11+
12+
13+
@pytest.fixture
14+
def smokescreen_properties() -> dict:
15+
return PropertiesFile().get_smokescreen_properties()
16+
17+
18+
@pytest.mark.smokescreen
19+
@pytest.mark.compartment4
20+
def test_compartment_4(page: Page, smokescreen_properties: dict) -> None:
21+
"""
22+
This is the main compartment 4 method
23+
First it obtains the necessary test data from the DB
24+
Then it logs on as a Screening Centre Manager and sets the availablity of a practitioner from 09:00 to 17:15 from todays date for the next 6 weeks
25+
After It logs out an logs back in as a Hub Manager
26+
Once logging back in it books appointments for the subjects retrieved earlier
27+
Finally it processes the necessary batches to send out the letters and checks the subjects satus has been updated to what is expected
28+
"""
29+
30+
# Add method of getting test data using the query below. To remove once subject retrieval logic is created
31+
"""select tk.kitid, ss.subject_nhs_number, se.screening_subject_id
32+
from tk_items_t tk
33+
inner join ep_subject_episode_t se on se.screening_subject_id = tk.screening_subject_id
34+
inner join screening_subject_t ss on ss.screening_subject_id = se.screening_subject_id
35+
inner join sd_contact_t c on c.nhs_number = ss.subject_nhs_number
36+
where se.latest_event_status_id = 11132
37+
and tk.logged_in_flag = 'Y'
38+
and se.episode_status_id = 11352
39+
and ss.screening_status_id != 4008
40+
and tk.logged_in_at = 23159
41+
and c.hub_id = 23159
42+
and tk.tk_type_id = 2
43+
and tk.datestamp > add_months(sysdate,-24)
44+
order by ss.subject_nhs_number desc"""
45+
46+
UserTools.user_login(page, "Screening Centre Manager at BCS001")
47+
BasePage(page).go_to_screening_practitioner_appointments_page()
48+
page.get_by_role("link", name="Set Availability").click()
49+
page.get_by_role("link", name="Practitioner Availability -").click()
50+
page.locator("#UI_SITE_ID").select_option(index=1)
51+
page.locator("#UI_PRACTITIONER_ID").select_option(index=1)
52+
page.get_by_role("button", name="Calendar").click()
53+
CalendarPicker(page).select_day(
54+
datetime.today()
55+
) # This will make it so that we can only run this test once a day, or we need to restore the DB back to the snapshot
56+
page.get_by_role("button", name="Show").dblclick()
57+
page.get_by_role("textbox", name="From:").click()
58+
page.get_by_role("textbox", name="From:").fill("09:00")
59+
page.get_by_role("textbox", name="To:").click()
60+
page.get_by_role("textbox", name="To:").fill("17:15")
61+
page.get_by_role("button", name="Calculate Slots").click()
62+
page.locator("#FOR_WEEKS").click()
63+
page.locator("#FOR_WEEKS").fill("6")
64+
page.locator("#FOR_WEEKS").press("Enter")
65+
page.get_by_role("button", name="Save").click()
66+
expect(page.get_by_text("Slots Updated for 6 Weeks")).to_be_visible()
67+
Logout(page).log_out()
68+
69+
page.get_by_role("button", name="Log in").click()
70+
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
71+
BasePage(page).go_to_screening_practitioner_appointments_page()
72+
page.get_by_role("link", name="Patients that Require").click()
73+
# Add for loop to loop x times (depends on how many we want to run it for) 70 - 79
74+
page.locator("#nhsNumberFilter").click()
75+
page.locator("#nhsNumberFilter").fill("9991406131")
76+
page.locator("#nhsNumberFilter").press("Enter")
77+
page.get_by_role("link", name="999 140 6131").click()
78+
page.get_by_label("Screening Centre ( All)").select_option("23162")
79+
page.locator("#UI_NEW_SITE").select_option("42808")
80+
page.locator('input[name="fri2"]').click() # Todays date if available
81+
page.locator("#UI_NEW_SLOT_SELECTION_ID_359119").check()
82+
page.get_by_role("button", name="Save").click()
83+
expect(page.get_by_text("Appointment booked")).to_be_visible()
84+
85+
batch_processing(
86+
page,
87+
"A183",
88+
"Practitioner Clinic 1st Appointment",
89+
"A25 - 1st Colonoscopy Assessment Appointment Booked, letter sent",
90+
)
91+
92+
batch_processing(
93+
page,
94+
"A183",
95+
"GP Result (Abnormal)",
96+
"A25 - 1st Colonoscopy Assessment Appointment Booked, letter sent",
97+
)
98+
page.locator("#ID_LINK_EPISODES_img").click()
99+
page.get_by_role("link", name="FOBT Screening").click()
100+
expect(
101+
page.get_by_role("cell", name="A167 - GP Abnormal FOBT Result Sent", exact=True)
102+
).to_be_visible()
103+
Logout(page).log_out()

0 commit comments

Comments
 (0)