Skip to content

Commit

Permalink
Merge pull request #3023 from alphagov/hmrc_user_research_banner
Browse files Browse the repository at this point in the history
Add user research banner
  • Loading branch information
hannako authored Dec 22, 2023
2 parents 4276b89 + 58c9347 commit c1949ec
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module ContentItem
module RecruitmentBanner
SURVEY_URL = "https://signup.take-part-in-research.service.gov.uk/".freeze
SURVEY_URL_MAPPINGS = {
"/guidance/check-employment-status-for-tax" => "#{SURVEY_URL}?utm_campaign=List_CEST_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=577",
"/guidance/corporation-tax-trading-and-non-trading" => "#{SURVEY_URL}?utm_campaign=List_Corp_Tax_trading_and_non_trading_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=578",
"/guidance/how-to-fill-in-and-submit-your-vat-return-vat-notice-70012" => "#{SURVEY_URL}?utm_campaign=List_Fill_and_submit_VAT_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=579",
"/guidance/sign-in-to-your-hmrc-business-tax-account" => "#{SURVEY_URL}?utm_campaign=List_Sign_in_BTA_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=580",
"/guidance/rates-of-vat-on-different-goods-and-services" => "#{SURVEY_URL}?utm_campaign=List_VAT_on_goods_and_services_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=581",
"/guidance/claim-a-refund-of-construction-industry-scheme-deductions-if-youre-a-limited-company" => "#{SURVEY_URL}?utm_campaign=List_CIS_refund_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=582",
"/guidance/understanding-off-payroll-working-ir35" => "#{SURVEY_URL}?utm_campaign=List_IR35_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=583",
"/guidance/tax-reliefs-and-allowances-for-businesses-employers-and-the-self-employed" => "#{SURVEY_URL}?utm_campaign=List_Tax_reliefs_and_allowances_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=584",
"/guidance/corporation-tax-selling-or-closing-your-company" => "#{SURVEY_URL}?utm_campaign=List_Corp_Tax_selling_or_closing_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=585",
"/guidance/check-when-you-can-expect-a-reply-from-hmrc" => "#{SURVEY_URL}?utm_campaign=List_Expect_a_reply_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=586",
}.freeze

def recruitment_survey_url
key = content_item["base_path"]
SURVEY_URL_MAPPINGS[key]
end
end
end
1 change: 1 addition & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ContentItemPresenter
include ContentItem::Withdrawable
include ContentItem::RecruitmentBanner

attr_reader :content_item,
:requested_path,
Expand Down
11 changes: 11 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
<% end %>
<% end %>

<% if @content_item.recruitment_survey_url %>
<div class="govuk-!-static-margin-top-4">
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Sign up to take part in user research (opens in a new tab)",
suggestion_link_url: @content_item.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<%= yield :header %>

<main role="main" id="content" class="<%= @content_item.schema_name.dasherize %>" lang="<%= I18n.locale %>">
Expand Down
41 changes: 41 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require "test_helper"

class RecruitmentBannerTest < ActionDispatch::IntegrationTest
test "User research banner is displayed on pages of interest" do
guide = GovukSchemas::Example.find("guide", example_name: "guide")
survey_url = "https://signup.take-part-in-research.service.gov.uk/"
survey_url_mappings = {
"/guidance/check-employment-status-for-tax" => "#{survey_url}?utm_campaign=List_CEST_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=577",
"/guidance/corporation-tax-trading-and-non-trading" => "#{survey_url}?utm_campaign=List_Corp_Tax_trading_and_non_trading_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=578",
"/guidance/how-to-fill-in-and-submit-your-vat-return-vat-notice-70012" => "#{survey_url}?utm_campaign=List_Fill_and_submit_VAT_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=579",
"/guidance/sign-in-to-your-hmrc-business-tax-account" => "#{survey_url}?utm_campaign=List_Sign_in_BTA_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=580",
"/guidance/rates-of-vat-on-different-goods-and-services" => "#{survey_url}?utm_campaign=List_VAT_on_goods_and_services_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=581",
"/guidance/claim-a-refund-of-construction-industry-scheme-deductions-if-youre-a-limited-company" => "#{survey_url}?utm_campaign=List_CIS_refund_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=582",
"/guidance/understanding-off-payroll-working-ir35" => "#{survey_url}?utm_campaign=List_IR35_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=583",
"/guidance/tax-reliefs-and-allowances-for-businesses-employers-and-the-self-employed" => "#{survey_url}?utm_campaign=List_Tax_reliefs_and_allowances_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=584",
"/guidance/corporation-tax-selling-or-closing-your-company" => "#{survey_url}?utm_campaign=List_Corp_Tax_selling_or_closing_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=585",
"/guidance/check-when-you-can-expect-a-reply-from-hmrc" => "#{survey_url}?utm_campaign=List_Expect_a_reply_TAD&utm_source=Other&utm_medium=gov.uk&t=HMRC&id=586",
}.freeze

pages_of_interest = survey_url_mappings.keys

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?("Sign up to take part in user research (opens in a new tab)", href: survey_url_mappings[path])
end
end

test "User research 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?("Sign up to take part in user research", href: "https://gov.uk")
end
end

0 comments on commit c1949ec

Please sign in to comment.