From 5c58550bd026d79689ab12aba9d73295ce75e16c Mon Sep 17 00:00:00 2001 From: Paul Robert Lloyd Date: Tue, 14 Jun 2022 17:35:18 +0100 Subject: [PATCH] Differentiate between internal and external interfaces (#660) * Differentiate support and public interfaces Co-authored-by: baarkerlounger --- app/frontend/styles/_header.scss | 5 ++++ app/helpers/application_helper.rb | 16 +++++++++++ app/views/layouts/application.html.erb | 4 +-- spec/helpers/application_helper_spec.rb | 36 +++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/app/frontend/styles/_header.scss b/app/frontend/styles/_header.scss index 670aeb8e9..12cfd4e54 100644 --- a/app/frontend/styles/_header.scss +++ b/app/frontend/styles/_header.scss @@ -21,3 +21,8 @@ } } } + +.app-header--orange, +.app-header--orange .govuk-header__container { + border-bottom-color: govuk-colour("orange"); +} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3b1332b28..971dd68d9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -9,6 +9,22 @@ module ApplicationHelper end end + def govuk_header_classes(current_user) + if current_user && current_user.support? + "app-header app-header--orange" + else + "app-header" + end + end + + def govuk_phase_banner_tag(current_user) + if current_user && current_user.support? + { colour: "orange", text: "Support beta" } + else + { text: "Beta" } + end + end + private def paginated_title(title, pagy) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7a3e85d89..e71f828be 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -43,7 +43,7 @@ <%= govuk_skip_link %> <%= govuk_header( - classes: "app-header", + classes: govuk_header_classes(current_user), service_url: current_user.nil? ? "/" : "/logs", navigation_classes: "govuk-header__navigation--end", ) do |component| @@ -60,7 +60,7 @@ <%= govuk_phase_banner( classes: "govuk-width-container", - tag: { text: "Beta" }, + tag: govuk_phase_banner_tag(current_user), text: "This is a new service – help us improve it by #{feedback_link}".html_safe, ) %> diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index b5cde06ce..c0bb02fd2 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -6,6 +6,42 @@ RSpec.describe ApplicationHelper do let(:subsection) { form.get_subsection("household_characteristics") } let(:case_log) { FactoryBot.build(:case_log, :in_progress) } let(:pagy) { nil } + let(:current_user) { FactoryBot.create(:user) } + + describe "govuk_header_classes" do + context "with external user" do + it "shows the standard app header" do + expect(govuk_header_classes(current_user)).to eq("app-header") + end + end + + context "with internal support user" do + let(:current_user) { FactoryBot.create(:user, :support) } + + it "shows an orange header" do + expect(govuk_header_classes(current_user)).to eq("app-header app-header--orange") + end + end + end + + describe "govuk_phase_banner_tag" do + context "with external user" do + it "shows the standard phase tag" do + expect(govuk_phase_banner_tag(current_user)).to eq({ text: "Beta" }) + end + end + + context "with support user" do + let(:current_user) { FactoryBot.create(:user, :support) } + + it "shows an orange phase tag" do + expect(govuk_phase_banner_tag(current_user)).to eq({ + colour: "orange", + text: "Support beta", + }) + end + end + end describe "browser_title" do context "with no pagination" do