11from playwright .sync_api import Page , expect
22from pages .base_page import BasePage
3+ from enum import StrEnum
34
45
56class AppointmentDetailPage (BasePage ):
@@ -13,6 +14,10 @@ def __init__(self, page: Page):
1314 self .attended_check_box = self .page .locator ("#UI_ATTENDED" )
1415 self .calendar_button = self .page .get_by_role ("button" , name = "Calendar" )
1516 self .save_button = self .page .get_by_role ("button" , name = "Save" )
17+ self .cancel_radio = self .page .get_by_role ("radio" , name = "Cancel" )
18+ self .reason_for_cancellation_dropwdown = self .page .get_by_label (
19+ "Reason for Cancellation"
20+ )
1621
1722 def check_attendance_radio (self ) -> None :
1823 """Checks the attendance radio button."""
@@ -26,9 +31,16 @@ def click_calendar_button(self) -> None:
2631 """Clicks the calendar button."""
2732 self .click (self .calendar_button )
2833
29- def click_save_button (self ) -> None :
30- """Clicks the save button."""
31- self .click (self .save_button )
34+ def click_save_button (self , accept_dialog : bool = False ) -> None :
35+ """
36+ Clicks the save button.
37+ Args:
38+ accept_dialog (bool): Whether to accept the dialog.
39+ """
40+ if accept_dialog :
41+ self .safe_accept_dialog (self .save_button )
42+ else :
43+ self .click (self .save_button )
3244
3345 def verify_text_visible (self , text : str ) -> None :
3446 """Verifies that the specified text is visible on the page."""
@@ -60,3 +72,30 @@ def wait_for_attendance_radio(self, timeout_duration: float = 30000) -> None:
6072 timeout_duration - elapsed if timeout_duration - elapsed > 0 else 1000
6173 )
6274 )
75+
76+ def check_cancel_radio (self ) -> None :
77+ """Checks the cancel radio button."""
78+ self .cancel_radio .check ()
79+
80+ def select_reason_for_cancellation_option (self , option : str ) -> None :
81+ """
82+ Selects the reason for cancellation from the dropdown.
83+ Args:
84+ option: The reason for cancellation to select.
85+ The options are in the ReasonForCancellationOptions class
86+ """
87+ self .reason_for_cancellation_dropwdown .select_option (value = option )
88+
89+
90+ class ReasonForCancellationOptions (StrEnum ):
91+ """Enum for cancellation reason options"""
92+
93+ PATIENT_REQUESTS_DISCHARGE_FROM_SCREENING = "6008"
94+ PATIENT_UNSUITABLE_RECENTLY_SCREENED = "6007"
95+ PATIENT_UNSUITABLE_CURRENTLY_UNDERGOING_TREATMENT = "6006"
96+ PATIENT_CANCELLED_TO_CONSIDER = "6005"
97+ PATIENT_CANCELLED_MOVED_OUT_OF_AREA = "6003"
98+ SCREENING_CENTRE_CANCELLED_OTHER_REASON = "6002"
99+ CLINIC_UNAVAILABLE = "6001"
100+ PRACTITIONER_UNAVAILABLE = "6000"
101+ PATIENT_CANCELLED_OTHER_REASON = "6004"
0 commit comments