Skip to content

Commit

Permalink
Add recruitment banner for cost of living tree test
Browse files Browse the repository at this point in the history
  • Loading branch information
hannako committed Dec 13, 2022
1 parent e928965 commit a65ce9f
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/components/_banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
max-width: 30em;
padding-top: govuk-spacing(2);
}

.gem-c-intervention {
margin-top: govuk-spacing(4);
}
32 changes: 32 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module ContentItem
module RecruitmentBanner
COST_OF_LIVING_SURVEY_URL = "https://GDSUserResearch.optimalworkshop.com/treejack/cbd7a696cbf57c683cbb2e95b4a36c8a".freeze
SURVEY_URL_MAPPINGS = {
"/guidance/cost-of-living-payment" => COST_OF_LIVING_SURVEY_URL,
"/universal-credit" => COST_OF_LIVING_SURVEY_URL,
"/the-warm-home-discount-scheme" => COST_OF_LIVING_SURVEY_URL,
"/winter-fuel-payment" => COST_OF_LIVING_SURVEY_URL,
"/pay-self-assessment-tax-bill" => COST_OF_LIVING_SURVEY_URL,
"/universal-credit/eligibility" => COST_OF_LIVING_SURVEY_URL,
"/universal-credit/what-youll-get" => COST_OF_LIVING_SURVEY_URL,
"/universal-credit/how-to-claim" => COST_OF_LIVING_SURVEY_URL,
"/winter-fuel-payment/how-much-youll-get" => COST_OF_LIVING_SURVEY_URL,
"/government/publications/autumn-statement-2022-cost-of-living-support-factsheet/cost-of-living-support-factsheet" => COST_OF_LIVING_SURVEY_URL,
"/new-state-pension/what-youll-get" => COST_OF_LIVING_SURVEY_URL,
"/check-if-youre-eligible-for-warm-home-discount" => COST_OF_LIVING_SURVEY_URL,
"/universal-credit/other-financial-support" => COST_OF_LIVING_SURVEY_URL,
"/guidance/getting-the-energy-bills-support-scheme-discount" => COST_OF_LIVING_SURVEY_URL,
"/pension-credit" => COST_OF_LIVING_SURVEY_URL,
"/child-benefit" => COST_OF_LIVING_SURVEY_URL,
}.freeze

def recruitment_survey_url
cost_of_living_test_url
end

def cost_of_living_test_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,
:view_context,
Expand Down
9 changes: 8 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
</head>
<body>
<div id="wrapper" class="<%= wrapper_class %>">
<% if @content_item.show_phase_banner? %>
<% if @content_item.recruitment_survey_url %>
<%= 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.recruitment_survey_url,
new_tab: true,
} %>
<% elsif @content_item.show_phase_banner? %>
<%= render 'govuk_publishing_components/components/phase_banner', phase: @content_item.phase %>
<% end %>

Expand Down
46 changes: 46 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require "test_helper"

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

pages_of_interest =
[
"/guidance/cost-of-living-payment",
"/universal-credit",
"/the-warm-home-discount-scheme",
"/winter-fuel-payment",
"/pay-self-assessment-tax-bill",
"/universal-credit/eligibility",
"/universal-credit/what-youll-get",
"/universal-credit/how-to-claim",
"/winter-fuel-payment/how-much-youll-get",
"/government/publications/autumn-statement-2022-cost-of-living-support-factsheet/cost-of-living-support-factsheet",
"/new-state-pension/what-youll-get",
"/check-if-youre-eligible-for-warm-home-discount",
"/universal-credit/other-financial-support",
"/guidance/getting-the-energy-bills-support-scheme-discount",
"/pension-credit",
"/child-benefit",
]

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 (opens in a new tab)", href: "https://GDSUserResearch.optimalworkshop.com/treejack/cbd7a696cbf57c683cbb2e95b4a36c8a")
end
end

test "Cost of living recruitment 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?("Take part in user research", href: "https://GDSUserResearch.optimalworkshop.com/treejack/cbd7a696cbf57c683cbb2e95b4a36c8a")
end
end

0 comments on commit a65ce9f

Please sign in to comment.