174174 then_i_see_the_notice_of_sensitive
175175 end
176176
177+ scenario "Important notices for patient added to new team" do
178+ given_another_team_exists
179+ and_a_patient_with_all_notices_exists
180+
181+ when_the_patient_is_added_to_the_new_team
182+ when_i_go_to_the_imports_page_as_a_superuser_in_the_new_team
183+ and_i_click_on_notices
184+ then_i_see_all_patient_notices
185+ and_i_do_not_see_gillick_no_notify_notices
186+ end
187+
177188 def given_my_team_exists
178189 @hpv = Programme . hpv
179190 @flu = Programme . flu
@@ -188,6 +199,18 @@ def given_my_team_exists
188199 TeamSessionsFactory . call ( @team , academic_year : AcademicYear . current )
189200 end
190201
202+ def given_another_team_exists
203+ @new_team =
204+ create (
205+ :team ,
206+ :with_generic_clinic ,
207+ :with_one_nurse ,
208+ programmes : [ @hpv , @flu ]
209+ )
210+
211+ TeamSessionsFactory . call ( @new_team , academic_year : AcademicYear . current )
212+ end
213+
191214 def given_patients_exist
192215 school = create ( :school , team : @team )
193216
@@ -288,6 +311,20 @@ def when_a_restricted_patient_exists
288311 @restricted_patient = create ( :patient , :restricted , session :)
289312 end
290313
314+ def and_a_patient_with_all_notices_exists
315+ session = create ( :session , team : @team , programmes : [ @hpv ] )
316+ @patient_all_notices =
317+ create ( :patient , :deceased , :invalidated , :restricted , session :)
318+ create (
319+ :vaccination_record ,
320+ notify_parents : false ,
321+ patient : @patient_all_notices ,
322+ programme : @hpv ,
323+ session :
324+ )
325+ expect ( @patient_all_notices . important_notices . count ) . to eq ( 4 )
326+ end
327+
291328 def when_i_click_on_children
292329 sign_in @team . users . first
293330
@@ -462,6 +499,12 @@ def when_i_go_to_the_imports_page_as_a_superuser
462499 visit "/imports"
463500 end
464501
502+ def when_i_go_to_the_imports_page_as_a_superuser_in_the_new_team
503+ sign_in @new_team . users . first , superuser : true
504+
505+ visit "/imports"
506+ end
507+
465508 def when_i_wait_for_the_sync_to_complete
466509 Sidekiq ::Job . drain_all
467510 end
@@ -484,6 +527,21 @@ def when_i_click_on_notices
484527
485528 alias_method :and_i_click_on_notices , :when_i_click_on_notices
486529
530+ def when_the_patient_is_added_to_the_new_team
531+ SchoolMove . new (
532+ academic_year : AcademicYear . current ,
533+ home_educated : false ,
534+ patient : @patient_all_notices ,
535+ team : @new_team
536+ ) . confirm!
537+
538+ expect ( @patient_all_notices . teams ) . to include ( @new_team )
539+ expect ( @patient_all_notices . teams ) . to include ( @team )
540+
541+ perform_enqueued_jobs_while_exists ( only : SyncPatientTeamJob )
542+ perform_enqueued_jobs_while_exists ( only : ImportantNoticeGeneratorJob )
543+ end
544+
487545 def then_i_see_no_notices
488546 expect ( page ) . to have_content ( "There are currently no important notices." )
489547 end
@@ -506,6 +564,22 @@ def then_i_see_the_notice_of_sensitive
506564 expect ( page ) . to have_content ( "Record flagged as sensitive" )
507565 end
508566
567+ def then_i_see_all_patient_notices
568+ expect ( page ) . to have_content ( "Important notices (3)" )
569+ expect ( page ) . to have_content ( @patient_all_notices . full_name ) . exactly (
570+ 3
571+ ) . times
572+ expect ( page ) . to have_content ( "Record updated with child’s date of death" )
573+ expect ( page ) . to have_content ( "Record flagged as invalid" )
574+ expect ( page ) . to have_content ( "Record flagged as sensitive" )
575+ end
576+
577+ def and_i_do_not_see_gillick_no_notify_notices
578+ expect ( page ) . not_to have_content (
579+ "does not want their parents to be notified"
580+ )
581+ end
582+
509583 def then_the_vaccination_record_is_created_with_the_nhs
510584 expect ( @stubbed_post_request ) . to have_been_requested
511585 end
0 commit comments