Skip to content

Commit

Permalink
Merge pull request #3773 from alphagov/add-brand-user-research-banner
Browse files Browse the repository at this point in the history
Add Brand recruitment banner
  • Loading branch information
catalinailie committed Sep 22, 2023
2 parents 8bfe0bf + 9f1e6af commit fc6927b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
18 changes: 18 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module ContentItem
module RecruitmentBanner
BRAND_SURVEY_URL = "https://surveys.publishing.service.gov.uk/s/5G06FO/".freeze
SURVEY_URL_MAPPINGS = {
"/check-national-insurance-record" => BRAND_SURVEY_URL,
"/check-mot-history" => BRAND_SURVEY_URL,
}.freeze

def recruitment_survey_url
brand_user_research_test_url
end

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

attr_reader :content_item

def initialize(content_item)
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 @@ -4,7 +4,14 @@
<%= yield %>
</main>
<% else %>
<% if publication && publication.in_beta %>
<% if publication && publication.recruitment_survey_url %>
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Take part in user research (opens in a new tab)",
suggestion_link_url: publication.recruitment_survey_url,
new_tab: true,
} %>
<% elsif publication && publication.in_beta %>
<%= render 'govuk_publishing_components/components/phase_banner', phase: "beta", ga4_tracking: true %>
<% end %>
<% unless current_page?(root_path) || !(publication || @calendar) %>
Expand Down
32 changes: 32 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "integration_test_helper"

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

pages_of_interest =
[
"/check-national-insurance-record",
"/check-mot-history",
]

pages_of_interest.each do |path|
transaction["base_path"] = path
stub_content_store_has_item(transaction["base_path"], transaction.to_json)
visit transaction["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://surveys.publishing.service.gov.uk/s/5G06FO/")
end
end

test "Brand user research banner is not displayed on all pages" do
transaction = GovukSchemas::Example.find("transaction", example_name: "transaction")
transaction["base_path"] = "/nothing-to-see-here"
stub_content_store_has_item(transaction["base_path"], transaction.to_json)
visit transaction["base_path"]

assert_not page.has_css?(".gem-c-intervention")
assert_not page.has_link?("Take part in user research", href: "https://surveys.publishing.service.gov.uk/s/5G06FO/")
end
end

0 comments on commit fc6927b

Please sign in to comment.