-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathapp_patient_session_consent_component_spec.rb
More file actions
77 lines (59 loc) · 2.5 KB
/
app_patient_session_consent_component_spec.rb
File metadata and controls
77 lines (59 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# frozen_string_literal: true
describe AppPatientSessionConsentComponent do
subject(:rendered) { render_inline(component) }
let(:component) { described_class.new(patient:, session:, programme:) }
let(:programme) { Programme.hpv }
let(:session) { create(:session, programmes: [programme]) }
let(:patient) { create(:patient, session:, parents: [create(:parent)]) }
before { stub_authorization(allowed: true) }
context "without consent" do
it { should_not have_content(/Consent (given|refused)/) }
it { should_not have_css("details", text: /Consent (given|refused) by/) }
it { should_not have_css("details", text: "Responses to health questions") }
it { should have_css("p", text: "No consent request is scheduled") }
it { should have_link("Record a new consent response") }
end
context "when vaccinated" do
before do
create(:patient_programme_status, :vaccinated_fully, patient:, programme:)
end
it { should_not have_css("p", text: "No requests have been sent.") }
it { should_not have_link("Record a new consent response") }
end
context "with refused consent" do
let(:parent) { create(:parent_relationship, :mother, patient:).parent }
let!(:consent) do
create(:consent, :refused, patient: patient.reload, parent:, programme:)
end
it { should have_content("refused to give consent") }
it { should have_content(consent.parent.full_name) }
it { should have_content(consent.parent_relationship.label) }
it { should have_content("Consent refused") }
it { should_not have_css("details", text: "Responses to health questions") }
end
context "with given consent" do
let(:patient) do
create(:patient, :consent_given_triage_not_needed, session:)
end
let(:consent) { patient.consents.first }
it { should have_text("is ready for the vaccinator") }
it { should_not have_css("a", text: "Contact #{consent.parent.full_name}") }
context "and the programme is flu" do
let(:programme) { Programme.flu }
let(:patient) do
create(:patient, :consent_given_nasal_only_triage_not_needed, session:)
end
it { should have_text("Nasal spray only") }
context "and the vaccine method is overridden by triage" do
let(:patient) do
create(
:patient,
:consent_given_injection_and_nasal_triage_safe_to_vaccinate_injection,
session:
)
end
it { should have_text("is ready for the vaccinator") }
end
end
end
end