Skip to content

Commit

Permalink
Merge pull request #6514 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 221209c + 1868fc2 commit 756da77
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ $govuk-new-link-styles: true;
$govuk-include-default-font-face: false;

@import "govuk_publishing_components/govuk_frontend_support";
@import "govuk_publishing_components/components/intervention";

@import "components/intervention";
@import "smart_answers";

.desktop-min-height {
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/components/_intervention.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gem-c-intervention {
margin-top: govuk-spacing(4);
}
21 changes: 21 additions & 0 deletions app/presenters/start_node/recruitment_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module StartNode
module RecruitmentBanner
SURVEY_URLS = {
"/childcare-costs-for-tax-credits" => "https://surveys.publishing.service.gov.uk/s/4J4QD4/",
}.freeze

def survey_url(path)
landing_page?(path) && SURVEY_URLS[base_path]
end

private

def base_path
"/#{@flow_presenter.name}"
end

def landing_page?(current_path)
base_path == current_path
end
end
end
2 changes: 2 additions & 0 deletions app/presenters/start_node_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class StartNodePresenter < NodePresenter
include StartNode::RecruitmentBanner

def initialize(node, flow_presenter, state = nil, options = {})
super(node, flow_presenter, state)
@renderer = options[:renderer] || SmartAnswer::ErbRenderer.new(
Expand Down
10 changes: 10 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<% content_for :body do %>
<div class="smart_answer">
<%= yield :breadcrumbs %>
<% if @presenter && @presenter.start_node.survey_url(request.path) %>
<div class="banner-container">
<%= render "govuk_publishing_components/components/intervention", {
suggestion_text: "Help improve GOV.UK",
suggestion_link_text: "Take part in user research",
suggestion_link_url: @presenter.start_node.survey_url(request.path),
new_tab: true,
} %>
</div>
<% end %>
<main id="content" role="main">
<%= yield %>
</main>
Expand Down
31 changes: 31 additions & 0 deletions test/integration/recruitment_banner_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require_relative "../integration_test_helper"

class RecruitmentBannerTest < ActionDispatch::IntegrationTest
context "user research banner" do
context "childcare costs for tax credits" do
setup do
stub_content_store_has_item("/childcare-costs-for-tax-credits")
end

should "display User Research Banner on the landing page" do
visit "/childcare-costs-for-tax-credits"
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

should "not display User Research Banner on non-landing pages of the specific smart answer" do
visit "/childcare-costs-for-tax-credits/y"

assert_not page.has_css?(".gem-c-intervention")
assert_not page.has_link?("Take part in user research (opens in a new tab)", href: "https://surveys.publishing.service.gov.uk/s/4J4QD4/")
end

should "not display User Research Banner unless survey URL is specified for the base path" do
visit "/bridge-of-death"

assert_not page.has_css?(".gem-c-intervention")
assert_not page.has_link?("Take part in user research (opens in a new tab)", href: "https://surveys.publishing.service.gov.uk/s/4J4QD4/")
end
end
end
end

0 comments on commit 756da77

Please sign in to comment.