From 06cd9e99b74e3263a94a464903e17c5c45605094 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 22 Mar 2024 09:21:25 +0000 Subject: [PATCH 1/3] Update test method A page can be tagged to mainstream browse with or without a browse parent. The breadcrumb is different in these two cases. --- spec/features/contextual_navigation_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/contextual_navigation_spec.rb b/spec/features/contextual_navigation_spec.rb index f23ccf9744..035bb5246a 100644 --- a/spec/features/contextual_navigation_spec.rb +++ b/spec/features/contextual_navigation_spec.rb @@ -22,8 +22,8 @@ and_i_see_the_other_step_by_step_as_an_also_part_of_list end - scenario "There's a mainstream browse page tagged" do - given_theres_a_browse_page + scenario "The page is tagged to browse and has a browse parent" do + given_theres_a_page_tagged_to_browse_with_a_browse_parent and_i_visit_that_page then_i_see_the_browse_page_in_the_footer and_the_default_breadcrumbs @@ -254,7 +254,7 @@ def given_there_are_three_related_to_step_nav_and_one_secondary_to_step_nav }) end - def given_theres_a_browse_page + def given_theres_a_page_tagged_to_browse_with_a_browse_parent content_store_has_random_item( links: { "parent" => [top_level_mainstream_browse_page], From 6505e444ed71b395803914d9402fafac2b97f44e Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 22 Mar 2024 09:30:04 +0000 Subject: [PATCH 2/3] Add test to cover example of a page without browse parent --- spec/features/contextual_navigation_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/features/contextual_navigation_spec.rb b/spec/features/contextual_navigation_spec.rb index 035bb5246a..89e787ef54 100644 --- a/spec/features/contextual_navigation_spec.rb +++ b/spec/features/contextual_navigation_spec.rb @@ -29,6 +29,13 @@ and_the_default_breadcrumbs end + scenario "The page is tagged to browse and does not have a browse parent" do + given_theres_a_page_tagged_to_browse_without_a_browse_parent + and_i_visit_that_page + then_i_see_the_browse_page_in_the_footer + then_i_see_the_topic_breadcrumb + end + scenario "Foreign travel advice content" do given_theres_a_travel_advice_page and_i_visit_that_page @@ -263,6 +270,15 @@ def given_theres_a_page_tagged_to_browse_with_a_browse_parent ) end + def given_theres_a_page_tagged_to_browse_without_a_browse_parent + content_store_has_random_item( + links: { + "topics" => [topic_item], + "mainstream_browse_pages" => [example_item("mainstream_browse_page", "root_page")], + }, + ) + end + def given_theres_a_travel_advice_page content_store_has_random_item( schema: "travel_advice", From 38b6ef1b19bb84660ecba03b3f1860fa0c0a7f03 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 22 Mar 2024 09:34:29 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d6beaf67..4e2b40c9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ useful summary for people upgrading their application, not a replication of the commit log. +## Unreleased + +* Improve test coverage of contextual breadcrumb logic ([PR #3944](https://github.com/alphagov/govuk_publishing_components/pull/3944)) + ## 37.9.1 * Track 'Start now' buttons with a specific GA4 type ([PR #3935](https://github.com/alphagov/govuk_publishing_components/pull/3935))