|
3 | 3 | describe "Triage" do
|
4 | 4 | scenario "nurse can triage a patient" do
|
5 | 5 | given_a_programme_with_a_running_session
|
| 6 | + and_a_patient_who_needs_triage_exists |
| 7 | + and_a_patient_who_doesnt_need_triage_exists |
| 8 | + |
| 9 | + when_i_go_to_the_session_triage_tab |
| 10 | + then_i_see_the_patient_who_needs_triage |
| 11 | + and_i_dont_see_the_patient_who_doesnt_need_triage |
| 12 | + |
6 | 13 | when_i_go_to_the_patient_that_needs_triage
|
7 | 14 | then_i_see_the_triage_options
|
8 | 15 |
|
@@ -36,40 +43,60 @@ def given_a_programme_with_a_running_session
|
36 | 43 | organisation: @organisation,
|
37 | 44 | vaccine: programmes.first.vaccines.first
|
38 | 45 | )
|
39 |
| - location = create(:school) |
40 |
| - @session = |
41 |
| - create(:session, organisation: @organisation, programmes:, location:) |
42 |
| - @patient = |
| 46 | + |
| 47 | + @session = create(:session, organisation: @organisation, programmes:) |
| 48 | + end |
| 49 | + |
| 50 | + def and_a_patient_who_needs_triage_exists |
| 51 | + @patient_triage_needed = |
43 | 52 | create(
|
44 | 53 | :patient_session,
|
45 | 54 | :consent_given_triage_needed,
|
46 |
| - programmes:, |
47 | 55 | session: @session
|
48 | 56 | ).patient
|
| 57 | + |
49 | 58 | create(
|
50 | 59 | :consent,
|
51 | 60 | :given,
|
52 | 61 | :health_question_notes,
|
53 | 62 | :from_granddad,
|
54 |
| - patient: @patient, |
55 |
| - programme: programmes.first |
| 63 | + patient: @patient_triage_needed, |
| 64 | + programme: @session.programmes.first |
56 | 65 | )
|
57 | 66 |
|
58 |
| - @patient.reload # Make sure both consents are accessible |
| 67 | + @patient_triage_needed.reload # Make sure both consents are accessible |
59 | 68 | end
|
60 | 69 |
|
61 |
| - def when_i_go_to_the_patient_that_needs_triage |
62 |
| - sign_in @organisation.users.first |
| 70 | + def and_a_patient_who_doesnt_need_triage_exists |
| 71 | + @patient_triage_not_needed = |
| 72 | + create( |
| 73 | + :patient_session, |
| 74 | + :consent_given_triage_not_needed, |
| 75 | + session: @session |
| 76 | + ).patient |
| 77 | + end |
63 | 78 |
|
| 79 | + def when_i_go_to_the_session_triage_tab |
| 80 | + sign_in @organisation.users.first |
64 | 81 | visit session_triage_path(@session)
|
| 82 | + end |
| 83 | + |
| 84 | + def then_i_see_the_patient_who_needs_triage |
| 85 | + expect(page).to have_content(@patient_triage_needed.full_name) |
| 86 | + end |
| 87 | + |
| 88 | + def and_i_dont_see_the_patient_who_doesnt_need_triage |
| 89 | + expect(page).not_to have_content(@patient_triage_not_needed.full_name) |
| 90 | + end |
| 91 | + |
| 92 | + def when_i_go_to_the_patient_that_needs_triage |
65 | 93 | choose "Needs triage"
|
66 | 94 | click_on "Update results"
|
67 |
| - |
68 |
| - click_link @patient.full_name |
| 95 | + click_link @patient_triage_needed.full_name |
69 | 96 | end
|
70 | 97 |
|
71 | 98 | def when_i_go_to_the_patient
|
72 |
| - click_link @patient.full_name, match: :first |
| 99 | + click_link @patient_triage_needed.full_name, match: :first |
73 | 100 | end
|
74 | 101 |
|
75 | 102 | def when_i_record_that_they_need_triage
|
@@ -109,19 +136,19 @@ def then_i_see_the_update_triage_link
|
109 | 136 | end
|
110 | 137 |
|
111 | 138 | def and_needs_triage_emails_are_sent_to_both_parents
|
112 |
| - @patient.parents.each do |parent| |
| 139 | + @patient_triage_needed.parents.each do |parent| |
113 | 140 | expect_email_to parent.email, :consent_confirmation_triage, :any
|
114 | 141 | end
|
115 | 142 | end
|
116 | 143 |
|
117 | 144 | def and_vaccination_wont_happen_emails_are_sent_to_both_parents
|
118 |
| - @patient.parents.each do |parent| |
| 145 | + @patient_triage_needed.parents.each do |parent| |
119 | 146 | expect_email_to parent.email, :triage_vaccination_wont_happen, :any
|
120 | 147 | end
|
121 | 148 | end
|
122 | 149 |
|
123 | 150 | def and_vaccination_will_happen_emails_are_sent_to_both_parents
|
124 |
| - @patient.parents.each do |parent| |
| 151 | + @patient_triage_needed.parents.each do |parent| |
125 | 152 | expect_email_to parent.email, :triage_vaccination_will_happen, :any
|
126 | 153 | end
|
127 | 154 | end
|
|
0 commit comments