@@ -108,6 +108,38 @@ def assert_diagnosis_event_details(
108108 ), f"Expected today's date ({ today_formatted } ) in item but got: { event_details ['item' ]} "
109109
110110
111+ def amend_diagnosis_date_with_reason (
112+ page : Page ,
113+ reason_code : str ,
114+ date : Optional [datetime ] = None ,
115+ click_back_steps : int = 2 ,
116+ ) -> None :
117+ """
118+ Navigates back, amends diagnosis date with a reason, and opens the events page.
119+
120+ Args:
121+ page (Page): Playwright page object
122+ reason_code (str): The dropdown value to select for reason
123+ date (Optional[datetime]): The date to enter in the field. Defaults to today.
124+ click_back_steps (int): How many times to click the 'Back' link
125+ """
126+ for _ in range (click_back_steps ):
127+ page .get_by_role ("link" , name = "Back" , exact = True ).click ()
128+
129+ subject_page = RecordDiagnosisDatePage (page )
130+ page .get_by_role ("button" , name = "Advance FOBT Screening Episode" ).click ()
131+ page .get_by_role ("checkbox" ).check ()
132+ page .get_by_role ("button" , name = "Amend Diagnosis Date" ).click ()
133+
134+ if date is None :
135+ date = datetime .today ()
136+ subject_page .enter_date_in_diagnosis_date_field (date )
137+ page .locator ("#reason" ).select_option (reason_code )
138+ subject_page .click_save_button ()
139+ page .get_by_role ("link" , name = "List Episodes" ).click ()
140+ page .get_by_role ("link" , name = "events" ).click ()
141+
142+
111143# Scenario 1
112144@pytest .mark .regression
113145@pytest .mark .vpn_required
@@ -720,16 +752,7 @@ def test_record_and_amend_diagnosis_date_multiple_times(page: Page):
720752
721753 # --- Second: Amend Diagnosis Date (today, with reason) ---
722754 # Step 7: Interact with subject page
723- [page .get_by_role ("link" , name = "Back" , exact = True ).click () for _ in range (2 )]
724- subject_page_s15 = RecordDiagnosisDatePage (page )
725- page .get_by_role ("button" , name = "Advance FOBT Screening Episode" ).click ()
726- page .get_by_role ("checkbox" ).check ()
727- page .get_by_role ("button" , name = "Amend Diagnosis Date" ).click ()
728- subject_page_s15 .enter_date_in_diagnosis_date_field (datetime .today ())
729- page .locator ("#reason" ).select_option ("305501" )
730- subject_page_s15 .click_save_button ()
731- page .get_by_role ("link" , name = "List Episodes" ).click ()
732- page .get_by_role ("link" , name = "events" ).click ()
755+ amend_diagnosis_date_with_reason (page , reason_code = "305501" )
733756
734757 # Step 8: Assertions
735758 subject_event_status_s15 = SubjectEpisodeEventsAndNotesPage (page )
@@ -780,16 +803,7 @@ def test_record_and_amend_diagnosis_date_multiple_times(page: Page):
780803
781804 # --- Fourth: Amend Diagnosis Date again (today, with reason) ---
782805 # Step 11: Interact with subject page
783- [page .get_by_role ("link" , name = "Back" , exact = True ).click () for _ in range (2 )]
784- subject_page_s15 = RecordDiagnosisDatePage (page )
785- page .get_by_role ("button" , name = "Advance FOBT Screening Episode" ).click ()
786- page .get_by_role ("checkbox" ).check ()
787- page .get_by_role ("button" , name = "Amend Diagnosis Date" ).click ()
788- subject_page_s15 .enter_date_in_diagnosis_date_field (datetime .today ())
789- page .locator ("#reason" ).select_option ("305501" )
790- subject_page_s15 .click_save_button ()
791- page .get_by_role ("link" , name = "List Episodes" ).click ()
792- page .get_by_role ("link" , name = "events" ).click ()
806+ amend_diagnosis_date_with_reason (page , reason_code = "305501" )
793807
794808 # Step 12: Assertions
795809 subject_event_status_s15 = SubjectEpisodeEventsAndNotesPage (page )
0 commit comments