Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User Research Banner for Business Topic Pages #3450

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 GOV.UK",
suggestion_link_text: "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
12 changes: 12 additions & 0 deletions app/views/second_level_browse_page/show_a_to_z.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@

<div class="govuk-width-container">
<div class="govuk-grid-row">

<% if page.recruitment_survey_url %>
<div class="govuk-!-static-margin-top-4">
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Take part in user research",
suggestion_link_url: page.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-2" data-module="ga4-link-tracker">
<%
index_section_count = page.lists.count
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 GOV.UK",
suggestion_link_text: "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 GOV.UK tool",
suggestion_link_text: "Take part in user research",
suggestion_link_url: subtopic.recruitment_survey_url,
new_tab: true,
} %>
</div>
<% end %>

<%= render(
layout: "subtopic",
locals: {
Expand Down
60 changes: 60 additions & 0 deletions spec/features/research_panel_banner_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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")
hannako marked this conversation as resolved.
Show resolved Hide resolved

survey_url = "https://surveys.publishing.service.gov.uk/s/ur-ttm/"

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

pages_of_interest.each do |path|
schema["base_path"] = path
stub_content_store_has_item(schema["base_path"], schema.to_json)
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)

assert page.has_css?(".gem-c-intervention")
assert page.has_link?("Take part in user research", href: survey_url)
end
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