Skip to content

Commit 2ff2967

Browse files
adrianoaru-nhsvictor-soares-ibm
authored andcommitted
Feature/bcss 20443 compartment 6 pom record diagnosis date (#63)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> New POM for the record diagnosis date page ## Context <!-- Why is this change required? What problem does it solve? --> 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) - [ ] 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) - [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 d7fbd88 commit 2ff2967

File tree

4 files changed

+87
-78
lines changed

4 files changed

+87
-78
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
from datetime import datetime
4+
from utils.calendar_picker import CalendarPicker
5+
6+
7+
class RecordDiagnosisDatePage(BasePage):
8+
"""Record Diagnosis Date Page locators, and methods for interacting with the page."""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
13+
# Record Diagnosis Date - page locators
14+
self.diagnosis_date_field = self.page.locator("#diagnosisDate")
15+
self.save_button = self.page.get_by_role("button", name="Save")
16+
17+
def enter_date_in_diagnosis_date_field(self, date: datetime) -> None:
18+
"""
19+
Enters a date in the diagnosis date field.
20+
Args:
21+
date (datetime): The date to enter in the field.
22+
"""
23+
self.click(self.diagnosis_date_field)
24+
CalendarPicker(self.page).v2_calendar_picker(date)
25+
self.diagnosis_date_field.press("Enter")
26+
27+
def click_save_button(self) -> None:
28+
"""Clicks the save button."""
29+
self.click(self.save_button)

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ def __init__(self, page: Page):
5656
"button", name="Advance FOBT Screening Episode"
5757
)
5858

59+
def wait_for_page_title(self) -> None:
60+
"""Waits for the page to be the Subject Screening Summary"""
61+
self.subject_screening_summary.wait_for()
62+
5963
def verify_result_contains_text(self, text) -> None:
6064
"""Verify that the result contains the given text."""
6165
expect(self.display_rs).to_contain_text(text)
@@ -86,6 +90,7 @@ def verify_latest_event_status_header(self) -> None:
8690

8791
def verify_latest_event_status_value(self, latest_event_status: str | list) -> None:
8892
"""Verify that the latest event status value is visible."""
93+
self.wait_for_page_title()
8994
latest_event_status_locator = self.get_visible_status_from_list(
9095
latest_event_status
9196
)

tests/smokescreen/test_compartment_6.py

Lines changed: 52 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from pages.datasets.subject_datasets_page import SubjectDatasetsPage
1212
from utils.calendar_picker import CalendarPicker
1313
from datetime import datetime
14+
from pages.screening_subject_search.record_diagnosis_date_page import (
15+
RecordDiagnosisDatePage,
16+
)
1417
from pages.datasets.investigation_dataset_page import (
1518
InvestigationDatasetsPage,
1619
SiteLookupOptions,
@@ -230,6 +233,36 @@ def after_lnpcp_result(page: Page) -> None:
230233
page.get_by_role("button", name="Save").click()
231234

232235

236+
def handover_subject_to_symptomatic_care(page: Page) -> None:
237+
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
238+
"A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
239+
)
240+
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
241+
242+
# The following code is on the advance fobt screening episode page
243+
page.get_by_role("button", name="Handover into Symptomatic Care").click()
244+
245+
# The following code is on the handover into symptomatic care page
246+
page.get_by_label("Referral").select_option("20445")
247+
page.get_by_role("button", name="Calendar").click()
248+
CalendarPicker(page).v1_calender_picker(datetime.today())
249+
page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK").click()
250+
option_locator = page.locator(
251+
'[value="201"]:visible'
252+
) # Here value '201' is referring to Consultant B, Frame
253+
option_locator.wait_for(state="visible")
254+
option_locator.click()
255+
page.get_by_role("textbox", name="Notes").click()
256+
page.get_by_role("textbox", name="Notes").fill("Test Automation")
257+
page.once("dialog", lambda dialog: dialog.accept())
258+
page.get_by_role("button", name="Save").click()
259+
260+
SubjectScreeningSummaryPage(page).wait_for_page_title()
261+
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
262+
"A385 - Handover into Symptomatic Care"
263+
)
264+
265+
233266
@pytest.mark.vpn_required
234267
@pytest.mark.smokescreen
235268
@pytest.mark.compartment6
@@ -248,7 +281,7 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
248281

249282
# This needs to be repeated for two subjects, one old and one not - High Risk Result
250283
# Older patient
251-
nhs_no = "9056553305"
284+
nhs_no = "9109877185"
252285
go_to_investigation_datasets_page(page, nhs_no)
253286

254287
# The following code is on the investigation datasets page
@@ -260,35 +293,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
260293
save_investigation_dataset(page)
261294
after_high_risk_result(page)
262295

263-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
264-
"A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
265-
)
266-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
267-
268-
# The following code is on the advance fobt screening episode page
269-
page.get_by_role("button", name="Handover into Symptomatic Care").click()
270-
271-
# The following code is on the handover into symptomatic care page
272-
page.get_by_label("Referral").select_option("20445")
273-
page.get_by_role("button", name="Calendar").click()
274-
CalendarPicker(page).v1_calender_picker(datetime.today())
275-
page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK").click()
276-
option_locator = page.locator(
277-
'[value="201"]:visible'
278-
) # Here value '201' is refering to Consultant B, Frame
279-
option_locator.wait_for(state="visible")
280-
option_locator.click()
281-
page.get_by_role("textbox", name="Notes").click()
282-
page.get_by_role("textbox", name="Notes").fill("Test Automation")
283-
page.once("dialog", lambda dialog: dialog.accept())
284-
page.get_by_role("button", name="Save").click()
285-
286-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
287-
"A385 - Handover into Symptomatic Care"
288-
)
296+
handover_subject_to_symptomatic_care(page)
289297

290298
# Younger patient
291-
nhs_no = "9867208471"
299+
nhs_no = "9624131880"
292300
go_to_investigation_datasets_page(page, nhs_no)
293301

294302
# The following code is on the investigation datasets page
@@ -309,17 +317,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
309317
page.get_by_role("button", name="Record Diagnosis Date").click()
310318

311319
# The following code is on the record diagnosis date page
312-
page.locator("#diagnosisDate").click()
313-
CalendarPicker(page).v2_calendar_picker(datetime.today())
314-
page.get_by_role("button", name="Save").click()
320+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
321+
RecordDiagnosisDatePage(page).click_save_button()
315322

316323
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
317324
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
318325
)
319326

320327
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
321328
# Older patient
322-
nhs_no = "9840013254"
329+
nhs_no = "9648064792"
323330
go_to_investigation_datasets_page(page, nhs_no)
324331

325332
# The following code is on the investigation datasets page
@@ -331,35 +338,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
331338
save_investigation_dataset(page)
332339
after_lnpcp_result(page)
333340

334-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
335-
"A394 - Handover into Symptomatic Care for Surveillance - Patient Age"
336-
)
337-
SubjectScreeningSummaryPage(page).click_advance_fobt_screening_episode_button()
338-
339-
# The following code is on the advance fobt screening episode page
340-
page.get_by_role("button", name="Handover into Symptomatic Care").click()
341-
342-
# The following code is on the handover into symptomatic care page
343-
page.get_by_label("Referral").select_option("20445")
344-
page.get_by_role("button", name="Calendar").click()
345-
CalendarPicker(page).v1_calender_picker(datetime.today())
346-
page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK").click()
347-
option_locator = page.locator(
348-
'[value="201"]:visible'
349-
) # Here value '201' is refering to Consultant B, Frame
350-
option_locator.wait_for(state="visible")
351-
option_locator.click()
352-
page.get_by_role("textbox", name="Notes").click()
353-
page.get_by_role("textbox", name="Notes").fill("Test Automation")
354-
page.once("dialog", lambda dialog: dialog.accept())
355-
page.get_by_role("button", name="Save").click()
356-
357-
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
358-
"A385 - Handover into Symptomatic Care"
359-
)
341+
handover_subject_to_symptomatic_care(page)
360342

361343
# Younger patient
362-
nhs_no = "9477527106"
344+
nhs_no = "9627060208"
363345
go_to_investigation_datasets_page(page, nhs_no)
364346

365347
# The following code is on the investigation datasets page
@@ -379,18 +361,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
379361
page.get_by_role("button", name="Record Diagnosis Date").click()
380362

381363
# The following code is on the record diagnosis date page
382-
page.locator("#diagnosisDate").click()
383-
CalendarPicker(page).v2_calendar_picker(datetime.today())
384-
page.locator("#diagnosisDate").press("Enter")
385-
page.get_by_role("button", name="Save").click()
364+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
365+
RecordDiagnosisDatePage(page).click_save_button()
386366

387367
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
388368
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
389369
)
390370

391371
# This needs to be repeated for 1 subject, age does not matter - Normal Result
392-
nhs_no = "9936724968"
393-
go_to_investigation_datasets_page(page, nhs_no)
372+
nhs_no_normal = "9965184321"
373+
go_to_investigation_datasets_page(page, nhs_no_normal)
394374

395375
# The following code is on the investigation datasets page
396376
default_investigation_dataset_forms(page)
@@ -431,18 +411,8 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
431411
page.get_by_role("button", name="Record Diagnosis Date").click()
432412

433413
# The following code is on the record diagnosis date page
434-
page.locator("#diagnosisDate").click()
435-
CalendarPicker(page).v2_calendar_picker(datetime.today())
436-
page.get_by_role("button", name="Save").click()
437-
438-
# Modification needs to be done to accept this list. it should check if any of the values in this list are present. Something like the following:
439-
# def get_first_visible_cell(page, values):
440-
# if isinstance(values, str):
441-
# values = [values]
442-
# for name in values:
443-
# locator = page.get_by_role("cell", name=name)
444-
# if locator.is_visible():
445-
# return locator
414+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
415+
RecordDiagnosisDatePage(page).click_save_button()
446416

447417
batch_processing(
448418
page,
@@ -455,6 +425,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
455425
],
456426
)
457427

428+
# This is to check for the status of a normal subject as this NHS Number cannot be retrieved from the DB
429+
verify_subject_event_status_by_nhs_no(
430+
page, nhs_no_normal, "S61 - Normal (No Abnormalities Found)"
431+
)
432+
458433
batch_processing(
459434
page,
460435
"A385",

utils/batch_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def prepare_and_print_batch(
9292
page: Page, link_text: str, get_subjects_from_pdf: bool = False
9393
) -> pd.DataFrame | None:
9494
"""
95-
This prepares the batch, retreives the files and confirms them as printed
95+
This prepares the batch, retrieves the files and confirms them as printed
9696
Once those buttons have been pressed it waits for the message 'Batch Successfully Archived'
9797
9898
Args:

0 commit comments

Comments
 (0)