Skip to content

Commit dc2b015

Browse files
Completing scenario 2 and refactoring methods.
1 parent 972d71d commit dc2b015

16 files changed

+529
-306
lines changed

pages/screening_subject_search/advance_surveillance_episode_page.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,40 @@
44

55
class AdvanceSurveillanceEpisodePage(AdvanceEpisodePage):
66
"""Advance Surveillance Episode Page locators, and methods for interacting with the page."""
7-
7+
88
def __init__(self, page: Page):
99
super().__init__(page)
1010
self.page = page
11-
11+
1212
# Locators
13-
self.discharge_from_surveillance_clinical_decision_button = self.page.get_by_role(
14-
"button", name="Discharge from Surveillance - Clinical Decision"
13+
self.discharge_from_surveillance_clinical_decision_button = (
14+
self.page.get_by_role(
15+
"button", name="Discharge from Surveillance - Clinical Decision"
16+
)
17+
)
18+
self.discharge_from_screening_and_surveillance_clinical_decision_button = (
19+
self.page.get_by_role(
20+
"button",
21+
name="Discharge from Screening and Surveillance - Clinical Decision",
22+
)
23+
)
24+
self.book_surveillance_appointment_button = self.page.get_by_role(
25+
"button", name="Book Surveillance Appointment"
1526
)
1627

1728
def click_discharge_from_surveillance_clinical_decision_button(self) -> None:
1829
"""Click on the 'Discharge from Surveillance - Clinical Decision' button."""
1930
self.click(self.discharge_from_surveillance_clinical_decision_button)
31+
32+
def click_discharge_from_screening_and_surveillance_clinical_decision_button(
33+
self,
34+
) -> None:
35+
"""Click on the 'Discharge from Screening and Surveillance - Clinical Decision' button."""
36+
self.click(
37+
self.discharge_from_screening_and_surveillance_clinical_decision_button
38+
)
39+
40+
def click_book_surveillance_appointment_button(self) -> None:
41+
"""Click on the 'Book Surveillance Appointment' button."""
42+
self.safe_accept_dialog(self.book_surveillance_appointment_button)
43+
self.page.wait_for_timeout(500) # Timeout to allow subject to update on the DB.

pages/screening_subject_search/discharge_from_surveillance_page.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,24 @@ def __init__(self, page: Page):
1313

1414
# Locators
1515
self.date_decision_made_input_field = self.page.locator("#UI_OTHER_DATE")
16-
self.screening_consultant_lookup_link = self.page.locator("#UI_CONSULTANT_PIO_SELECT_LINK")
17-
self.screening_pracitioner_dropdown = self.page.locator("#UI_SCREENING_PRACTITIONER")
18-
self.notes_field = self.page.locator("#UI_NOTES")
19-
self.save_button = self.page.get_by_role(
20-
"button", name="Save"
16+
self.screening_consultant_lookup_link = self.page.locator(
17+
"#UI_CONSULTANT_PIO_SELECT_LINK"
18+
)
19+
self.screening_pracitioner_dropdown = self.page.locator(
20+
"#UI_SCREENING_PRACTITIONER"
2121
)
22+
self.notes_field = self.page.locator("#UI_NOTES")
23+
self.save_button = self.page.get_by_role("button", name="Save")
2224

2325
def enter_date_decition_made(self, date: datetime) -> None:
2426
"""
2527
Enter a date into the 'Date Decision Made' field
2628
Args:
2729
date (datetime): the date to enter.
2830
"""
29-
CalendarPicker(self.page).calendar_picker_ddmmyyyy(date, self.date_decision_made_input_field)
31+
CalendarPicker(self.page).calendar_picker_ddmmyyyy(
32+
date, self.date_decision_made_input_field
33+
)
3034

3135
def select_screening_consultant_from_index(self, index: int) -> None:
3236
"""
@@ -63,7 +67,9 @@ def click_save_button(self) -> None:
6367
"""Click on the 'Save' button."""
6468
self.safe_accept_dialog(self.save_button)
6569

66-
def complete_discharge_from_surveillance_form(self, include_screening_consultant: bool) -> None:
70+
def complete_discharge_from_surveillance_form(
71+
self, include_screening_consultant: bool
72+
) -> None:
6773
"""
6874
Completes the discharge from surveillance form.
6975
Args:
@@ -75,4 +81,6 @@ def complete_discharge_from_surveillance_form(self, include_screening_consultant
7581
self.select_screening_pracitioner_from_index(1)
7682
self.fill_notes_field("Notes for subject being discharged")
7783
self.click_save_button()
78-
84+
self.page.wait_for_timeout(
85+
1000
86+
) # Timeout to allow subject to be updated on the DB.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
3+
4+
5+
class ReopenEpisodePage(BasePage):
6+
"""Reopen Episode Page locators, and methods for interacting with the page."""
7+
8+
def __init__(self, page: Page):
9+
super().__init__(page)
10+
self.page = page
11+
12+
self.reopen_to_book_an_assessment_button = self.page.get_by_role(
13+
"button", name="Reopen to book an assessment"
14+
)
15+
self.reopen_episode_for_correction_button = self.page.get_by_role(
16+
"button", name="Reopen episode for correction"
17+
)
18+
self.reopen_due_to_subject_or_patient_decision = self.page.get_by_role(
19+
"button", name="Reopen due to subject or patient decision"
20+
)
21+
self.reopen_following_non_response_button = self.page.get_by_role(
22+
"button", name="Reopen following Non-Response"
23+
)
24+
self.reopen_to_confirm_diagnostic_test_result_and_outcome_button = (
25+
self.page.get_by_role(
26+
"button", name="Reopen to Confirm Diagnostic Test Result and Outcome"
27+
)
28+
)
29+
self.reopen_to_reschedule_diagnostic_test_button = self.page.get_by_role(
30+
"button", name="Reopen to Reschedule Diagnostic Test"
31+
)
32+
self.reopen_to_rerecord_outcome_from_symptomatic_referral_button = (
33+
self.page.get_by_role(
34+
"button", name="Reopen to Re-record Outcome from Symptomatic Referral"
35+
)
36+
)
37+
38+
def click_reopen_to_book_an_assessment_button(self) -> None:
39+
"""Click the 'Reopen to book an assessment' button."""
40+
self.safe_accept_dialog(self.reopen_to_book_an_assessment_button)
41+
42+
def click_reopen_episode_for_correction_button(self) -> None:
43+
"""Click the 'Reopen episode for correction' button."""
44+
self.safe_accept_dialog(self.reopen_episode_for_correction_button)
45+
46+
def click_reopen_due_to_subject_or_patient_decision(self) -> None:
47+
"""Click the 'Reopen due to subject or patient decision' button."""
48+
self.safe_accept_dialog(self.reopen_due_to_subject_or_patient_decision)
49+
50+
def click_reopen_following_non_response_button(self) -> None:
51+
"""Click the 'Reopen following Non-Response' button."""
52+
self.safe_accept_dialog(self.reopen_following_non_response_button)
53+
54+
def click_reopen_to_confirm_diagnostic_test_result_and_outcome_button(self) -> None:
55+
"""Click the 'Reopen to Confirm Diagnostic Test Result and Outcome' button."""
56+
self.safe_accept_dialog(
57+
self.reopen_to_confirm_diagnostic_test_result_and_outcome_button
58+
)
59+
60+
def click_reopen_to_reschedule_diagnostic_test_button(self) -> None:
61+
"""Click the 'Reopen to Reschedule Diagnostic Test' button."""
62+
self.safe_accept_dialog(self.reopen_to_reschedule_diagnostic_test_button)
63+
64+
def click_reopen_to_rerecord_outcome_from_symptomatic_referral_button(self) -> None:
65+
"""Click the 'Reopen to Re-record Outcome from Symptomatic Referral' button."""
66+
self.safe_accept_dialog(
67+
self.reopen_to_rerecord_outcome_from_symptomatic_referral_button
68+
)
Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,10 @@
11
from playwright.sync_api import Page
2-
from pages.base_page import BasePage
2+
from pages.screening_subject_search.reopen_episode_page import ReopenEpisodePage
33

44

5-
class ReopenFOBTScreeningEpisodePage(BasePage):
5+
class ReopenFOBTScreeningEpisodePage(ReopenEpisodePage):
66
"""Reopen FOBT Screening Episode Page locators, and methods for interacting with the page."""
77

88
def __init__(self, page: Page):
99
super().__init__(page)
1010
self.page = page
11-
12-
self.reopen_to_book_an_assessment_button = self.page.get_by_role(
13-
"button", name="Reopen to book an assessment"
14-
)
15-
self.reopen_episode_for_correction_button = self.page.get_by_role(
16-
"button", name="Reopen episode for correction"
17-
)
18-
self.reopen_due_to_subject_or_patient_decision = self.page.get_by_role(
19-
"button", name="Reopen due to subject or patient decision"
20-
)
21-
self.reopen_following_non_response_button = self.page.get_by_role(
22-
"button", name="Reopen following Non-Response"
23-
)
24-
self.reopen_to_confirm_diagnostic_test_result_and_outcome_button = (
25-
self.page.get_by_role(
26-
"button", name="Reopen to Confirm Diagnostic Test Result and Outcome"
27-
)
28-
)
29-
self.reopen_to_reschedule_diagnostic_test_button = self.page.get_by_role(
30-
"button", name="Reopen to Reschedule Diagnostic Test"
31-
)
32-
self.reopen_to_rerecord_outcome_from_symptomatic_referral_button = (
33-
self.page.get_by_role(
34-
"button", name="Reopen to Re-record Outcome from Symptomatic Referral"
35-
)
36-
)
37-
38-
def click_reopen_to_book_an_assessment_button(self) -> None:
39-
"""Click the 'Reopen to book an assessment' button."""
40-
self.safe_accept_dialog(self.reopen_to_book_an_assessment_button)
41-
42-
def click_reopen_episode_for_correction_button(self) -> None:
43-
"""Click the 'Reopen episode for correction' button."""
44-
self.safe_accept_dialog(self.reopen_episode_for_correction_button)
45-
46-
def click_reopen_due_to_subject_or_patient_decision(self) -> None:
47-
"""Click the 'Reopen due to subject or patient decision' button."""
48-
self.safe_accept_dialog(self.reopen_due_to_subject_or_patient_decision)
49-
50-
def click_reopen_following_non_response_button(self) -> None:
51-
"""Click the 'Reopen following Non-Response' button."""
52-
self.safe_accept_dialog(self.reopen_following_non_response_button)
53-
54-
def click_reopen_to_confirm_diagnostic_test_result_and_outcome_button(self) -> None:
55-
"""Click the 'Reopen to Confirm Diagnostic Test Result and Outcome' button."""
56-
self.safe_accept_dialog(
57-
self.reopen_to_confirm_diagnostic_test_result_and_outcome_button
58-
)
59-
60-
def click_reopen_to_reschedule_diagnostic_test_button(self) -> None:
61-
"""Click the 'Reopen to Reschedule Diagnostic Test' button."""
62-
self.safe_accept_dialog(self.reopen_to_reschedule_diagnostic_test_button)
63-
64-
def click_reopen_to_rerecord_outcome_from_symptomatic_referral_button(self) -> None:
65-
"""Click the 'Reopen to Re-record Outcome from Symptomatic Referral' button."""
66-
self.safe_accept_dialog(
67-
self.reopen_to_rerecord_outcome_from_symptomatic_referral_button
68-
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from playwright.sync_api import Page
2+
from pages.screening_subject_search.reopen_episode_page import ReopenEpisodePage
3+
4+
5+
class ReopenSurveillanceEpisodePage(ReopenEpisodePage):
6+
"""Reopen Surveillance Episode Page locators, and methods for interacting with the page."""
7+
8+
def __init__(self, page: Page):
9+
super().__init__(page)
10+
self.page = page

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def __init__(self, page: Page):
106106
self.reopen_fobt_screening_episode_button = self.page.get_by_role(
107107
"button", name="Reopen FOBT Screening Episode"
108108
)
109+
self.reopen_surveillance_episode_button = self.page.get_by_role(
110+
"button", name="Reopen Surveillance Episode"
111+
)
109112
self.reopen_for_correction_button = self.page.get_by_role(
110113
"button", name="Reopen episode for correction"
111114
)
@@ -441,6 +444,10 @@ def click_reopen_fobt_screening_episode_button(self) -> None:
441444
"""Click on the 'Reopen FOBT Screening Episode' button"""
442445
self.click(self.reopen_fobt_screening_episode_button)
443446

447+
def click_reopen_surveillance_episode_button(self) -> None:
448+
"""Click on the 'Reopen Surveillance Episode' button"""
449+
self.click(self.reopen_surveillance_episode_button)
450+
444451
def reopen_fobt_screening_episode(self) -> None:
445452
"""
446453
Reopen a previously closed FOBT screening episode, including confirmation modal.

tests/regression/regression_tests/fobt_regression_tests/test_fobt_scenario_10.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def test_scenario_10(page: Page) -> None:
615615

616616
# And I set the practitioner appointment date to "today"
617617
# And I book the earliest available post investigation appointment on this date
618-
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)", 1)
618+
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
619619

620620
# Then my subject has been updated as follows:
621621
subject_assertion(

tests/regression/regression_tests/fobt_regression_tests/test_fobt_scenario_11.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def test_scenario_11(page: Page) -> None:
600600

601601
# And I set the practitioner appointment date to "today"
602602
# And I book the earliest available post investigation appointment on this date
603-
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)", 1)
603+
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
604604

605605
# Then my subject has been updated as follows:
606606
subject_assertion(
@@ -672,9 +672,7 @@ def test_scenario_11(page: Page) -> None:
672672
# And I set the practitioner appointment date to "today"
673673
# And I book the earliest available post investigation appointment on this date
674674
book_post_investigation_appointment(
675-
page=page,
676-
site="The Royal Hospital (Wolverhampton)",
677-
screening_practitioner_index=1,
675+
page=page, site="The Royal Hospital (Wolverhampton)"
678676
)
679677

680678
# Then my subject has been updated as follows:

tests/regression/regression_tests/fobt_regression_tests/test_fobt_scenario_12.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
YesNoOptions,
5858
EndoscopyLocationOptions,
5959
)
60-
from pages.screening_subject_search.non_neoplastic_result_from_symptomatic_procedure_page import (NonNeoplasticResultFromSymptomaticProcedurePage)
60+
from pages.screening_subject_search.non_neoplastic_result_from_symptomatic_procedure_page import (
61+
NonNeoplasticResultFromSymptomaticProcedurePage,
62+
)
6163
from utils.subject_demographics import SubjectDemographicUtil
6264
from pages.screening_subject_search.reopen_fobt_screening_episode_page import (
6365
ReopenFOBTScreeningEpisodePage,
@@ -431,7 +433,7 @@ def test_scenario_12(page: Page) -> None:
431433

432434
# And I set the practitioner appointment date to "today"
433435
# And I book the earliest available post investigation appointment on this date
434-
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)", 1)
436+
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
435437

436438
# Then my subject has been updated as follows:
437439
subject_assertion(

tests/regression/regression_tests/fobt_regression_tests/test_fobt_scenario_14.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ def test_scenario_14(page: Page) -> None:
677677
SubjectScreeningSummaryPage(page).click_book_practitioner_clinic_button()
678678
# And I set the practitioner appointment date to "today"
679679
# And I book the "earliest" available practitioner appointment on this date
680-
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)", 1)
680+
book_post_investigation_appointment(page, "The Royal Hospital (Wolverhampton)")
681681
# Then my subject has been updated as follows:
682682
subject_assertion(
683683
nhs_no,

0 commit comments

Comments
 (0)