Skip to content

Commit

Permalink
Update tests for content lists under 3 headings
Browse files Browse the repository at this point in the history
Updated tests that checked for no content list with fewer than three headings to align with the new logic in the show_contents_list? method in contents_list.
  • Loading branch information
CodeSonia committed Oct 16, 2024
1 parent 4b6246e commit 533077a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 66 deletions.
13 changes: 0 additions & 13 deletions test/integration/corporate_information_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ class CorporateInformationPageTest < ActionDispatch::IntegrationTest
])
end

test "renders without contents list if it has fewer than 3 items" do
item = get_content_example("corporate_information_page")
item["details"]["body"] = "<div class='govspeak'>
<h2>Item one</h2><p>Content about item one</p>
<h2>Item two</h2><p>Content about item two</p>
</div>"

stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
end

test "renders corporate information with body when present" do
setup_and_visit_content_item("corporate_information_page")

Expand Down
5 changes: 0 additions & 5 deletions test/integration/detailed_guide_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
assert page.has_css?(".gem-c-contents-list")
end

test "renders without contents list if it has fewer than 3 items" do
setup_and_visit_content_item("national_applicability_alternative_url_detailed_guide")
assert_not page.has_css?(".gem-c-contents-list")
end

test "conditionally renders a logo" do
setup_and_visit_content_item("england-2014-to-2020-european-structural-and-investment-funds")

Expand Down
16 changes: 3 additions & 13 deletions test/integration/document_collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,9 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
end
end

test "renders without contents list if it has fewer than 3 items" do
item = get_content_example("document_collection")
item["details"]["collection_groups"] = [
{
"title" => "Item one",
"body" => "<p>Content about item one</p>",
"documents" => %w[a-content-id],
},
]
stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
test "renders a content list" do
setup_and_visit_content_item("document_collection")
assert page.has_css?(".gem-c-contents-list", text: "Contents")
end

test "renders each collection group" do
Expand Down
5 changes: 2 additions & 3 deletions test/integration/specialist_document_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ def assert_nested_content_item(heading)
assert page.has_content?("on the Big Issue Invest website")
end

test "does not render a contents list if there are fewer than three items in the contents list" do
test "renders a content list" do
setup_and_visit_content_item("aaib-reports")

assert_not page.has_css?("#contents .gem-c-contents-list")
assert page.has_css?(".gem-c-contents-list", text: "Contents")
end

test "renders a link to statutory instruments finder" do
Expand Down
13 changes: 0 additions & 13 deletions test/integration/statistical_data_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ class StatisticalDataSetTest < ActionDispatch::IntegrationTest
])
end

test "renders without contents list if it has fewer than 3 items" do
item = get_content_example("statistical_data_set")
item["details"]["body"] = "<div class='govspeak'>
<h2>Item one</h2><p>Content about item one</p>
<h2>Item two</h2><p>Content about item two</p>
</div>"

stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
end

test "does not render with the single page notification button" do
setup_and_visit_content_item("statistical_data_set")
assert_not page.has_css?(".gem-c-single-page-notification-button")
Expand Down
11 changes: 3 additions & 8 deletions test/integration/topical_event_about_page_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ class TopicalEventAboutPageTest < ActionDispatch::IntegrationTest
assert_not page.has_css?(".contents-list.contents-list-dashed")
end

test "contents list not displayed when fewer than three items" do
@content_item = get_content_example("topical_event_about_page")
@content_item["details"]["body"] = body_with_two_contents_list_items

stub_content_store_has_item(@content_item["base_path"], @content_item.to_json)

visit_with_cachebust @content_item["base_path"]
assert_not page.has_css?(".gem-c-contents-list")
test "renders a content list" do
setup_and_visit_content_item("topical_event_about_page")
assert page.has_css?(".gem-c-contents-list", text: "Contents")
end

test "contents list displayed when fewer than three items and first item word count is greater than 100" do
Expand Down
14 changes: 3 additions & 11 deletions test/integration/working_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,9 @@ class WorkingGroupTest < ActionDispatch::IntegrationTest
assert page.has_text?("Some content")
end

test "renders without contents list if it has fewer than 3 items" do
item = get_content_example("short")
item["details"]["body"] = "<div class='govspeak'>
<h2>Item one</h2><p>Content about item one</p>
<h2>Item two</h2><p>Content about item two</p>
</div>"

stub_content_store_has_item(item["base_path"], item.to_json)
visit_with_cachebust(item["base_path"])

assert_not page.has_css?(".gem-c-contents-list")
test "renders a content list" do
setup_and_visit_content_item("with_policies")
assert page.has_css?(".gem-c-contents-list", text: "Contents")
end

test "does not render with the single page notification button" do
Expand Down

0 comments on commit 533077a

Please sign in to comment.