Skip to content

Commit

Permalink
Update tests for world location and world wide taxons
Browse files Browse the repository at this point in the history
Updated the tests to check that the "title", "link" and "description" for each search result/tagged content is included on the page
  • Loading branch information
MartinJJones committed Dec 4, 2024
1 parent 9832a2a commit fe70206
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
18 changes: 18 additions & 0 deletions spec/features/world_location_taxon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions spec/features/world_wide_taxon_browsing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit fe70206

Please sign in to comment.