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 :
@@ -326,7 +333,7 @@ def select_consent_not_given_reason(
326333
327334 self .click_continue ()
328335
329- def answer_follow_up_question (self , yes_to_follow_up_request : bool ) -> None :
336+ def answer_follow_up_question (self , * , yes_to_follow_up_request : bool ) -> None :
330337 if yes_to_follow_up_request :
331338 self .follow_up_question_yes_radio .check ()
332339 else :
@@ -337,6 +344,44 @@ 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 = (
361+ "For example, it may be possible to use a vaccine that "
362+ "does not contain gelatine"
363+ )
364+
365+ if refusal_reason == ConsentRefusalReason .MEDICAL_REASONS :
366+ expect (self .page .get_by_text (hint_text_medical )).to_be_visible ()
367+ elif refusal_reason == ConsentRefusalReason .CONTAINS_GELATINE :
368+ expect (self .page .get_by_text (hint_text_gelatine )).to_be_visible ()
369+ else :
370+ expect (self .page .get_by_text (hint_text_medical )).not_to_be_visible ()
371+ expect (self .page .get_by_text (hint_text_gelatine )).not_to_be_visible ()
372+
373+ @step ("Click Change link for discuss options" )
374+ def click_change_discuss_options (self ) -> None :
375+ self .change_discuss_options_link .click ()
376+
377+ @step ("Click Change link for refusal reason" )
378+ def click_change_refusal_reason (self ) -> None :
379+ self .change_reason_for_refusal_link .click ()
380+
381+ @step ("Verify Discuss options is not shown" )
382+ def verify_discuss_options_not_shown (self ) -> None :
383+ expect (self .page .get_by_text ("Discuss options" )).not_to_be_visible ()
384+
340385 def go_to_url (self , url : str ) -> None :
341386 self .page .goto (url )
342387
@@ -358,6 +403,46 @@ def fill_details(
358403
359404 self .fill_parent_details (parent )
360405
406+ @step ("Submit refused consent, follow-up requested: {follow_up_requested}" )
407+ def submit_refusal (
408+ self ,
409+ reason : ConsentRefusalReason = ConsentRefusalReason .PERSONAL_CHOICE ,
410+ * ,
411+ follow_up_requested : bool = False ,
412+ details : str | None = None ,
413+ ) -> None :
414+ self .dont_agree_to_vaccination ()
415+ self .select_consent_not_given_reason (reason , details )
416+ if reason .has_follow_up_option :
417+ self .answer_follow_up_question (follow_up_requested )
418+ self .click_confirm ()
419+
420+ @step ("Submit given consent" )
421+ def submit_positive_consent (
422+ self ,
423+ child : Child ,
424+ programme : Programme ,
425+ consent_option : ConsentOption ,
426+ * ,
427+ yes_to_health_questions : bool = False ,
428+ ) -> None :
429+ if programme is Programme .MMR :
430+ self .agree_to_mmr_vaccination (consent_option )
431+ elif programme is Programme .HPV :
432+ self .agree_to_hpv_vaccination ()
433+ elif programme is Programme .FLU :
434+ self .agree_to_flu_vaccination (consent_option )
435+ elif programme in (Programme .MENACWY , Programme .TD_IPV ):
436+ programmes = [programme ]
437+ self .agree_to_doubles_vaccinations (* programmes )
438+
439+ self .fill_address_details (* child .address )
440+ number_of_questions = len (programme .health_questions (consent_option ))
441+ self .answer_health_questions (
442+ number_of_questions , yes_to_health_questions = yes_to_health_questions
443+ )
444+ self .click_confirm ()
445+
361446 def answer_health_questions (
362447 self , number_of_questions : int , * , yes_to_health_questions : bool
363448 ) -> None :
0 commit comments