1010 Programme ,
1111)
1212from mavis .test .data_models import Child , Parent , School
13+ from mavis .test .utils import expect_details
1314
1415
1516class OnlineConsentWizardPage :
@@ -124,6 +125,12 @@ def __init__(self, page: Page) -> None:
124125 "radio" ,
125126 name = "No" ,
126127 )
128+ self .change_discuss_options_link = self .page .get_by_role (
129+ "link" , name = "Change follow-up request"
130+ )
131+ self .change_reason_for_refusal_link = self .page .get_by_role (
132+ "link" , name = "Change reason for refusal"
133+ )
127134
128135 @step ("Click Continue" )
129136 def click_continue (self ) -> None :
@@ -337,6 +344,41 @@ def expect_confirmation_text(self, text: str) -> None:
337344 confirmation = self .page .locator (".nhsuk-panel.nhsuk-panel--confirmation" )
338345 expect (confirmation ).to_contain_text (text )
339346
347+ @step ("Verify check and confirm refusal details" )
348+ def verify_check_and_confirm_refusal_details (
349+ self , refusal_reason : ConsentRefusalReason , follow_up_requested : bool
350+ ) -> None :
351+ expect_details (self .page , "Reason" , str (refusal_reason ))
352+ expected_discuss_value = "Yes" if follow_up_requested else "No"
353+ expect_details (self .page , "Discuss options" , expected_discuss_value )
354+
355+ @step ("Verify follow-up hint text" )
356+ def verify_follow_up_hint_text (self , refusal_reason : ConsentRefusalReason ) -> None :
357+ hint_text_medical = (
358+ "We understand alternatives might not be suitable in some cases."
359+ )
360+ hint_text_gelatine = "For example, it may be possible to use a vaccine that does not contain gelatine"
361+
362+ if refusal_reason == ConsentRefusalReason .MEDICAL_REASONS :
363+ expect (self .page .get_by_text (hint_text_medical )).to_be_visible ()
364+ elif refusal_reason == ConsentRefusalReason .CONTAINS_GELATINE :
365+ expect (self .page .get_by_text (hint_text_gelatine )).to_be_visible ()
366+ else :
367+ expect (self .page .get_by_text (hint_text_medical )).not_to_be_visible ()
368+ expect (self .page .get_by_text (hint_text_gelatine )).not_to_be_visible ()
369+
370+ @step ("Click Change link for discuss options" )
371+ def click_change_discuss_options (self ) -> None :
372+ self .change_discuss_options_link .click ()
373+
374+ @step ("Click Change link for refusal reason" )
375+ def click_change_refusal_reason (self ) -> None :
376+ self .change_reason_for_refusal_link .click ()
377+
378+ @step ("Verify Discuss options is not shown" )
379+ def verify_discuss_options_not_shown (self ) -> None :
380+ expect (self .page .get_by_text ("Discuss options" )).not_to_be_visible ()
381+
340382 def go_to_url (self , url : str ) -> None :
341383 self .page .goto (url )
342384
@@ -358,6 +400,44 @@ def fill_details(
358400
359401 self .fill_parent_details (parent )
360402
403+ @step ("Submit refused consent, follow-up requested: {follow_up_requested}" )
404+ def submit_refusal (
405+ self ,
406+ reason : ConsentRefusalReason = ConsentRefusalReason .PERSONAL_CHOICE ,
407+ follow_up_requested : bool = False ,
408+ details : str | None = None ,
409+ ) -> None :
410+ self .dont_agree_to_vaccination ()
411+ self .select_consent_not_given_reason (reason , details )
412+ if reason .has_follow_up_option :
413+ self .answer_follow_up_question (follow_up_requested )
414+ self .click_confirm ()
415+
416+ @step ("Submit given consent" )
417+ def submit_positive_consent (
418+ self ,
419+ child : Child ,
420+ programme : Programme ,
421+ consent_option : ConsentOption ,
422+ yes_to_health_questions : bool = False ,
423+ ) -> None :
424+ if programme is Programme .MMR :
425+ self .agree_to_mmr_vaccination (consent_option )
426+ elif programme is Programme .HPV :
427+ self .agree_to_hpv_vaccination ()
428+ elif programme is Programme .FLU :
429+ self .agree_to_flu_vaccination (consent_option )
430+ elif programme in (Programme .MENACWY , Programme .TD_IPV ):
431+ programmes = [programme ]
432+ self .agree_to_doubles_vaccinations (* programmes )
433+
434+ self .fill_address_details (* child .address )
435+ number_of_questions = len (programme .health_questions (consent_option ))
436+ self .answer_health_questions (
437+ number_of_questions , yes_to_health_questions = yes_to_health_questions
438+ )
439+ self .click_confirm ()
440+
361441 def answer_health_questions (
362442 self , number_of_questions : int , * , yes_to_health_questions : bool
363443 ) -> None :
0 commit comments