-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathapp_patient_programme_session_table_component_spec.rb
More file actions
105 lines (90 loc) · 2.74 KB
/
app_patient_programme_session_table_component_spec.rb
File metadata and controls
105 lines (90 loc) · 2.74 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
describe AppPatientProgrammeSessionTableComponent do
subject { render_inline(component) }
let(:component) do
described_class.new(patient, current_team: team, programme_type:)
end
let(:programme_type) { :hpv }
let(:team) { create(:team) }
context "without a session" do
let(:patient) { create(:patient) }
it { should have_content("No sessions") }
end
context "with one session" do
let(:programmes) { [Programme.hpv, Programme.mmr] }
let(:location) do
create(:school, name: "Waterloo Road", programmes:, academic_year: 2024)
end
let(:session) do
create(
:session,
team:,
location:,
programmes:,
date: Date.new(2025, 1, 1)
)
end
# Can't use year_group here because we need an absolute date, not one
# relative to the current academic year.
let(:patient) { create(:patient, date_of_birth: Date.new(2011, 9, 1)) }
before { create_list(:patient_location, 1, patient:, session:) }
it { should have_link("Waterloo Road") }
it { should have_content("1 January 2025") }
context "with multiple sessions" do
let(:other_location) do
create(
:school,
name: "Paddington Road",
programmes: other_programmes,
academic_year: 2024
)
end
let(:other_session) do
create(
:session,
team:,
location: other_location,
programmes: other_programmes,
date: Date.new(2025, 2, 1)
)
end
let(:other_programmes) { [Programme.hpv, Programme.menacwy] }
before do
create(:patient_location, patient:, session: other_session)
create(
:vaccination_record,
patient:,
session:,
outcome: :administered,
performed_at_date: 1.month.ago,
programme_type:
)
create(
:vaccination_record,
patient:,
session:,
outcome: :refused,
performed_at_date: 1.year.ago,
programme_type:
)
end
it { should have_link("Waterloo Road") }
it { should have_content("1 January 2025") }
it { should have_content("Vaccinated") }
it { should have_link("Paddington Road") }
it { should have_content("1 February 2025") }
it { should have_content("No outcome") }
context "with a programme type filter that matches only one session" do
let(:component) do
described_class.new(
patient,
current_team: team,
programme_type: :menacwy
)
end
it { should_not have_link("Waterloo Road") }
it { should have_link("Paddington Road") }
end
end
end
end