Skip to content

Commit 38a8bca

Browse files
committed
Display separate MMR and MMRV consent form links in session summaries
Updates AppSessionSummaryComponent to show two online consent form links for MMR sessions (one for MMR variant, one for MMRV variant) instead of a single combined link.
1 parent 6f4baa0 commit 38a8bca

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

app/components/app_session_summary_component.rb

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,23 @@ def online_consent_links
160160

161161
ProgrammeGrouper
162162
.call(session.programmes)
163-
.map do |_group, programmes|
164-
names =
165-
programmes.map do |programme|
166-
# TODO: This enables us to show "MMR" for the "MMR(V)" programme
167-
# but will probably need fixing once we collect consent for MMRV.
168-
I18n.t(programme.type, scope: :programme_types)
163+
.flat_map do |_group, programmes|
164+
variants =
165+
if programmes.first.mmr?
166+
programmes.first.variants.map { [it.name, it.to_param] }
167+
else
168+
names = programmes.map(&:name).to_sentence
169+
param = programmes.map(&:to_param).join("-")
170+
[[names, param]]
169171
end
170172

171-
label = "View the #{names.to_sentence} online consent form"
172-
173-
helpers.govuk_link_to(
174-
label,
175-
start_parent_interface_consent_forms_path(
176-
session,
177-
programmes.map(&:to_param).join("-")
178-
),
179-
new_tab: true
180-
)
173+
variants.map do |name, param|
174+
helpers.govuk_link_to(
175+
"View the #{name} online consent form",
176+
start_parent_interface_consent_forms_path(session, param),
177+
new_tab: true
178+
)
179+
end
181180
end
182181
end
183182

spec/components/app_session_summary_component_spec.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,28 @@
5858
context "for MMR(V) programme" do
5959
let(:programmes) { [Programme.mmr] }
6060

61-
it { should have_link("View the MMR online consent form") }
61+
it "shows separate links for MMR and MMRV variants" do
62+
expect(rendered).to have_link(
63+
"View the MMR online consent form (opens in new tab)"
64+
)
65+
expect(rendered).to have_link(
66+
"View the MMRV online consent form (opens in new tab)"
67+
)
68+
end
69+
70+
it "links to the correct MMR variant consent form" do
71+
expect(rendered).to have_link(
72+
"View the MMR online consent form (opens in new tab)",
73+
href: %r{/consents/#{session.slug}/mmr/start$}
74+
)
75+
end
76+
77+
it "links to the correct MMRV variant consent form" do
78+
expect(rendered).to have_link(
79+
"View the MMRV online consent form (opens in new tab)",
80+
href: %r{/consents/#{session.slug}/mmrv/start$}
81+
)
82+
end
6283
end
6384
end
6485
end

0 commit comments

Comments
 (0)