Skip to content

Commit

Permalink
Merge pull request #3732 from alphagov/add-user-research-banner
Browse files Browse the repository at this point in the history
Add user research banner for One Login
  • Loading branch information
catalinailie authored Aug 23, 2023
2 parents 96632fb + ec41b9f commit c328c82
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/presenters/content_item/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module ContentItem
module RecruitmentBanner
SURVEY_URL = "https://surveys.publishing.service.gov.uk/s/4J4QD4/".freeze
SURVEY_URL_MAPPINGS = {
"/check-national-insurance-record" => SURVEY_URL,
"/check-state-pension" => SURVEY_URL,
"/student-finance-register-login" => SURVEY_URL,
"/sign-in-universal-credit" => SURVEY_URL,
}.freeze

def recruitment_survey_url
user_research_test_url
end

def user_research_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,4 +1,5 @@
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" %>
<% end %>
<% unless current_page?(root_path) || !(publication || @calendar) %>
Expand Down
34 changes: 34 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require "integration_test_helper"

class RecruitmentBannerTest < ActionDispatch::IntegrationTest
test "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-state-pension",
"/student-finance-register-login",
"/sign-in-universal-credit",
]

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/4J4QD4/")
end
end

test "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/4J4QD4/")
end
end

0 comments on commit c328c82

Please sign in to comment.