diff --git a/app/presenters/content_item/recruitment_banner.rb b/app/presenters/content_item/recruitment_banner.rb new file mode 100644 index 0000000000..2715c9a4d4 --- /dev/null +++ b/app/presenters/content_item/recruitment_banner.rb @@ -0,0 +1,18 @@ +module ContentItem + module RecruitmentBanner + BRAND_SURVEY_URL = "https://surveys.publishing.service.gov.uk/s/5G06FO/".freeze + SURVEY_URL_MAPPINGS = { + "/check-national-insurance-record" => BRAND_SURVEY_URL, + "/check-mot-history" => BRAND_SURVEY_URL, + }.freeze + + def recruitment_survey_url + brand_user_research_test_url + end + + def brand_user_research_test_url + key = content_item["base_path"] + SURVEY_URL_MAPPINGS[key] + end + end +end diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index a492bdedc8..cf79b347a4 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -1,4 +1,6 @@ class ContentItemPresenter + include ContentItem::RecruitmentBanner + attr_reader :content_item def initialize(content_item) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5e05aad968..f202d69a22 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,14 @@ <%= yield %> <% else %> - <% if publication && publication.in_beta %> + <% if publication && publication.recruitment_survey_url %> + <%= render "govuk_publishing_components/components/intervention", { + suggestion_text: "Help improve GOV.UK", + suggestion_link_text: "Take part in user research (opens in a new tab)", + suggestion_link_url: publication.recruitment_survey_url, + new_tab: true, + } %> + <% elsif publication && publication.in_beta %> <%= render 'govuk_publishing_components/components/phase_banner', phase: "beta", ga4_tracking: true %> <% end %> <% unless current_page?(root_path) || !(publication || @calendar) %> diff --git a/test/integration/recruitment_banner_test.rb b/test/integration/recruitment_banner_test.rb new file mode 100644 index 0000000000..cec5e4bff7 --- /dev/null +++ b/test/integration/recruitment_banner_test.rb @@ -0,0 +1,32 @@ +require "integration_test_helper" + +class RecruitmentBannerTest < ActionDispatch::IntegrationTest + test "Brand user research banner is displayed on pages of interest" do + transaction = GovukSchemas::Example.find("transaction", example_name: "transaction") + + pages_of_interest = + [ + "/check-national-insurance-record", + "/check-mot-history", + ] + + pages_of_interest.each do |path| + transaction["base_path"] = path + stub_content_store_has_item(transaction["base_path"], transaction.to_json) + visit transaction["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/5G06FO/") + end + end + + test "Brand user research banner is not displayed on all pages" do + transaction = GovukSchemas::Example.find("transaction", example_name: "transaction") + transaction["base_path"] = "/nothing-to-see-here" + stub_content_store_has_item(transaction["base_path"], transaction.to_json) + visit transaction["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/5G06FO/") + end +end