|
| 1 | +require "test_helper" |
| 2 | + |
| 3 | +class RecruitmentBannerTest < ActionDispatch::IntegrationTest |
| 4 | + test "Recruitment Banner is displayed for any page tagged to Working, jobs and pensions" do |
| 5 | + @working_browse_page = { |
| 6 | + "content_id" => "123", |
| 7 | + "title" => "Self Assessment", |
| 8 | + "base_path" => "/browse/working/self-assessment", |
| 9 | + } |
| 10 | + |
| 11 | + guide = GovukSchemas::Example.find("guide", example_name: "guide") |
| 12 | + guide["links"]["mainstream_browse_pages"] = [] |
| 13 | + guide["links"]["mainstream_browse_pages"] << @working_browse_page |
| 14 | + |
| 15 | + stub_content_store_has_item(guide["base_path"], guide.to_json) |
| 16 | + visit guide["base_path"] |
| 17 | + |
| 18 | + assert page.has_css?(".gem-c-intervention") |
| 19 | + assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/61ec38b742396bc23d00104953ffb17d") |
| 20 | + end |
| 21 | + |
| 22 | + test "Recruitment Banner is not displayed unless page is tagged to a topic of interest" do |
| 23 | + @not_of_interest = { |
| 24 | + "content_id" => "123", |
| 25 | + "title" => "I am not interesting", |
| 26 | + "base_path" => "/browse/boring", |
| 27 | + } |
| 28 | + |
| 29 | + guide = GovukSchemas::Example.find("guide", example_name: "guide") |
| 30 | + guide["links"]["mainstream_browse_pages"] = [] |
| 31 | + guide["links"]["mainstream_browse_pages"] << @not_of_interest |
| 32 | + stub_content_store_has_item(guide["base_path"], guide.to_json) |
| 33 | + visit_with_cachebust guide["base_path"] |
| 34 | + |
| 35 | + assert_not page.has_css?(".gem-c-intervention") |
| 36 | + assert_not page.has_link?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/61ec38b742396bc23d00104953ffb17d") |
| 37 | + end |
| 38 | +end |
0 commit comments