Skip to content

Commit ebad560

Browse files
Merge pull request #5765 from nhsuk/mike/breadcrumb-for-national-reporting-vaccs-record
Never show session-based breadcrumb in national reporting vaccination records
2 parents 11751d8 + 2a0f425 commit ebad560

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

app/controllers/vaccination_records_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def set_breadcrumb_items
6767
{ text: t("dashboard.index.title"), href: dashboard_path }
6868
]
6969

70-
if @session
70+
if @session && policy(@session).show?
7171
@breadcrumb_items << {
7272
text: t("sessions.index.title"),
7373
href: sessions_path

spec/features/edit_vaccination_record_spec.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@
263263
then_i_should_see_the_vaccination_record
264264
and_i_should_see_parent_details
265265
end
266+
267+
scenario "Breadcrumb shows session-specific path for POC team" do
268+
given_i_am_signed_in
269+
and_an_administered_vaccination_record_exists
270+
271+
when_i_visit_the_vaccination_record_directly
272+
then_i_should_see_the_vaccination_record
273+
and_i_should_see_the_session_specific_breadcrumb
274+
end
266275
end
267276

268277
context "in bulk upload Mavis" do
@@ -296,6 +305,16 @@
296305
then_i_should_see_the_vaccination_record
297306
and_i_should_not_see_parent_details
298307
end
308+
309+
scenario "Breadcrumb shows patient-based path when viewing session-based vaccination record" do
310+
given_i_am_signed_in
311+
and_a_vaccination_record_with_a_session_exists
312+
and_the_patient_is_accessible_to_the_upload_only_team
313+
314+
when_i_visit_the_vaccination_record_directly
315+
then_i_should_see_the_vaccination_record
316+
and_i_should_see_the_patient_based_breadcrumb
317+
end
299318
end
300319

301320
def given_an_hpv_programme_is_underway
@@ -709,4 +728,43 @@ def and_i_should_not_see_parent_details
709728
expect(page).not_to have_content("First parent or guardian")
710729
expect(page).not_to have_content("Second parent or guardian")
711730
end
731+
732+
def when_i_visit_the_vaccination_record_directly
733+
visit vaccination_record_path(@vaccination_record)
734+
end
735+
736+
def and_i_should_see_the_session_specific_breadcrumb
737+
breadcrumb = page.find(".nhsuk-breadcrumb")
738+
expect(breadcrumb).to have_content("Sessions")
739+
expect(breadcrumb).to have_content(@session.location.name)
740+
end
741+
742+
def and_a_vaccination_record_with_a_session_exists
743+
location = create(:school, urn: 100_001)
744+
745+
@session = create(:session, :completed, programmes: [@programme], location:)
746+
747+
@vaccination_record =
748+
create(
749+
:vaccination_record,
750+
batch: @batch,
751+
patient: @patient,
752+
session: @session,
753+
programme: @programme
754+
)
755+
end
756+
757+
def and_the_patient_is_accessible_to_the_upload_only_team
758+
# Patient is already part of the upload-only team from the before block
759+
# Just ensure patient_team association exists
760+
PatientTeam.find_or_create_by!(patient: @patient, team: @team)
761+
end
762+
763+
def and_i_should_see_the_patient_based_breadcrumb
764+
# Patient-based breadcrumb should include: Home → Children → Patient name
765+
# Should NOT include session-specific links (Sessions, Location name)
766+
breadcrumb = page.find(".nhsuk-breadcrumb")
767+
expect(breadcrumb).to have_content("Children")
768+
expect(breadcrumb).not_to have_content("Sessions")
769+
end
712770
end

0 commit comments

Comments
 (0)