From 4d72565e9d02d221b270648b215f5603104c03a3 Mon Sep 17 00:00:00 2001 From: hannako Date: Wed, 3 Aug 2022 13:57:21 +0100 Subject: [PATCH 1/2] Rename survey urls -> tree test urls We are adding a new recruitment banner to visa pages, so we need to be rename things a bit first. --- app/presenters/content_item/recruitment_banner.rb | 15 +++++++++------ test/integration/recruitment_banner_test.rb | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb index b304fd556..49fb4106c 100644 --- a/app/presenters/content_item/recruitment_banner.rb +++ b/app/presenters/content_item/recruitment_banner.rb @@ -1,13 +1,16 @@ module ContentItem module RecruitmentBanner - SURVEY_URL_ONE = "https://GDSUserResearch.optimalworkshop.com/treejack/834dm2s6".freeze - SURVEY_URLS = { - "/browse/working" => SURVEY_URL_ONE, - }.freeze + TREE_TEST_URL = "https://GDSUserResearch.optimalworkshop.com/treejack/834dm2s6".freeze + TREE_TEST_PAGE = "/browse/working".freeze + TREE_TEST_MAPPINGS = { TREE_TEST_PAGE => TREE_TEST_URL }.freeze def recruitment_survey_url - key = SURVEY_URLS.keys.find { |k| content_tagged_to(k).present? } - SURVEY_URLS[key] + tree_test_url + end + + def tree_test_url + key = TREE_TEST_MAPPINGS.keys.find { |k| content_tagged_to(k).present? } + TREE_TEST_MAPPINGS[key] end private diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb index 30eea2786..10f6dc389 100644 --- a/test/integration/recruitment_banner_test.rb +++ b/test/integration/recruitment_banner_test.rb @@ -1,7 +1,7 @@ require "test_helper" class RecruitmentBannerTest < ActionDispatch::IntegrationTest - test "Recruitment Banner is displayed for any page tagged to Working, jobs and pensions" do + 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", @@ -19,7 +19,7 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest assert page.has_link?("Take part in user research (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/834dm2s6") end - test "Recruitment Banner is not displayed unless page is tagged to a topic of interest" do + 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", From d6afe1d620f9ec2188c056a6028d9746337ab1e2 Mon Sep 17 00:00:00 2001 From: hannako Date: Wed, 3 Aug 2022 14:24:19 +0100 Subject: [PATCH 2/2] Add recruitment banner to pages relevant to UK visa service --- .../content_item/recruitment_banner.rb | 24 ++++++++++- test/integration/recruitment_banner_test.rb | 40 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb index 49fb4106c..50bc54f75 100644 --- a/app/presenters/content_item/recruitment_banner.rb +++ b/app/presenters/content_item/recruitment_banner.rb @@ -4,8 +4,25 @@ module RecruitmentBanner 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, + "/healthcare-immigration-application" => VISA_TEST_URL, + "/tb-test-visa" => VISA_TEST_URL, + "/faster-decision-visa-settlement" => VISA_TEST_URL, + "/skilled-worker-visa" => VISA_TEST_URL, + "/health-care-worker-visa" => VISA_TEST_URL, + "/temporary-worker-charity-worker-visa" => VISA_TEST_URL, + "/seasonal-worker-visa" => VISA_TEST_URL, + "/graduate-visa" => VISA_TEST_URL, + "/uk-family-visa" => VISA_TEST_URL, + "/find-a-visa-application-centre" => VISA_TEST_URL, + "/guidance/visa-decision-waiting-times-applications-outside-the-uk" => VISA_TEST_URL, + "/government/publications/skilled-worker-visa-shortage-occupations/skilled-worker-visa-shortage-occupations" => VISA_TEST_URL, + }.freeze + def recruitment_survey_url - tree_test_url + tree_test_url || visa_test_url end def tree_test_url @@ -13,6 +30,11 @@ def tree_test_url TREE_TEST_MAPPINGS[key] end + def visa_test_url + key = content_item["base_path"] + VISA_TEST_MAPPINGS[key] + end + private def mainstream_browse_pages diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb index 10f6dc389..75c2afa93 100644 --- a/test/integration/recruitment_banner_test.rb +++ b/test/integration/recruitment_banner_test.rb @@ -35,4 +35,44 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest assert_not page.has_css?(".gem-c-intervention") assert_not page.has_link?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/834dm2s6") end + + test "Visa test recruitment banner is displayed on pages of interest" do + guide = GovukSchemas::Example.find("guide", example_name: "guide") + + pages_of_interest = + [ + "/apply-to-come-to-the-uk", + "/healthcare-immigration-application", + "/tb-test-visa", + "/faster-decision-visa-settlement", + "/skilled-worker-visa", + "/health-care-worker-visa", + "/temporary-worker-charity-worker-visa", + "/seasonal-worker-visa", + "/graduate-visa", + "/uk-family-visa", + "/find-a-visa-application-centre", + "/guidance/visa-decision-waiting-times-applications-outside-the-uk", + "/government/publications/skilled-worker-visa-shortage-occupations/skilled-worker-visa-shortage-occupations", + ] + + pages_of_interest.each do |path| + guide["base_path"] = path + 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://surveys.publishing.service.gov.uk/s/0DZCPX/") + end + end + + test "Visa test recruitment banner is not displayed on all pages" do + guide = GovukSchemas::Example.find("guide", example_name: "guide") + guide["base_path"] = "/nothing-to-see-here" + stub_content_store_has_item(guide["base_path"], guide.to_json) + visit guide["base_path"] + + assert_not page.has_css?(".gem-c-intervention") + assert_not page.has_link?("Take part in user research", href: "https://surveys.publishing.service.gov.uk/s/0DZCPX/") + end end