4343 [ "07700 900000" , "07700 900001" , "07700 900002" , "07700 900003" ]
4444 end
4545
46+ let ( :mmrv_parent_emails ) do
47+ %w[ parent1.child3@example.com parent2.child3@example.com ]
48+ end
49+
50+ let ( :mmrv_parent_phones ) { [ "07700 900004" , "07700 900005" ] }
51+
4652 scenario "Consent requests and reminders are sent automatically" do
4753 given_my_team_is_running_all_vaccination_programmes
4854 and_one_unscheduled_session_exists_with_two_children_and_two_parents_each
55+ and_an_mmrv_eligible_child_with_two_parents_exists
4956 and_i_am_signed_in
5057
5158 when_i_go_to_my_team_page
@@ -75,7 +82,7 @@ def given_my_team_is_running_all_vaccination_programmes
7582 Programme . td_ipv
7683 ]
7784 @team = create ( :team , :with_one_nurse , :with_generic_clinic , programmes :)
78- @location = create ( :school , :secondary , team : @team )
85+ @location = create ( :school , team : @team )
7986 @session =
8087 create (
8188 :session ,
@@ -116,6 +123,33 @@ def and_one_unscheduled_session_exists_with_two_children_and_two_parents_each
116123 end
117124 end
118125
126+ def and_an_mmrv_eligible_child_with_two_parents_exists
127+ parents = [
128+ create (
129+ :parent ,
130+ email : "parent1.child3@example.com" ,
131+ phone : "07700900004" ,
132+ phone_receive_updates : true
133+ ) ,
134+ create (
135+ :parent ,
136+ email : "parent2.child3@example.com" ,
137+ phone : "07700900005" ,
138+ phone_receive_updates : true
139+ )
140+ ]
141+ # Child3 is born after the MMRV eligibility cutoff (2020-01-01) so they
142+ # receive MMRV consent request and reminder emails.
143+ create (
144+ :patient ,
145+ date_of_birth : Date . new ( 2020 , 6 , 1 ) ,
146+ session : @session ,
147+ given_name : "Child3" ,
148+ family_name : "Test" ,
149+ parents :
150+ )
151+ end
152+
119153 def and_i_am_signed_in
120154 sign_in @user
121155 end
@@ -205,6 +239,16 @@ def then_all_four_parents_received_all_programme_consent_requests
205239 parent_phones . each do |phone |
206240 expect_sms_to ( phone , :consent_school_request , :any )
207241 end
242+
243+ mmrv_parent_emails . each do |email |
244+ expect ( email_deliveries ) . to include (
245+ matching_notify_email ( to : email , template : :consent_school_request_mmrv )
246+ )
247+ end
248+
249+ mmrv_parent_phones . each do |phone |
250+ expect_sms_to ( phone , :consent_school_request , :any )
251+ end
208252 end
209253
210254 def then_all_four_parents_received_all_programme_initial_reminders
@@ -223,6 +267,19 @@ def then_all_four_parents_received_all_programme_initial_reminders
223267 parent_phones . each do |phone |
224268 expect_sms_to ( phone , :consent_school_reminder , :any )
225269 end
270+
271+ mmrv_parent_emails . each do |email |
272+ expect ( email_deliveries ) . to include (
273+ matching_notify_email (
274+ to : email ,
275+ template : :consent_school_initial_reminder_mmrv
276+ )
277+ )
278+ end
279+
280+ mmrv_parent_phones . each do |phone |
281+ expect_sms_to ( phone , :consent_school_reminder , :any )
282+ end
226283 end
227284
228285 def then_all_four_parents_received_all_programme_subsequent_reminders
@@ -241,5 +298,18 @@ def then_all_four_parents_received_all_programme_subsequent_reminders
241298 parent_phones . each do |phone |
242299 expect_sms_to ( phone , :consent_school_reminder , :any )
243300 end
301+
302+ mmrv_parent_emails . each do |email |
303+ expect ( email_deliveries ) . to include (
304+ matching_notify_email (
305+ to : email ,
306+ template : :consent_school_subsequent_reminder_mmrv
307+ )
308+ )
309+ end
310+
311+ mmrv_parent_phones . each do |phone |
312+ expect_sms_to ( phone , :consent_school_reminder , :any )
313+ end
244314 end
245315end
0 commit comments