Skip to content

Commit 5150003

Browse files
Add User Research Banner
User Research banner added for following pages: - /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
1 parent 7cc786c commit 5150003

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

app/presenters/content_item_presenter.rb

+18
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ class ContentItemPresenter
1818

1919
attr_accessor :include_collections_in_other_publisher_metadata
2020

21+
COLD_SURVEY_URL = "https://forms.office.com/pages/responsepage.aspx?id=lY2s6r7DX0av4Th52NzAlAT5pt_hKLdInpMo5L74aZNUMzgzVUhaSDRSNVg0UVpVOTNLWFFZUlcyRy4u".freeze
22+
COLD_SURVEY_URL_MAPPINGS = {
23+
"/cold-weather-payment" => COLD_SURVEY_URL,
24+
"/cold-weather-payment/eligibility" => COLD_SURVEY_URL,
25+
"/cold-weather-payment/what-you-need-to-do" => COLD_SURVEY_URL,
26+
"/cold-weather-payment/when-youll-get-paid" => COLD_SURVEY_URL,
27+
"/cold-weather-payment/further-information" => COLD_SURVEY_URL,
28+
}.freeze
29+
30+
def recruitment_survey_url
31+
user_research_test_url
32+
end
33+
34+
def user_research_test_url
35+
key = content_item["base_path"]
36+
COLD_SURVEY_URL_MAPPINGS[key]
37+
end
38+
2139
def initialize(content_item, requested_path, view_context)
2240
@content_item = content_item
2341
@requested_path = requested_path

app/views/layouts/application.html.erb

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
<% end %>
2424
<% end %>
2525

26+
<% if @content_item.recruitment_survey_url %>
27+
<div class="govuk-!-static-margin-top-4">
28+
<%= render "govuk_publishing_components/components/intervention", {
29+
suggestion_text: "Help improve a new GOV.UK tool",
30+
suggestion_link_text: "Sign up to take part in user research",
31+
suggestion_link_url: @content_item.recruitment_survey_url,
32+
new_tab: true,
33+
} %>
34+
</div>
35+
<% end %>
36+
2637
<%= yield :header %>
2738

2839
<main role="main" id="content" class="<%= @content_item.schema_name.dasherize %>" lang="<%= I18n.locale %>">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require "test_helper"
2+
3+
class RecruitmentBannerTest < ActionDispatch::IntegrationTest
4+
test "User research banner is displayed on pages of interest" do
5+
guide = GovukSchemas::Example.find("guide", example_name: "guide")
6+
7+
pages_of_interest =
8+
[
9+
"/cold-weather-payment",
10+
"/cold-weather-payment/eligibility",
11+
"/cold-weather-payment/what-you-need-to-do",
12+
"/cold-weather-payment/when-youll-get-paid",
13+
"/cold-weather-payment/further-information",
14+
]
15+
16+
pages_of_interest.each do |path|
17+
guide["base_path"] = path
18+
stub_content_store_has_item(guide["base_path"], guide.to_json)
19+
visit guide["base_path"]
20+
21+
assert page.has_css?(".gem-c-intervention")
22+
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")
23+
end
24+
end
25+
26+
test "User research banner is not displayed on all pages" do
27+
guide = GovukSchemas::Example.find("guide", example_name: "guide")
28+
guide["base_path"] = "/nothing-to-see-here"
29+
stub_content_store_has_item(guide["base_path"], guide.to_json)
30+
visit guide["base_path"]
31+
32+
assert_not page.has_css?(".gem-c-intervention")
33+
assert_not page.has_link?("Sign up to take part in user research", href: "https://gov.uk")
34+
end
35+
end

0 commit comments

Comments
 (0)