Skip to content

Commit

Permalink
Add User Research Banner
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpatrickpatrick committed Nov 24, 2023
1 parent 7cc786c commit 8b33e5c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ class ContentItemPresenter

attr_accessor :include_collections_in_other_publisher_metadata

COLD_SURVEY_URL = "https://forms.office.com/pages/responsepage.aspx?id=lY2s6r7DX0av4Th52NzAlAT5pt_hKLdInpMo5L74aZNUMzgzVUhaSDRSNVg0UVpVOTNLWFFZUlcyRy4u".freeze
COLD_SURVEY_URL_MAPPINGS = {
"/cold-weather-payment" => COLD_SURVEY_URL,
"/cold-weather-payment/eligibility" => COLD_SURVEY_URL,
"/cold-weather-payment/what-you-need-to-do" => COLD_SURVEY_URL,
"/cold-weather-payment/when-youll-get-paid" => COLD_SURVEY_URL,
"/cold-weather-payment/further-information" => COLD_SURVEY_URL,
}.freeze

def recruitment_survey_url
user_research_test_url
end

def user_research_test_url
key = content_item["base_path"]
COLD_SURVEY_URL_MAPPINGS[key]
end

def initialize(content_item, requested_path, view_context)
@content_item = content_item
@requested_path = 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 a new GOV.UK tool",
suggestion_link_text: "Sign up to take part in user research",
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
35 changes: 35 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "test_helper"

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

pages_of_interest =
[
"/cold-weather-payment",
"/cold-weather-payment/eligibility",
"/cold-weather-payment/what-you-need-to-do",
"/cold-weather-payment/when-youll-get-paid",
"/cold-weather-payment/further-information",
]

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"
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 8b33e5c

Please sign in to comment.