Skip to content

Commit

Permalink
Merge pull request #3284 from alphagov/hmrc_manual_breadcrumbs
Browse files Browse the repository at this point in the history
Minor bug fixes to HMRC manual layout and breadcrumbs
  • Loading branch information
hannako authored Jul 31, 2024
2 parents e8044d1 + 70f902a commit d1c94d4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
43 changes: 22 additions & 21 deletions app/views/content_items/manuals/_manual_layout.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<% content_for :main do %>
<%= render "govuk_publishing_components/components/heading", {
text: t("manuals.summary_title"),
margin_bottom: 4
} %>
<div id="manuals-frontend" class="manuals-frontend-body">

<%= machine_readable_metadata(schema: :article) %>
<%= machine_readable_metadata(schema: :article) %>

<div class="manual-body">
<% if @content_item.description.present? %>
<%= render "govuk_publishing_components/components/lead_paragraph", {
text: @content_item.description
} %>
<% end %>
<% if @content_item.body.present? %>
<%= render "govuk_publishing_components/components/govspeak", {} do %>
<%= raw(@content_item.body) %>
<div class="manual-body">
<% if @content_item.description.present? %>
<%= render "govuk_publishing_components/components/heading", {
text: t("manuals.summary_title"),
margin_bottom: 4
} %>
<%= render "govuk_publishing_components/components/lead_paragraph", {
text: @content_item.description
} %>
<% end %>
<% if @content_item.body.present? %>
<%= render "govuk_publishing_components/components/govspeak", {} do %>
<%= raw(@content_item.body) %>
<% end %>
<% end %>
<% end %>

<%= render "govuk_publishing_components/components/heading", {
text: t("manuals.contents_title"),
margin_bottom: 4
} %>
<%= render "govuk_publishing_components/components/heading", {
text: t("manuals.contents_title"),
margin_bottom: 4
} %>

<%= yield %>
<%= yield %>

<%= render 'govuk_publishing_components/components/print_link' %>
<%= render 'govuk_publishing_components/components/print_link' %>
</div>
</div>
<% end %>
15 changes: 11 additions & 4 deletions app/views/content_items/manuals/_manual_section_layout.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<% show_contents ||= false %>

<% content_for :main do %>
<%= render "govuk_publishing_components/components/back_link", {
text: t("manuals.breadcrumb_contents"),
href: @content_item.base_path
} %>
<% if @content_item.breadcrumbs.any? %>
<%= render "govuk_publishing_components/components/breadcrumbs", {
border: "bottom",
breadcrumbs: @content_item.breadcrumbs,
collapse_on_mobile: false } %>
<% else %>
<%= render "govuk_publishing_components/components/back_link", {
text: t("manuals.breadcrumb_contents"),
href: @content_item.base_path
} %>
<% end %>
<div id="manuals-frontend" class="manuals-frontend-body">
<% if show_contents %>
<%= render "govuk_publishing_components/components/contents_list", {
Expand Down
24 changes: 23 additions & 1 deletion test/integration/hmrc_manual_section_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ class HmrcManualSectionTest < ActionDispatch::IntegrationTest
end
end

test "renders back link" do
test "renders back link if breadcrumbs are not set" do
setup_and_visit_manual_section

assert page.has_link?(I18n.t("manuals.breadcrumb_contents"), href: "/hmrc-internal-manuals/vat-government-and-public-bodies")
end

test "renders breadcrumbs if they are set in the content item" do
setup_and_visit_manual_section_with_breadcrumbs

assert page.has_link?("DMBM510000", href: "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000")
end

test "renders section group" do
setup_and_visit_manual_section

Expand Down Expand Up @@ -92,4 +98,20 @@ def setup_and_visit_manual_section(content_item = get_content_example("vatgpb200
stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)
visit_with_cachebust((@content_item["base_path"]).to_s)
end

def setup_and_visit_manual_section_with_breadcrumbs(content_item = get_content_example("vatgpb2000"))
@manual = get_content_example_by_schema_and_name("hmrc_manual", "vat-government-public-bodies")
@content_item = content_item
first_crumb = { "base_path" => "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000", "section_id" => "DMBM510000" }
last_crumb = { "base_path" => "/hmrc-internal-manuals/vat-government-public-bodiesg/dmbm510100", "section_id" => "DMBM510100" }

@content_item["details"]["breadcrumbs"].push(first_crumb, last_crumb)
manual_base_path = @content_item["details"]["manual"]["base_path"]

stub_content_store_has_item(manual_base_path, @manual.to_json)

stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)
stub_content_store_has_item(@content_item["details"]["breadcrumbs"].last["base_path"], @content_item.to_json)
visit_with_cachebust((@content_item["base_path"]).to_s)
end
end
2 changes: 1 addition & 1 deletion test/integration/hmrc_manual_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HmrcManualTest < ActionDispatch::IntegrationTest
end
end

test "renders about title" do
test "renders 'Summary' title if description field is present" do
setup_and_visit_content_item("vat-government-public-bodies")

assert page.has_text?(I18n.t("manuals.summary_title"))
Expand Down

0 comments on commit d1c94d4

Please sign in to comment.