From da64b05c940b6d82a13c63fc00968da12e320e95 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 4 Dec 2024 15:46:16 +0000 Subject: [PATCH] Update tests for world location and world wide taxons Updated the tests to check that the "title", "link" and "description" for each search result/tagged content is included on the page --- spec/features/world_location_taxon_spec.rb | 18 ++++++++++++++++++ .../features/world_wide_taxon_browsing_spec.rb | 15 ++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/spec/features/world_location_taxon_spec.rb b/spec/features/world_location_taxon_spec.rb index d55ce1628..882018f1d 100644 --- a/spec/features/world_location_taxon_spec.rb +++ b/spec/features/world_location_taxon_spec.rb @@ -25,6 +25,24 @@ expect(page).to have_selector("a[href='#{email_url}']", text: "Get emails for this topic") end + scenario "contains a link and description for each search result" do + world_usa = world_usa_taxon(base_path:, phase: "live") + world_usa_news_events = world_usa_news_events_taxon(base_path: child_taxon_base_path) + + stub_content_store_has_item(base_path, world_usa) + stub_content_store_has_item(child_taxon_base_path, world_usa_news_events) + stub_content_for_taxon(taxon.content_id, search_results) # For the "general information" taxon + stub_most_popular_content_for_taxon(taxon.content_id, search_results, filter_content_store_document_type: nil) + stub_content_for_taxon(child_taxon.content_id, search_results) + + visit base_path + + search_results.each do |content| + expect(page).to have_link(content["title"], href: content["link"], class: "govuk-link") + expect(page.has_css?(".gem-c-document-list__item-description", text: content["description"])).to be(true) + end + end + private def search_results diff --git a/spec/features/world_wide_taxon_browsing_spec.rb b/spec/features/world_wide_taxon_browsing_spec.rb index 560fe4718..017898401 100644 --- a/spec/features/world_wide_taxon_browsing_spec.rb +++ b/spec/features/world_wide_taxon_browsing_spec.rb @@ -68,7 +68,8 @@ def then_i_see_the_taxon_page def and_i_can_see_the_content_tagged_to_the_taxon tagged_content.each do |content| - expect(page).to have_link(content["title"]) + expect(page).to have_link(content["title"], href: content["link"], class: "govuk-link") + expect(page.has_css?(".gem-c-document-list__item-description", text: content["description"])).to be(true) end end @@ -116,8 +117,16 @@ def content_id def tagged_content [ - { title: "Hey hello" }, - { title: "How are you" }, + { + "title" => "Hey hello", + "link" => "hey-hello", + "description" => "Description for hey hello", + }, + { + "title" => "How are you", + "link" => "how-are-you", + "description" => "Description for how are you", + }, ] end end