@@ -132,7 +132,6 @@ def __init__(
132132 "#vaccinate-form-vaccine-method-nasal-field"
133133 )
134134 self .attending_button = self .page .get_by_role ("button" , name = "Attending" ).first
135- self .success_alert = self .page .get_by_role ("alert" , name = "Success" )
136135 self .notes_length_error = (
137136 page .locator ("div" ).filter (has_text = "There is a problemEnter" ).nth (3 )
138137 )
@@ -531,7 +530,7 @@ def add_note(self, note: str):
531530 with self .page .expect_navigation ():
532531 self .click_save_note ()
533532
534- expect ( self .success_alert ). to_contain_text ("Note added" )
533+ self .expect_alert_text ("Note added" )
535534 reload_until_element_is_visible (self .page , self .page .get_by_text (note ))
536535
537536 self .check_notes_appear_in_order ([note ])
@@ -562,22 +561,43 @@ def download_offline_recording_excel(self) -> Path:
562561
563562 return _file_path
564563
565- @step ("Expect text {1}" )
566- def expect_main_to_contain_text (self , text : str ):
567- expect (self .page .locator ("main" )).to_contain_text (text )
564+ def expect_consent_refused_text (self , parent : Parent ):
565+ expect (
566+ self .page .get_by_text (f"{ parent .relationship } refused to give consent." )
567+ ).to_be_visible ()
568+
569+ def check_session_activity_entry (self , text : str ):
570+ expect (self .page .get_by_role ("heading" , name = text ).first ).to_be_visible ()
571+
572+ def expect_conflicting_consent_text (self ):
573+ expect (
574+ self .page .get_by_text (
575+ "You can only vaccinate if all respondents give consent."
576+ )
577+ ).to_be_visible ()
578+
579+ def expect_consent_status (self , programme : Programme , status : str ):
580+ expect (self .page .get_by_text (f"{ programme } : { status } " )).to_be_visible ()
581+
582+ def expect_child_safe_to_vaccinate (self , child : Child ):
583+ expect (
584+ self .page .get_by_text (
585+ f"NURSE, Nurse decided that { str (child )} is safe to vaccinate."
586+ )
587+ ).to_be_visible ()
568588
569589 def get_session_id_from_offline_excel (self ):
570590 file_path = self .download_offline_recording_excel ()
571591 return self .test_data .get_session_id (file_path )
572592
573593 @step ("Add Gillick competence details" )
574594 def add_gillick_competence (
575- self , is_competent : bool , competence_details : str
595+ self ,
596+ is_competent : bool ,
576597 ) -> None :
577598 self .__set_gillick_competence (
578599 is_add = True ,
579600 is_competent = is_competent ,
580- competence_details = competence_details ,
581601 )
582602
583603 @step ("Click Sessions" )
@@ -586,29 +606,35 @@ def click_sessions(self) -> None:
586606
587607 @step ("Edit Gillick competence details" )
588608 def edit_gillick_competence (
589- self , is_competent : bool , competence_details : str
609+ self ,
610+ is_competent : bool ,
590611 ) -> None :
591612 self .__set_gillick_competence (
592613 is_add = False ,
593614 is_competent = is_competent ,
594- competence_details = competence_details ,
595615 )
596616
597617 def __set_gillick_competence (
598- self , is_add : bool , is_competent : bool , competence_details : str
618+ self ,
619+ is_add : bool ,
620+ is_competent : bool ,
599621 ) -> None :
600622 self .answer_gillick_competence_questions (is_competent )
623+ competence_assessment = (
624+ f"Child assessed as { '' if is_competent else 'not ' } Gillick competent"
625+ )
601626
602- self .assessment_notes_textbox .fill (competence_details )
627+ self .assessment_notes_textbox .fill (competence_assessment )
603628 if is_add :
604629 self .click_complete_assessment ()
605630 else :
606631 self .click_update_assessment ()
607- if is_competent :
608- self .expect_main_to_contain_text ("Child assessed as Gillick competent" )
609- else :
610- self .expect_main_to_contain_text ("Child assessed as not Gillick competent" )
611- self .expect_main_to_contain_text (competence_details )
632+
633+ competence_result_locator = self .page .get_by_role (
634+ "heading" , name = "Gillick assessment"
635+ ).locator ("xpath=following-sibling::*[1]" )
636+
637+ expect (competence_result_locator ).to_contain_text (competence_assessment )
612638
613639 def answer_gillick_competence_questions (self , is_competent ):
614640 questions = [
@@ -632,7 +658,7 @@ def __schedule_session(self, on_date: str, expect_error: bool = False):
632658 self .fill_date_fields (_day , _month , _year )
633659 self .click_continue_button ()
634660 if expect_error :
635- self .expect_main_to_contain_text ("There is a problemEnter a date" )
661+ self .expect_alert_text ("There is a problemEnter a date" )
636662
637663 def __edit_session (self , to_date : str ):
638664 _day = to_date [- 2 :]
@@ -650,23 +676,28 @@ def __edit_session(self, to_date: str):
650676 ).not_to_be_visible ()
651677
652678 def verify_triage_updated_for_child (self ):
653- expect ( self .success_alert ). to_contain_text ("Triage outcome updated" )
679+ self .expect_alert_text ("Triage outcome updated" )
654680
655681 def invalidate_parent_refusal (self , parent : Parent ):
682+ invalidation_notes = "Invalidation notes."
656683 self .page .get_by_role ("link" , name = parent .full_name ).click ()
657684 self .click_mark_as_invalid_link ()
658- self .fill_notes ("Invalidation notes." )
685+ self .fill_notes (invalidation_notes )
659686 self .click_mark_as_invalid_button ()
660- self .expect_main_to_contain_text ( "Consent refusedInvalid" )
661- self .expect_main_to_contain_text ( "Invalidation notes." )
687+ self .expect_details ( "Decision" , "Consent refusedInvalid" )
688+ self .expect_details ( "Notes" , invalidation_notes )
662689
663690 self .click_back_to_child ()
664- self .expect_main_to_contain_text ( "Consent refusedInvalid" )
665- self .expect_main_to_contain_text ("No requests have been sent." )
691+ self .expect_details ( "Decision" , "Consent refusedInvalid" )
692+ expect ( self .page . get_by_text ("No requests have been sent." )). to_be_visible ( )
666693
667- def verify_scheduled_date (self , message : str ):
668- self .expect_main_to_contain_text (message )
669- self .click_continue_link ()
694+ def expect_details (self , key : str , value : str ) -> None :
695+ detail_key = self .page .locator (
696+ ".nhsuk-summary-list__key" , has_text = re .compile (f"^{ key } $" )
697+ ).first
698+ detail_value = detail_key .locator ("xpath=following-sibling::*[1]" )
699+
700+ expect (detail_value ).to_contain_text (value )
670701
671702 def schedule_a_valid_session (
672703 self ,
@@ -684,10 +715,13 @@ def schedule_a_valid_session(
684715 else :
685716 offset_days = 10
686717 _future_date = get_offset_date (offset_days = offset_days )
687- _expected_message = f"Session dates{ self .__get_display_formatted_date (date_to_format = _future_date )} "
688718 self .click_session_for_programme_group (location , programme_group )
689719 self .__schedule_session (on_date = _future_date )
690- self .verify_scheduled_date (message = _expected_message )
720+ self .expect_details (
721+ "Session dates" ,
722+ self .__get_display_formatted_date (date_to_format = _future_date ),
723+ )
724+ self .click_continue_link ()
691725
692726 def edit_a_session_to_today (self , location : str , programme_group : str ):
693727 _future_date = get_offset_date (offset_days = 0 )
@@ -741,7 +775,9 @@ def verify_search(self):
741775 """
742776 self .click_consent_tab ()
743777 self .search_for ("a very long string that won't match any names" )
744- self .expect_main_to_contain_text ("No children matching search criteria found" )
778+ expect (
779+ self .page .get_by_text ("No children matching search criteria found" )
780+ ).to_be_visible ()
745781
746782 def search_child (self , child : Child ) -> None :
747783 self .search_for (str (child ))
@@ -790,11 +826,12 @@ def record_vaccs_for_child(
790826 self .vaccination_notes .fill ("Confirmation notes" )
791827 self .click_confirm_button ()
792828
793- expect (self .success_alert ).to_contain_text (
794- f"Vaccination outcome recorded for { programme } "
795- )
829+ self .expect_alert_text (f"Vaccination outcome recorded for { programme } " )
796830 return datetime .now ().astimezone ()
797831
832+ def expect_alert_text (self , text : str ):
833+ expect (self .page .get_by_role ("alert" )).to_contain_text (text )
834+
798835 def verify_child_shows_correct_flu_consent_method (self , child : Child , method : str ):
799836 patient_card = self .page .locator (
800837 f'div.nhsuk-card.app-card.app-card--compact:has(h4:has-text("{ str (child )} "))'
0 commit comments