Skip to content

Commit

Permalink
Add recruitment banner to pages relevant to UK visa service
Browse files Browse the repository at this point in the history
  • Loading branch information
hannako committed Aug 3, 2022
1 parent 4d72565 commit d6afe1d
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,37 @@ 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
key = TREE_TEST_MAPPINGS.keys.find { |k| content_tagged_to(k).present? }
TREE_TEST_MAPPINGS[key]
end

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

private

def mainstream_browse_pages
Expand Down
40 changes: 40 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d6afe1d

Please sign in to comment.