From cffe4944cf664fff86ca344a730a7a986fcd5d2c Mon Sep 17 00:00:00 2001 From: Jonathon Date: Mon, 18 Mar 2024 10:02:40 +0000 Subject: [PATCH] Update related_navigation_spec to account for topics being removed --- spec/components/related_navigation_spec.rb | 49 +++++++++------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/spec/components/related_navigation_spec.rb b/spec/components/related_navigation_spec.rb index 7e34ce3bfd..7f497275c5 100644 --- a/spec/components/related_navigation_spec.rb +++ b/spec/components/related_navigation_spec.rb @@ -44,17 +44,6 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) assert_select ".gem-c-related-navigation__section-link[href=\"/something-a-bit-like-this\"]", text: "Some other guidance" end - it "renders topics section when passed topic items" do - content_item = {} - content_item["links"] = construct_links( - "topics", "/finding-a-job", "Finding a job", "topic" - ) - render_component(content_item:) - - assert_select ".gem-c-related-navigation__sub-heading", text: "Explore the topic" - assert_select ".gem-c-related-navigation__section-link[href=\"/finding-a-job\"]", text: "Finding a job" - end - it "renders statistical data set section when passed statistical data set items" do content_item = {} content_item["links"] = construct_links( @@ -148,10 +137,10 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) it "adds aria labelledby to navigation sections" do content_item = {} content_item["links"] = construct_links( - "topics", + "document_collections", "/apprenticeships", "Apprenticeships", - "topic", + "document_collection", ) render_component(content_item:) @@ -198,13 +187,13 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) it "link tracking is enabled" do content_item = {} content_item["links"] = construct_links( - "topics", "/apprenticeships", "Apprenticeships", "topic" + "document_collections", "/apprenticeships", "Apprenticeships", "document_collection" ) render_component(content_item:) assert_select ".gem-c-related-navigation[data-module='gem-track-click ga4-link-tracker']" assert_select ".gem-c-related-navigation__section-link[data-track-category='relatedLinkClicked']" - assert_select ".gem-c-related-navigation__section-link[data-track-action='1.1 Explore the topic']" + assert_select ".gem-c-related-navigation__section-link[data-track-action='1.1 Collection']" assert_select ".gem-c-related-navigation__section-link[data-track-label='/apprenticeships']" end @@ -221,21 +210,21 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) "title" => "Surfing", }, ], - "topics" => [ + "document_collections" => [ { "base_path" => "/skating", "title" => "Skating", - "document_type" => "topic", + "document_type" => "document_collection", }, { "base_path" => "/paragliding", "title" => "Paragliding", - "document_type" => "topic", + "document_type" => "document_collection", }, { "base_path" => "/knitting", "title" => "Knitting", - "document_type" => "topic", + "document_type" => "document_collection", }, ], "world_locations" => [], @@ -243,15 +232,15 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) %w[USA Wales Fiji Iceland Sweden Mauritius Brazil].each do |country| content_item["links"]["world_locations"] << { "title" => country } end - - render_component(content_item:) + + value = render_component(content_item:) assert_select ".gem-c-related-navigation[data-module='gem-track-click ga4-link-tracker']" assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"1\",\"index_link\":\"1\",\"index_section_count\":\"3\",\"index_total\":\"2\",\"section\":\"Related content\"}']", text: "Fishing" assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"1\",\"index_link\":\"2\",\"index_section_count\":\"3\",\"index_total\":\"2\",\"section\":\"Related content\"}']", text: "Surfing" - assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"2\",\"index_link\":\"1\",\"index_section_count\":\"3\",\"index_total\":\"3\",\"section\":\"Explore the topic\"}']", text: "Skating" - assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"2\",\"index_link\":\"2\",\"index_section_count\":\"3\",\"index_total\":\"3\",\"section\":\"Explore the topic\"}']", text: "Paragliding" + assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"2\",\"index_link\":\"1\",\"index_section_count\":\"3\",\"index_total\":\"3\",\"section\":\"Collection\"}']", text: "Skating" + assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"related content\",\"index_section\":\"2\",\"index_link\":\"2\",\"index_section_count\":\"3\",\"index_total\":\"3\",\"section\":\"Collection\"}']", text: "Paragliding" assert_select ".gem-c-related-navigation__section-link[href=\"/world/wales/news\"]", text: "Wales" assert_select ".gem-c-related-navigation__link.toggle-wrap[data-module='ga4-event-tracker']" @@ -271,21 +260,21 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) "title" => "Surfing", }, ], - "topics" => [ + "document_collections" => [ { "base_path" => "/skating", "title" => "Skating", - "document_type" => "topic", + "document_type" => "document_collection", }, { "base_path" => "/paragliding", "title" => "Paragliding", - "document_type" => "topic", + "document_type" => "document_collection", }, { "base_path" => "/knitting", "title" => "Knitting", - "document_type" => "topic", + "document_type" => "document_collection", }, ], "world_locations" => [], @@ -306,7 +295,7 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) it "uses lang when locale is set" do content_item = {} content_item["links"] = construct_links( - "topics", "/apprenticeships", "Apprenticeships", "topic", "ko" + "document_collections", "/apprenticeships", "Apprenticeships", "document_collection", "ko" ) render_component(content_item:) @@ -316,7 +305,7 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) it "lang is not used when the same as the app's locale" do content_item = {} content_item["links"] = construct_links( - "topics", "/apprenticeships", "Apprenticeships", "topic", I18n.locale + "document_collections", "/apprenticeships", "Apprenticeships", "document_collection", I18n.locale ) render_component(content_item:) @@ -326,7 +315,7 @@ def construct_links(type, base_path, title, document_type = nil, locale = nil) it "lang is not used when no locale is set" do content_item = {} content_item["links"] = construct_links( - "topics", "/apprenticeships", "Apprenticeships", "topic" + "document_collections", "/apprenticeships", "Apprenticeships", "document_collection" ) render_component(content_item:)