11# frozen_string_literal: true
22
3- describe "Manage school sessions" do
3+ describe "School sessions" do
44 around { |example | travel_to ( Time . zone . local ( 2024 , 2 , 18 ) ) { example . run } }
55
6- scenario "Adding a new session, closing consent, and closing the session" do
6+ before { Flipper . enable ( :schools_and_sessions ) }
7+
8+ scenario "adding a new session, closing consent, and closing the session" do
79 given_my_team_is_running_an_hpv_vaccination_programme
810 and_i_am_signed_in
911
1012 when_i_go_to_todays_sessions_as_a_nurse
1113 then_i_see_no_sessions
1214
13- when_i_go_to_unscheduled_sessions
14- then_i_see_the_school
15-
16- when_i_seach_for_the_school
17- then_i_see_the_school
18-
19- when_i_click_on_the_school
20- then_i_see_the_school_session
21- and_i_see_a_child_in_the_cohort
22-
23- when_i_click_on_schedule_sessions
15+ when_i_click_on_add_a_new_session
16+ and_i_choose_the_school
17+ and_i_choose_the_programmes
18+ and_i_choose_the_year_groups
2419 then_i_see_the_dates_page
2520
2621 when_i_add_an_invalid_date
4237 then_i_see_the_change_consent_reminders_page
4338 and_i_change_consent_reminders_weeks
4439
45- when_i_save_changes
40+ when_i_save_the_session
4641 then_i_should_see_the_session_details
4742
4843 when_i_go_to_todays_sessions_as_a_nurse
4944 then_i_see_no_sessions
5045
5146 when_i_go_to_scheduled_sessions
5247 then_i_see_the_school
48+ and_i_see_a_child_in_the_cohort
5349
5450 when_i_go_to_completed_sessions
5551 then_i_see_no_sessions
@@ -90,19 +86,11 @@ def given_my_team_is_running_an_hpv_vaccination_programme
9086 programmes : [ @programme , @other_programme ]
9187 )
9288 @location = create ( :school , :secondary , team : @team )
93- @session =
94- create (
95- :session ,
96- :unscheduled ,
97- location : @location ,
98- team : @team ,
99- programmes : [ @programme ]
100- )
10189
10290 @parent = create ( :parent )
10391
10492 @patient =
105- create ( :patient , year_group : 8 , session : @session , parents : [ @parent ] )
93+ create ( :patient , year_group : 8 , location : @location , parents : [ @parent ] )
10694
10795 clinic_session =
10896 create (
@@ -114,15 +102,15 @@ def given_my_team_is_running_an_hpv_vaccination_programme
114102 )
115103
116104 patient_already_in_clinic_without_invitiation =
117- create ( :patient , year_group : 8 , session : @session )
105+ create ( :patient , year_group : 8 , location : @location )
118106 create (
119107 :patient_location ,
120108 patient : patient_already_in_clinic_without_invitiation ,
121109 session : clinic_session
122110 )
123111
124112 patient_already_in_clinic_with_invitiation =
125- create ( :patient , year_group : 8 , session : @session )
113+ create ( :patient , year_group : 8 , location : @location )
126114 create (
127115 :patient_location ,
128116 patient : patient_already_in_clinic_with_invitiation ,
@@ -154,7 +142,7 @@ def when_i_go_to_unscheduled_sessions
154142 click_on "Update results"
155143 end
156144
157- def when_i_seach_for_the_school
145+ def when_i_search_for_the_school
158146 fill_in "Search" , with : @location . name
159147 click_on "Update results"
160148 end
@@ -189,16 +177,48 @@ def and_i_see_a_child_in_the_cohort
189177 expect ( page ) . to have_content ( "3 children" )
190178 end
191179
192- def when_i_click_on_schedule_sessions
193- click_on "Edit session"
194- click_on "Add session dates"
195- end
196-
197180 def and_i_click_on_edit_dates
198181 click_on "Edit session"
199182 click_on "Change session dates"
200183 end
201184
185+ def when_i_click_on_add_a_new_session
186+ click_on "Add a new session"
187+ end
188+
189+ def and_i_choose_the_school
190+ expect ( page ) . to have_content ( "What type of session is this?" )
191+
192+ choose "School"
193+ click_on "Continue"
194+
195+ expect ( page ) . to have_content ( "Where is this school session taking place?" )
196+
197+ select @location . name
198+ click_on "Continue"
199+ end
200+
201+ def and_i_choose_the_programmes
202+ expect ( page ) . to have_content (
203+ "Which programmes will you run in this session?"
204+ )
205+
206+ check "HPV"
207+ click_on "Continue"
208+ end
209+
210+ def and_i_choose_the_year_groups
211+ expect ( page ) . to have_content (
212+ "Which year groups do you want to invite to this session?"
213+ )
214+
215+ check "Year 8"
216+ check "Year 9"
217+ check "Year 10"
218+ check "Year 11"
219+ click_on "Continue"
220+ end
221+
202222 def then_i_see_the_dates_page_but_cannot_change
203223 expect ( page ) . to have_content (
204224 "Children have attended this session. It cannot be changed."
@@ -256,7 +276,7 @@ def when_i_choose_the_dates
256276 end
257277
258278 def then_i_see_the_confirmation_page
259- expect ( page ) . to have_content ( "Edit session " )
279+ expect ( page ) . to have_content ( "Check and confirm " )
260280 end
261281
262282 def when_i_click_on_change_programmes
@@ -310,8 +330,8 @@ def and_i_change_consent_reminders_weeks
310330 click_on "Continue"
311331 end
312332
313- def when_i_save_changes
314- click_on "Save changes "
333+ def when_i_save_the_session
334+ click_on "Continue "
315335 end
316336
317337 def then_i_should_see_the_session_details
@@ -320,7 +340,7 @@ def then_i_should_see_the_session_details
320340 end
321341
322342 def when_the_parent_visits_the_consent_form
323- visit start_parent_interface_consent_forms_path ( @session , @programme )
343+ visit start_parent_interface_consent_forms_path ( Session . last , @programme )
324344 end
325345
326346 def then_they_can_give_consent
@@ -336,12 +356,12 @@ def and_patients_have_been_seen
336356 :attendance_record ,
337357 :present ,
338358 patient : @patient ,
339- session : @session . reload
359+ session : Session . last
340360 )
341361 end
342362
343363 def then_they_can_no_longer_give_consent
344- visit start_parent_interface_consent_forms_path ( @session , @programme )
364+ visit start_parent_interface_consent_forms_path ( Session . last , @programme )
345365 expect ( page ) . to have_content ( "The deadline for responding has passed" )
346366 end
347367
0 commit comments