Skip to content

Commit

Permalink
Add user research banner to benefits pages
Browse files Browse the repository at this point in the history
  • Loading branch information
catalinailie committed Oct 10, 2023
1 parent aea97f6 commit b38b7d5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,34 @@ module RecruitmentBanner
"/government/organisations/hm-revenue-customs/contact/self-assessment" => SURVEY_URL,
}.freeze

BENEFITS_SURVEY_URL = "https://signup.take-part-in-research.service.gov.uk/home?utm_campaign=Content_History&utm_source=Hold_gov_to_account&utm_medium=gov.uk&t=GDS&id=16".freeze
BENEFITS_SURVEY_URL_MAPPINGS = {
"/disability-living-allowance-children" => BENEFITS_SURVEY_URL,
"/help-with-childcare-costs" => BENEFITS_SURVEY_URL,
"/financial-help-disabled" => BENEFITS_SURVEY_URL,
"/pip" => BENEFITS_SURVEY_URL,
"/blind-persons-allowance" => BENEFITS_SURVEY_URL,
"/dla-disability-living-allowance-benefit" => BENEFITS_SURVEY_URL,
"/carers-allowance" => BENEFITS_SURVEY_URL,
"/carers-credit" => BENEFITS_SURVEY_URL,
"/maternity-pay-leave" => BENEFITS_SURVEY_URL,
"/paternity-pay-leave" => BENEFITS_SURVEY_URL,
"/child-benefit" => BENEFITS_SURVEY_URL,
"/jobseekers-allowance" => BENEFITS_SURVEY_URL,
"/universal-credit" => BENEFITS_SURVEY_URL,
"/employment-support-allowance" => BENEFITS_SURVEY_URL,
"/benefits-calculators" => BENEFITS_SURVEY_URL,
}.freeze

def recruitment_survey_url
user_research_test_url
end

def benefits_recruitment_survey_url
key = content_item["base_path"]
BENEFITS_SURVEY_URL_MAPPINGS[key]
end

def user_research_test_url
key = content_item["base_path"]
SURVEY_URL_MAPPINGS[key]
Expand Down
9 changes: 9 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
new_tab: true,
} %>
</div>
<% elsif @content_item.benefits_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: "Take part in user research",
suggestion_link_url: @content_item.benefits_recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<%= yield :header %>
Expand Down
32 changes: 32 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,38 @@ class RecruitmentBannerTest < ActionDispatch::IntegrationTest
end
end

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

pages_of_interest =
[
"/disability-living-allowance-children",
"/help-with-childcare-costs",
"/financial-help-disabled",
"/pip",
"/blind-persons-allowance",
"/dla-disability-living-allowance-benefit",
"/carers-allowance",
"/carers-credit",
"/maternity-pay-leave",
"/paternity-pay-leave",
"/child-benefit",
"/jobseekers-allowance",
"/universal-credit",
"/employment-support-allowance",
"/benefits-calculators",
]

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", href: "https://signup.take-part-in-research.service.gov.uk/home?utm_campaign=Content_History&utm_source=Hold_gov_to_account&utm_medium=gov.uk&t=GDS&id=16")
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"
Expand Down

0 comments on commit b38b7d5

Please sign in to comment.