1
1
# frozen_string_literal: true
2
2
3
3
describe "Self-consent" do
4
- scenario "From Gillick assessment" do
4
+ scenario "after Gillick assessment" do
5
5
given_an_hpv_programme_is_underway
6
6
and_there_is_a_child_without_parental_consent
7
7
15
15
then_the_details_of_the_gillick_competence_assessment_are_visible
16
16
and_the_activity_log_shows_the_gillick_non_competence
17
17
and_the_activity_log_shows_the_gillick_competence
18
+ and_the_nurse_records_consent_for_the_child
18
19
and_the_child_can_give_their_own_consent_that_the_nurse_records
19
20
20
21
when_the_nurse_views_the_childs_record
21
- then_they_see_that_the_child_has_consent
22
+ then_they_see_that_the_child_has_consent_from_themselves
22
23
and_the_child_should_be_safe_to_vaccinate
23
24
and_enqueued_jobs_run_with_no_errors
24
25
end
25
26
27
+ scenario "change to parent consent" do
28
+ given_an_hpv_programme_is_underway
29
+ and_there_is_a_child_with_gillick_competence
30
+ and_the_child_has_a_parent
31
+
32
+ when_the_nurse_goes_to_the_child
33
+ and_the_nurse_records_consent_for_the_child
34
+ and_changes_the_response_method_to_the_parent
35
+ then_the_parent_can_give_consent
36
+
37
+ when_the_nurse_views_the_childs_record
38
+ then_they_see_that_the_child_has_consent_from_the_parent
39
+ and_the_child_should_be_safe_to_vaccinate
40
+ end
41
+
26
42
def given_an_hpv_programme_is_underway
27
- programme = create ( :programme , :hpv )
43
+ @programme = create ( :programme , :hpv )
44
+
28
45
@organisation =
29
- create ( :organisation , :with_one_nurse , programmes : [ programme ] )
46
+ create ( :organisation , :with_one_nurse , programmes : [ @ programme] )
30
47
31
48
@school = create ( :school )
32
49
@@ -35,7 +52,7 @@ def given_an_hpv_programme_is_underway
35
52
:session ,
36
53
:today ,
37
54
organisation : @organisation ,
38
- programmes : [ programme ] ,
55
+ programmes : [ @ programme] ,
39
56
location : @school
40
57
)
41
58
@@ -62,6 +79,25 @@ def and_there_is_a_child_without_parental_consent
62
79
expect ( page ) . to have_content ( @patient . full_name )
63
80
end
64
81
82
+ def and_there_is_a_child_with_gillick_competence
83
+ create (
84
+ :gillick_assessment ,
85
+ :competent ,
86
+ patient_session : @patient . patient_sessions . first ,
87
+ programme : @programme
88
+ )
89
+ end
90
+
91
+ def and_the_child_has_a_parent
92
+ @parent = create ( :parent_relationship , patient : @patient ) . parent
93
+ end
94
+
95
+ def when_the_nurse_goes_to_the_child
96
+ sign_in @organisation . users . first
97
+
98
+ visit session_patient_programme_path ( @session , @patient , @programme )
99
+ end
100
+
65
101
def when_the_nurse_assesses_the_child_as_not_being_gillick_competent
66
102
click_on @patient . full_name
67
103
click_on "Assess Gillick competence"
@@ -176,7 +212,7 @@ def and_the_activity_log_shows_the_gillick_competence
176
212
click_on "HPV"
177
213
end
178
214
179
- def and_the_child_can_give_their_own_consent_that_the_nurse_records
215
+ def and_the_nurse_records_consent_for_the_child
180
216
click_on "Get consent"
181
217
182
218
# who
@@ -197,8 +233,9 @@ def and_the_child_can_give_their_own_consent_that_the_nurse_records
197
233
198
234
choose "Yes, it’s safe to vaccinate"
199
235
click_on "Continue"
236
+ end
200
237
201
- # confirmation page
238
+ def and_the_child_can_give_their_own_consent_that_the_nurse_records
202
239
click_on "Change response method"
203
240
choose "Child (Gillick competent)"
204
241
5 . times { click_on "Continue" }
@@ -208,17 +245,41 @@ def and_the_child_can_give_their_own_consent_that_the_nurse_records
208
245
expect ( page ) . to have_content ( "Consent recorded for #{ @patient . full_name } " )
209
246
end
210
247
248
+ def and_changes_the_response_method_to_the_parent
249
+ click_on "Change response method"
250
+ choose @parent . full_name
251
+ click_on "Continue"
252
+
253
+ click_on "Continue"
254
+
255
+ choose "By phone"
256
+ click_on "Continue"
257
+
258
+ 3 . times { click_on "Continue" }
259
+ end
260
+
261
+ def then_the_parent_can_give_consent
262
+ click_on "Confirm"
263
+ end
264
+
211
265
def when_the_nurse_views_the_childs_record
212
266
click_on @patient . full_name , match : :first
213
267
end
214
268
215
- def then_they_see_that_the_child_has_consent
269
+ def then_they_see_that_the_child_has_consent_from_themselves
216
270
expect ( page ) . to have_content (
217
271
"#{ @patient . full_name } Child (Gillick competent)"
218
272
)
219
273
expect ( page ) . to have_content ( "Consent given" )
220
274
end
221
275
276
+ def then_they_see_that_the_child_has_consent_from_the_parent
277
+ expect ( page ) . to have_content (
278
+ "Consent given\n NameResponse dateDecision #{ @parent . full_name } "
279
+ )
280
+ expect ( page ) . to have_content ( "Consent given" )
281
+ end
282
+
222
283
def and_the_child_should_be_safe_to_vaccinate
223
284
expect ( page ) . to have_content ( "Safe to vaccinate" )
224
285
end
0 commit comments