diff --git a/test/integration/content_pages_navigation_test.rb b/test/integration/content_pages_navigation_test.rb index ddfda7361..cc9d83a2a 100644 --- a/test/integration/content_pages_navigation_test.rb +++ b/test/integration/content_pages_navigation_test.rb @@ -245,16 +245,153 @@ def setup end end - test "shows taxon breadcrumbs if variant b" do - stub_empty_rummager + test "ContentPagesNav variant B when a page belongs to a single topic shows full breadcrumb" do + stub_rummager setup_variant_b - taxons = THREE_TAXONS - setup_and_visit_content_item_with_taxons('guide', taxons) + setup_and_visit_content_item_with_taxons('guide', SINGLE_TAXON) within('.gem-c-contextual-breadcrumbs') do - assert page.has_css?('a', text: "Home") - assert page.has_css?('a', text: "Becoming a wizard") + assert page.has_css?('a', text: 'Home') + assert page.has_css?('a', text: 'Becoming an apprentice') + end + + refute page.has_css?('.taxonomy-navigation__banner') + end + + test "ContentPagesNav variant B shows home breadcrumb when a page belongs to a two topics" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide', TWO_TAXONS) + + within('.gem-c-contextual-breadcrumbs') do + assert page.has_css?('a', text: 'Home') + refute page.has_css?('a', text: 'Becoming an apprentice') + refute page.has_css?('a', text: 'Becoming a wizard') + end + end + + test "ContentPagesNav variant B shows banner when a page belongs to two topics" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide', TWO_TAXONS) + + within('.taxonomy-navigation__banner') do + assert page.has_content?('This page is part of Becoming an apprentice and Becoming a wizard') + assert page.has_css?('a', text: 'Becoming an apprentice') + assert page.has_css?('a', text: 'Becoming a wizard') + end + end + + test "ContentPagesNav variant B shows breadcrumb when a page belongs to more than two topics" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide', THREE_TAXONS) + + within('.gem-c-contextual-breadcrumbs') do + assert page.has_css?('a', text: 'Home') + refute page.has_css?('a', text: 'Becoming an apprentice') + refute page.has_css?('a', text: 'Becoming a wizard') + refute page.has_css?('a', text: 'Becoming the sorceror supreme') + end + end + + test "ContentPagesNav variant B shows banner when a page belongs to more than two topics" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide', THREE_TAXONS) + + within('.taxonomy-navigation__banner') do + assert page.has_content?('This page is part of Becoming an apprentice and 2 others + show all') + assert page.has_css?('a', text: 'Becoming an apprentice') + assert page.has_css?('a', text: 'Becoming a wizard') + assert page.has_css?('a', text: 'Becoming the sorceror supreme') + end + end + + test "ContentPagesNav variant B shows full breadcrumb when a page belongs to a single topic and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON) + + within('.gem-c-contextual-breadcrumbs') do + assert page.has_css?('a', text: 'Home') + assert page.has_css?('a', text: 'Becoming an apprentice') + end + end + + test "ContentPagesNav variant B shows banner when a page belongs to a single topic and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON) + + within('.taxonomy-navigation__banner') do + assert page.has_content?('This page is part of Learn to drive a car: step by step') + assert page.has_css?('a', text: 'Learn to drive a car: step by step') + end + end + + test "ContentPagesNav variant B shows home breadcrumb when a page belongs to a two topics and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS) + + within('.gem-c-contextual-breadcrumbs') do + assert page.has_css?('a', text: 'Home') + refute page.has_css?('a', text: 'Becoming an apprentice') + refute page.has_css?('a', text: 'Becoming a wizard') + end + end + + test "ContentPagesNav variant B shows banner when a page belongs to two topics and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS) + + within('.taxonomy-navigation__banner') do + assert page.has_content?('This page is part of Learn to drive a car: step by step and 2 others + show all') + assert page.has_content?('Becoming an apprentice and Becoming a wizard') + assert page.has_css?('a', text: 'Learn to drive a car') + assert page.has_css?('a', text: 'Becoming an apprentice') + assert page.has_css?('a', text: 'Becoming a wizard') + end + end + + test "ContentPagesNav variant B shows home breadcrumb when a page belongs to more than two topics and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', THREE_TAXONS) + + within('.gem-c-contextual-breadcrumbs') do + assert page.has_css?('a', text: 'Home') + refute page.has_css?('a', text: 'Becoming an apprentice') + refute page.has_css?('a', text: 'Becoming a wizard') + refute page.has_css?('a', text: 'Becoming the sorceror supreme') + end + end + + test "ContentPagesNav variant B shows banner when a page belongs to more than two topics and a step by step" do + stub_rummager + setup_variant_b + + setup_and_visit_content_item_with_taxons('guide-with-step-navs', THREE_TAXONS) + + within('.taxonomy-navigation__banner') do + assert page.has_content?('This page is part of Learn to drive a car: step by step and 3 others + show all') + assert page.has_content?('Becoming an apprentice, Becoming a wizard, and Becoming the sorceror supreme') + assert page.has_css?('a', text: 'Learn to drive a car') + assert page.has_css?('a', text: 'Becoming an apprentice') + assert page.has_css?('a', text: 'Becoming a wizard') + assert page.has_css?('a', text: 'Becoming the sorceror supreme') end end diff --git a/test/support/content_pages_nav_test_helper.rb b/test/support/content_pages_nav_test_helper.rb index 6c357d783..88ebba55f 100644 --- a/test/support/content_pages_nav_test_helper.rb +++ b/test/support/content_pages_nav_test_helper.rb @@ -66,6 +66,25 @@ def setup_and_visit_content_from_publishing_app(publishing_app: nil) } ].freeze + TWO_TAXONS = [ + { + "base_path" => "/education/becoming-an-apprentice", + "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af2", + "description" => "Pay and conditions, how to apply, become a higher or degree apprentice. Apprenticeship levels, training, find an apprenticeship.", + "schema_name" => "taxon", + "title" => "Becoming an apprentice", + "phase" => "live", + }, + { + "base_path" => "/education/becoming-a-wizard", + "content_id" => "ff0e8e1f-4dea-42ff-b1d5-f1ae37807af3", + "description" => "Pay and conditions, how to apply, become a higher or degree wizard. Wizard levels, training, find a wizard placement.", + "schema_name" => "taxon", + "title" => "Becoming a wizard", + "phase" => "live", + } + ].freeze + THREE_TAXONS = [ { "base_path" => "/education/becoming-an-apprentice",