Skip to content

Commit 1826273

Browse files
committed
Merge branch 'main' into feature/BCSS-20476-c6-pom-advance-fobt-screening-episode
# Conflicts: # tests/smokescreen/test_compartment_6.py
2 parents 2ab6a03 + 6742386 commit 1826273

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,
@@ -234,6 +237,36 @@ def after_lnpcp_result(page: Page) -> None:
234237
page.get_by_role("button", name="Save").click()
235238

236239

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

253286
# This needs to be repeated for two subjects, one old and one not - High Risk Result
254287
# Older patient
255-
nhs_no = "9056553305"
288+
nhs_no = "9109877185"
256289
go_to_investigation_datasets_page(page, nhs_no)
257290

258291
# The following code is on the investigation datasets page
@@ -264,35 +297,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
264297
save_investigation_dataset(page)
265298
after_high_risk_result(page)
266299

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

294302
# Younger patient
295-
nhs_no = "9867208471"
303+
nhs_no = "9624131880"
296304
go_to_investigation_datasets_page(page, nhs_no)
297305

298306
# The following code is on the investigation datasets page
@@ -313,17 +321,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
313321
AdvanceFOBTScreeningEpisodePage(page).click_record_diagnosis_date_button()
314322

315323
# The following code is on the record diagnosis date page
316-
page.locator("#diagnosisDate").click()
317-
CalendarPicker(page).v2_calendar_picker(datetime.today())
318-
page.get_by_role("button", name="Save").click()
324+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
325+
RecordDiagnosisDatePage(page).click_save_button()
319326

320327
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
321328
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
322329
)
323330

324331
# This needs to be repeated for two subjects, one old and one not - LNPCP Result
325332
# Older patient
326-
nhs_no = "9840013254"
333+
nhs_no = "9648064792"
327334
go_to_investigation_datasets_page(page, nhs_no)
328335

329336
# The following code is on the investigation datasets page
@@ -335,35 +342,10 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
335342
save_investigation_dataset(page)
336343
after_lnpcp_result(page)
337344

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

365347
# Younger patient
366-
nhs_no = "9477527106"
348+
nhs_no = "9627060208"
367349
go_to_investigation_datasets_page(page, nhs_no)
368350

369351
# The following code is on the investigation datasets page
@@ -383,18 +365,16 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
383365
page.get_by_role("button", name="Record Diagnosis Date").click()
384366

385367
# The following code is on the record diagnosis date page
386-
page.locator("#diagnosisDate").click()
387-
CalendarPicker(page).v2_calendar_picker(datetime.today())
388-
page.locator("#diagnosisDate").press("Enter")
389-
page.get_by_role("button", name="Save").click()
368+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
369+
RecordDiagnosisDatePage(page).click_save_button()
390370

391371
SubjectScreeningSummaryPage(page).verify_latest_event_status_value(
392372
"A318 - Post-investigation Appointment NOT Required - Result Letter Created"
393373
)
394374

395375
# This needs to be repeated for 1 subject, age does not matter - Normal Result
396-
nhs_no = "9936724968"
397-
go_to_investigation_datasets_page(page, nhs_no)
376+
nhs_no_normal = "9965184321"
377+
go_to_investigation_datasets_page(page, nhs_no_normal)
398378

399379
# The following code is on the investigation datasets page
400380
default_investigation_dataset_forms(page)
@@ -435,18 +415,8 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
435415
AdvanceFOBTScreeningEpisodePage(page).click_record_diagnosis_date_button()
436416

437417
# The following code is on the record diagnosis date page
438-
page.locator("#diagnosisDate").click()
439-
CalendarPicker(page).v2_calendar_picker(datetime.today())
440-
page.get_by_role("button", name="Save").click()
441-
442-
# 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:
443-
# def get_first_visible_cell(page, values):
444-
# if isinstance(values, str):
445-
# values = [values]
446-
# for name in values:
447-
# locator = page.get_by_role("cell", name=name)
448-
# if locator.is_visible():
449-
# return locator
418+
RecordDiagnosisDatePage(page).enter_date_in_diagnosis_date_field(datetime.today())
419+
RecordDiagnosisDatePage(page).click_save_button()
450420

451421
batch_processing(
452422
page,
@@ -459,6 +429,11 @@ def test_compartment_6(page: Page, smokescreen_properties: dict) -> None:
459429
],
460430
)
461431

432+
# This is to check for the status of a normal subject as this NHS Number cannot be retrieved from the DB
433+
verify_subject_event_status_by_nhs_no(
434+
page, nhs_no_normal, "S61 - Normal (No Abnormalities Found)"
435+
)
436+
462437
batch_processing(
463438
page,
464439
"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)