5252
5353 scenario "Given self consent, and requested parents aren't notified, and vaccinated, then invalidate" do
5454 given_i_am_signed_in
55- and_self_consent_has_been_given
56- and_patient_has_been_vaccinated_with_no_parent_notification
55+ and_the_api_feature_flag_is_enabled
56+ and_self_consent_has_been_given_with_no_parent_notification
57+
58+ when_the_patient_has_been_vaccinated_with_no_parent_notification
59+ then_the_record_is_not_synced_to_the_imms_api
5760
5861 when_i_go_to_the_patient
5962 then_i_see_the_self_consent
6467 when_i_fill_in_the_notes
6568 and_i_click_invalidate_consent
6669 then_i_see_the_consent_has_been_invalidated
67- and_the_vaccination_record_is_updated_to_notify_parents
70+ and_the_vaccination_record_is_updated_to_notify_parents_true
71+ and_the_vaccination_record_is_synced_to_the_imms_api
6872 end
6973
7074 def given_i_am_signed_in
@@ -76,6 +80,11 @@ def given_i_am_signed_in
7680 sign_in team . users . first
7781 end
7882
83+ def and_the_api_feature_flag_is_enabled
84+ Flipper . enable ( :enqueue_sync_vaccination_records_to_nhs )
85+ Flipper . enable ( :immunisations_fhir_api_integration )
86+ end
87+
7988 def and_consent_has_been_given
8089 @consent =
8190 create ( :consent , :given , patient : @patient , programme : @programme )
@@ -161,7 +170,7 @@ def and_i_am_not_able_to_record_a_vaccination
161170 expect ( page ) . not_to have_content ( "ready for their HPV vaccination?" )
162171 end
163172
164- def and_self_consent_has_been_given
173+ def and_self_consent_has_been_given_with_no_parent_notification
165174 @consent =
166175 create (
167176 :consent ,
@@ -178,7 +187,7 @@ def and_self_consent_has_been_given
178187 )
179188 end
180189
181- def and_patient_has_been_vaccinated_with_no_parent_notification
190+ def when_the_patient_has_been_vaccinated_with_no_parent_notification
182191 @vaccination_record =
183192 create (
184193 :vaccination_record ,
@@ -197,7 +206,20 @@ def when_i_click_on_the_self_consent
197206 click_on "Child (Gillick competent)"
198207 end
199208
200- def and_the_vaccination_record_is_updated_to_notify_parents
209+ def and_the_vaccination_record_is_updated_to_notify_parents_true
201210 expect ( @vaccination_record . reload . notify_parents ) . to be true
202211 end
212+
213+ def then_the_record_is_not_synced_to_the_imms_api
214+ @stubbed_post_request =
215+ stub_immunisations_api_post ( uuid : @vaccination_record . uuid )
216+
217+ perform_enqueued_jobs ( only : SyncVaccinationRecordToNHSJob )
218+ expect ( @stubbed_post_request ) . not_to have_been_requested
219+ end
220+
221+ def and_the_vaccination_record_is_synced_to_the_imms_api
222+ perform_enqueued_jobs ( only : SyncVaccinationRecordToNHSJob )
223+ expect ( @stubbed_post_request ) . to have_been_requested
224+ end
203225end
0 commit comments