|
22 | 22 | and_an_activity_log_entry_is_visible_for_the_text_tagged_as("HPV") |
23 | 23 | end |
24 | 24 |
|
25 | | - scenario "Send request where patient is eligible for MMRV" do |
| 25 | + scenario "Send clinic request where patient is eligible for MMRV" do |
26 | 26 | given_a_programme_exists(:mmr) |
27 | 27 | and_a_patient_without_consent_exists |
28 | 28 | and_i_am_signed_in |
|
40 | 40 | and_an_activity_log_entry_is_visible_for_the_text_tagged_as("MMRV") |
41 | 41 | end |
42 | 42 |
|
| 43 | + scenario "Send school request where patient is eligible for MMRV" do |
| 44 | + given_a_programme_exists(:mmr) |
| 45 | + and_a_school_session_with_mmrv_eligible_patient_exists |
| 46 | + and_i_am_signed_in |
| 47 | + |
| 48 | + when_i_go_to_a_patient_without_consent |
| 49 | + then_i_see_no_requests_sent |
| 50 | + |
| 51 | + when_i_click_send_consent_request |
| 52 | + then_i_see_the_confirmation_banner |
| 53 | + and_the_mmrv_email_template_is_sent_to_the_parent |
| 54 | + |
| 55 | + when_i_click_on_session_activity_and_notes |
| 56 | + then_an_activity_log_entry_is_visible_for_the_email_tagged_as( |
| 57 | + "MMRV", |
| 58 | + clinic: false |
| 59 | + ) |
| 60 | + end |
| 61 | + |
| 62 | + scenario "Send school request where patient is not eligible for MMRV" do |
| 63 | + given_a_programme_exists(:mmr) |
| 64 | + and_a_school_session_with_mmr_only_patient_exists |
| 65 | + and_i_am_signed_in |
| 66 | + |
| 67 | + when_i_go_to_a_patient_without_consent |
| 68 | + then_i_see_no_requests_sent |
| 69 | + |
| 70 | + when_i_click_send_consent_request |
| 71 | + then_i_see_the_confirmation_banner |
| 72 | + and_the_mmr_email_template_is_sent_to_the_parent |
| 73 | + |
| 74 | + when_i_click_on_session_activity_and_notes |
| 75 | + then_an_activity_log_entry_is_visible_for_the_email_tagged_as( |
| 76 | + "MMR", |
| 77 | + clinic: false |
| 78 | + ) |
| 79 | + end |
| 80 | + |
43 | 81 | def given_a_programme_exists(programme_type) |
44 | 82 | @programmes = [Programme.public_send(programme_type)] |
45 | 83 | end |
@@ -71,6 +109,60 @@ def and_a_patient_without_consent_exists |
71 | 109 | PatientStatusUpdater.call |
72 | 110 | end |
73 | 111 |
|
| 112 | + def and_a_school_session_with_mmrv_eligible_patient_exists |
| 113 | + @team = create(:team, :with_one_nurse, programmes: @programmes) |
| 114 | + @user = @team.users.first |
| 115 | + |
| 116 | + location = create(:school, team: @team, programmes: @programmes) |
| 117 | + |
| 118 | + @session = |
| 119 | + create( |
| 120 | + :session, |
| 121 | + team: @team, |
| 122 | + programmes: @programmes, |
| 123 | + location:, |
| 124 | + date: Date.current + 2.days |
| 125 | + ) |
| 126 | + |
| 127 | + @parent = create(:parent) |
| 128 | + @patient = |
| 129 | + create( |
| 130 | + :patient, |
| 131 | + session: @session, |
| 132 | + parents: [@parent], |
| 133 | + date_of_birth: Programme::MIN_MMRV_ELIGIBILITY_DATE + 1.month |
| 134 | + ) |
| 135 | + |
| 136 | + PatientStatusUpdater.call |
| 137 | + end |
| 138 | + |
| 139 | + def and_a_school_session_with_mmr_only_patient_exists |
| 140 | + @team = create(:team, :with_one_nurse, programmes: @programmes) |
| 141 | + @user = @team.users.first |
| 142 | + |
| 143 | + location = create(:school, team: @team, programmes: @programmes) |
| 144 | + |
| 145 | + @session = |
| 146 | + create( |
| 147 | + :session, |
| 148 | + team: @team, |
| 149 | + programmes: @programmes, |
| 150 | + location:, |
| 151 | + date: Date.current + 2.days |
| 152 | + ) |
| 153 | + |
| 154 | + @parent = create(:parent) |
| 155 | + @patient = |
| 156 | + create( |
| 157 | + :patient, |
| 158 | + session: @session, |
| 159 | + parents: [@parent], |
| 160 | + date_of_birth: Programme::MIN_MMRV_ELIGIBILITY_DATE - 1.month |
| 161 | + ) |
| 162 | + |
| 163 | + PatientStatusUpdater.call |
| 164 | + end |
| 165 | + |
74 | 166 | def and_i_am_signed_in |
75 | 167 | sign_in @user |
76 | 168 | end |
@@ -107,15 +199,25 @@ def and_a_text_is_sent_to_the_parent |
107 | 199 | expect_sms_to(@parent.phone, :consent_clinic_request) |
108 | 200 | end |
109 | 201 |
|
| 202 | + def and_the_mmrv_email_template_is_sent_to_the_parent |
| 203 | + expect_email_to(@parent.email, :consent_school_request_mmrv) |
| 204 | + end |
| 205 | + |
| 206 | + def and_the_mmr_email_template_is_sent_to_the_parent |
| 207 | + expect_email_to(@parent.email, :consent_school_request_mmr) |
| 208 | + end |
| 209 | + |
110 | 210 | def when_i_click_on_session_activity_and_notes |
111 | 211 | click_on "Session activity and notes" |
112 | 212 | end |
113 | 213 |
|
114 | 214 | def then_an_activity_log_entry_is_visible_for_the_email_tagged_as( |
115 | | - programme_name |
| 215 | + programme_name, |
| 216 | + clinic: true |
116 | 217 | ) |
117 | 218 | expect(page).to have_content( |
118 | | - "Consent clinic request sent\n#{@parent.email}\n" \ |
| 219 | + "Consent #{clinic ? "clinic" : "school"} request#{clinic ? "" : " #{programme_name.downcase}"} sent" \ |
| 220 | + "\n#{@parent.email}\n" \ |
119 | 221 | "#{programme_name} 1 January 2024 at 12:00am · USER, Test" |
120 | 222 | ) |
121 | 223 | end |
|
0 commit comments