From 851afc8df1cd425ddb0c4f58a0b1dc60c8ee3eba Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Wed, 17 Jan 2018 17:17:52 +0000 Subject: [PATCH] Allow related navigation to display related guidance --- .../components/_related-navigation.html.erb | 4 +++- config/locales/en.yml | 1 + test/components/related_navigation_test.rb | 14 ++++++++++++++ test/presenters/detailed_guide_presenter_test.rb | 16 +++++++++++----- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/views/components/_related-navigation.html.erb b/app/views/components/_related-navigation.html.erb index 43319e7e85..ac2e570d56 100644 --- a/app/views/components/_related-navigation.html.erb +++ b/app/views/components/_related-navigation.html.erb @@ -1,8 +1,10 @@ <% max_section_length = 5 - defined_sections = %w(topics publishers collections policies topical_events world_locations statistical_data_sets) + defined_sections = %w(related_guides topics publishers collections policies + topical_events world_locations statistical_data_sets) related_content = [ {"related_items" => related_items ||= [] }, + {"related_guides" => related_guides ||= [] }, {"topics" => topics ||= [] }, {"publishers" => publishers ||= [] }, {"collections" => collections ||= [] }, diff --git a/config/locales/en.yml b/config/locales/en.yml index 1f2ae15165..5f7d4d7af7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -33,6 +33,7 @@ en: policies: "Policy" publishers: "Published by" related_content: "Related content" + related_guides: "Detailed guidance" statistical_data_sets: "Statistical data set" topics: "Explore the topic" topical_events: "Topical event" diff --git a/test/components/related_navigation_test.rb b/test/components/related_navigation_test.rb index 23550206b4..e70dfd2f22 100644 --- a/test/components/related_navigation_test.rb +++ b/test/components/related_navigation_test.rb @@ -23,6 +23,20 @@ def component_name assert_select ".app-c-related-navigation__section-link--other[href=\"/apprenticeships\"]", text: 'Apprenticeships' end + test "renders related guides section when passed related guides" do + render_component( + related_guides: [ + { + text: "Some other guidance", + path: '/something-a-bit-like-this' + } + ] + ) + + assert_select ".app-c-related-navigation__sub-heading", text: 'Detailed guidance' + assert_select ".app-c-related-navigation__section-link[href=\"/something-a-bit-like-this\"]", text: 'Some other guidance' + end + test "renders topics section when passed topic items" do render_component( topics: [ diff --git a/test/presenters/detailed_guide_presenter_test.rb b/test/presenters/detailed_guide_presenter_test.rb index c81a2f976e..82c36c286a 100644 --- a/test/presenters/detailed_guide_presenter_test.rb +++ b/test/presenters/detailed_guide_presenter_test.rb @@ -49,14 +49,20 @@ def schema_name end test 'presents related detailed guides' do - assert_equal ['Offshore wind: part of the UK's energy mix'], presented_item("political_detailed_guide").related_guides + related_guides = [{ + text: 'Offshore wind: part of the UK\'s energy mix', + path: '/guidance/offshore-wind-part-of-the-uks-energy-mix', + }] + assert_equal(related_guides, presented_item("political_detailed_guide").related_navigation[:related_guides]) end test 'presents related mainstream content' do - assert_equal [ - 'Overseas British passport applications', - 'Cancel a lost or stolen passport' - ], presented_item("related_mainstream_detailed_guide").related_mainstream_content + related_mainstream_content = [ + { text: 'Overseas British passport applications', path: '/overseas-passports' }, + { text: 'Cancel a lost or stolen passport', path: '/report-a-lost-or-stolen-passport' } + ] + assert_equal related_mainstream_content, + presented_item("related_mainstream_detailed_guide").related_navigation[:related_items] end test 'content can be historically political' do