Skip to content

Commit

Permalink
Remove Tree test survey recruitment banners
Browse files Browse the repository at this point in the history
  • Loading branch information
AgaDufrat committed Aug 16, 2022
1 parent 512d221 commit d38dde6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 59 deletions.
25 changes: 1 addition & 24 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module ContentItem
module RecruitmentBanner
TREE_TEST_URL = "https://GDSUserResearch.optimalworkshop.com/treejack/8f1yr1fj".freeze
TREE_TEST_PAGE = "/browse/working".freeze
TREE_TEST_MAPPINGS = { TREE_TEST_PAGE => TREE_TEST_URL }.freeze

VISA_TEST_URL = "https://surveys.publishing.service.gov.uk/s/0DZCPX/".freeze
VISA_TEST_MAPPINGS = {
"/apply-to-come-to-the-uk" => VISA_TEST_URL,
Expand All @@ -22,31 +18,12 @@ module RecruitmentBanner
}.freeze

def recruitment_survey_url
tree_test_url || visa_test_url
end

def tree_test_url
key = TREE_TEST_MAPPINGS.keys.find { |k| content_tagged_to(k).present? }
TREE_TEST_MAPPINGS[key]
visa_test_url
end

def visa_test_url
key = content_item["base_path"]
VISA_TEST_MAPPINGS[key]
end

private

def mainstream_browse_pages
content_item["links"]["mainstream_browse_pages"] if content_item["links"]
end

def content_tagged_to(browse_base_path)
return [] unless mainstream_browse_pages

mainstream_browse_pages.find do |mainstream_browse_page|
mainstream_browse_page["base_path"].starts_with? browse_base_path
end
end
end
end
35 changes: 0 additions & 35 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
require "test_helper"

class RecruitmentBannerTest < ActionDispatch::IntegrationTest
test "Tree test recruitment banner is displayed for any page tagged to Working, jobs and pensions" do
@working_browse_page = {
"content_id" => "123",
"title" => "Self Assessment",
"base_path" => "/browse/working/self-assessment",
}

guide = GovukSchemas::Example.find("guide", example_name: "guide")
guide["links"]["mainstream_browse_pages"] = []
guide["links"]["mainstream_browse_pages"] << @working_browse_page

stub_content_store_has_item(guide["base_path"], guide.to_json)
visit guide["base_path"]

assert page.has_css?(".gem-c-intervention")
assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/8f1yr1fj")
end

test "Tree test recruitment banner is not displayed unless page is tagged to a topic of interest" do
@not_of_interest = {
"content_id" => "123",
"title" => "I am not interesting",
"base_path" => "/browse/boring",
}

guide = GovukSchemas::Example.find("guide", example_name: "guide")
guide["links"]["mainstream_browse_pages"] = []
guide["links"]["mainstream_browse_pages"] << @not_of_interest
stub_content_store_has_item(guide["base_path"], guide.to_json)
visit_with_cachebust guide["base_path"]

assert_not page.has_css?(".gem-c-intervention")
assert_not page.has_link?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/8f1yr1fj")
end

test "Visa test recruitment banner is displayed on pages of interest" do
guide = GovukSchemas::Example.find("guide", example_name: "guide")

Expand Down

0 comments on commit d38dde6

Please sign in to comment.