@@ -42,12 +42,18 @@ class HmrcManualSectionTest < ActionDispatch::IntegrationTest
42
42
end
43
43
end
44
44
45
- test "renders back link" do
45
+ test "renders back link if breadcrumbs are not set " do
46
46
setup_and_visit_manual_section
47
47
48
48
assert page . has_link? ( I18n . t ( "manuals.breadcrumb_contents" ) , href : "/hmrc-internal-manuals/vat-government-and-public-bodies" )
49
49
end
50
50
51
+ test "renders breadcrumbs if they are set in the content item" do
52
+ setup_and_visit_manual_section_with_breadcrumbs
53
+
54
+ assert page . has_link? ( "DMBM510000" , href : "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000" )
55
+ end
56
+
51
57
test "renders section group" do
52
58
setup_and_visit_manual_section
53
59
@@ -92,4 +98,20 @@ def setup_and_visit_manual_section(content_item = get_content_example("vatgpb200
92
98
stub_content_store_has_item ( @content_item [ "base_path" ] , @content_item . to_json )
93
99
visit_with_cachebust ( ( @content_item [ "base_path" ] ) . to_s )
94
100
end
101
+
102
+ def setup_and_visit_manual_section_with_breadcrumbs ( content_item = get_content_example ( "vatgpb2000" ) )
103
+ @manual = get_content_example_by_schema_and_name ( "hmrc_manual" , "vat-government-public-bodies" )
104
+ @content_item = content_item
105
+ first_crumb = { "base_path" => "/hmrc-internal-manuals/debt-management-and-banking/dmbm510000" , "section_id" => "DMBM510000" }
106
+ last_crumb = { "base_path" => "/hmrc-internal-manuals/vat-government-public-bodiesg/dmbm510100" , "section_id" => "DMBM510100" }
107
+
108
+ @content_item [ "details" ] [ "breadcrumbs" ] . push ( first_crumb , last_crumb )
109
+ manual_base_path = @content_item [ "details" ] [ "manual" ] [ "base_path" ]
110
+
111
+ stub_content_store_has_item ( manual_base_path , @manual . to_json )
112
+
113
+ stub_content_store_has_item ( @content_item [ "base_path" ] , @content_item . to_json )
114
+ stub_content_store_has_item ( @content_item [ "details" ] [ "breadcrumbs" ] . last [ "base_path" ] , @content_item . to_json )
115
+ visit_with_cachebust ( ( @content_item [ "base_path" ] ) . to_s )
116
+ end
95
117
end
0 commit comments