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 428a35e commit ccda032
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 3 deletions.
34 changes: 34 additions & 0 deletions app/helpers/recruitment_banner_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module RecruitmentBannerHelper
SURVEY_URL = "https://surveys.publishing.service.gov.uk/s/ur-ttm/".freeze

SURVEY_URL_MAPPINGS = {
"/browse/business/setting-up" => SURVEY_URL,
"/browse/business/business-tax" => SURVEY_URL,
"/browse/business/finance-support" => SURVEY_URL,
"/browse/business/limited-company" => SURVEY_URL,
"/browse/business/expenses-employee-benefits" => SURVEY_URL,
"/browse/business/funding-debt" => SURVEY_URL,
"/browse/business/premises-rates" => SURVEY_URL,
"/browse/business/food" => SURVEY_URL,
"/browse/business/imports" => SURVEY_URL,
"/browse/business/exports" => SURVEY_URL,
"/browse/business/licences" => SURVEY_URL,
"/browse/business/selling-closing" => SURVEY_URL,
"/browse/business/sale-goods-services-data" => SURVEY_URL,
"/browse/business/childcare-providers" => SURVEY_URL,
"/browse/business/manufacturing" => SURVEY_URL,
"/browse/business/intellectual-property" => SURVEY_URL,
"/browse/business/waste-environment" => SURVEY_URL,
"/browse/business/science" => SURVEY_URL,
"/browse/business/maritime" => SURVEY_URL,
"/browse/business" => SURVEY_URL,
}.freeze

def recruitment_survey_url
user_research_test_url
end

def user_research_test_url
SURVEY_URL_MAPPINGS[base_path]
end
end
2 changes: 2 additions & 0 deletions app/models/mainstream_browse_page.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class MainstreamBrowsePage
include RecruitmentBannerHelper

attr_reader :content_item

delegate(
Expand Down
2 changes: 2 additions & 0 deletions app/models/topic.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Topic
include RecruitmentBannerHelper

attr_reader :content_item

delegate(
Expand Down
13 changes: 12 additions & 1 deletion app/views/browse/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
} %>
<% end %>

<%= render "shared/browse_header", { margin_bottom: page.slug == "benefits" ? 7 : 9 } do %>
<%= render "shared/browse_header", { margin_bottom: page.slug == "benefits" || page.recruitment_survey_url ? 7 : 9 } do %>
<h1 class="browse__heading govuk-heading-xl">
<%= page.title %>
</h1>
Expand All @@ -31,6 +31,17 @@
} %>
<% end %>

<% if page.recruitment_survey_url %>
<div class="govuk-width-container">
<%= 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: page.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<% if page.slug == "benefits" %>
<div class="govuk-width-container">
<div class="govuk-grid-row">
Expand Down
15 changes: 13 additions & 2 deletions app/views/second_level_browse_page/show_curated.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<%= render "shared/browse_breadcrumbs" %>
<% end %>

<%= render "shared/browse_header", { two_thirds: true, margin_bottom: 8 } do %>

<% margin_bottom = page.recruitment_survey_url ? 7 : 8 %>
<%= render "shared/browse_header", { two_thirds: true, margin_bottom: margin_bottom } do %>
<%= render "govuk_publishing_components/components/heading", {
font_size: "xl",
heading_level: 1,
Expand All @@ -33,6 +33,17 @@
} %>
<% end %>

<% if page.recruitment_survey_url %>
<div class="govuk-width-container">
<%= 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: page.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<div class="govuk-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds" data-module="ga4-link-tracker">
Expand Down
11 changes: 11 additions & 0 deletions app/views/subtopics/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
<%= render "govuk_publishing_components/components/title", title_params %>
<% end %>

<% if subtopic.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: subtopic.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<%= render(
layout: "subtopic",
locals: {
Expand Down
29 changes: 29 additions & 0 deletions spec/features/research_panel_banner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "integration_spec_helper"

RSpec.feature "Research panel banner" do
include SearchApiHelpers
include RecruitmentBannerHelper

scenario "browse pages where we want to display User Research banner" do
schema = GovukSchemas::Example.find("mainstream_browse_page", example_name: "level_2_page")
schema["base_path"] = "/browse/tax"
stub_content_store_has_item(schema["base_path"], schema)
search_api_has_documents_for_browse_page(schema["content_id"], [schema["base_path"]], page_size: SearchApiSearch::PAGE_SIZE_TO_GET_EVERYTHING)

visit schema["base_path"]

expect(page.status_code).to eq(200)
expect(page).to have_selector(".gem-c-intervention")
end

scenario "pages where we don't want to display User Research banner" do
schema = GovukSchemas::Example.find("mainstream_browse_page", example_name: "level_2_page")
stub_content_store_has_item(schema["base_path"], schema)
search_api_has_documents_for_browse_page(schema["content_id"], [schema["base_path"]], page_size: SearchApiSearch::PAGE_SIZE_TO_GET_EVERYTHING)

visit schema["base_path"]

expect(page.status_code).to eq(200)
expect(page).to_not have_selector(".gem-c-intervention")
end
end

0 comments on commit ccda032

Please sign in to comment.