From 36e3900e1e7c079535acd5f060bd2fd34f61b601 Mon Sep 17 00:00:00 2001 From: farahTW Date: Tue, 17 Oct 2023 11:23:53 +0100 Subject: [PATCH 1/4] Transition main navigation to design system. This commit includes below changes: -Duplicated existing header partial view to legacy. -Created new header partial with design system logic for main navigation. -Added new method in base controller to handle toggle between legacy and new header views. -Updated admin and design_system views with new header partial view render. -Added view tests to BaseController to verify new header renders for design system permissions. --- app/controllers/admin/base_controller.rb | 5 ++ app/views/layouts/admin.html.erb | 2 +- app/views/layouts/design_system.html.erb | 12 ++- app/views/shared/_header.html.erb | 83 +++++++---------- app/views/shared/_legacy_header.html.erb | 88 +++++++++++++++++++ test/functional/admin/base_controller_test.rb | 24 +++++ 6 files changed, 159 insertions(+), 55 deletions(-) create mode 100644 app/views/shared/_legacy_header.html.erb create mode 100644 test/functional/admin/base_controller_test.rb diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 39fcd09a483..90d8ab1e69b 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -53,6 +53,11 @@ def render_design_system(design_system_view, legacy_view) end end + def show_new_header? + current_user.can_preview_design_system? + end + helper_method :show_new_header? + private def new_design_system? diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 28ffc2227f5..8b944d73f77 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -21,7 +21,7 @@ <% end %> <% content_for :navbar do %> - <%= render "shared/header", admin_template: true %> + <%= render "shared/legacy_header", admin_template: true %> <% if t('admin.whats_new.show_banner') %>
"> diff --git a/app/views/layouts/design_system.html.erb b/app/views/layouts/design_system.html.erb index 0705bc97580..d6278d8a789 100644 --- a/app/views/layouts/design_system.html.erb +++ b/app/views/layouts/design_system.html.erb @@ -26,11 +26,15 @@ <%= render "govuk_publishing_components/components/skip_link" %> -
- + <% end %>
<%= render "shared/phase_banner", { diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 84ca8de9967..4a574348ebd 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -1,55 +1,39 @@ -<% environment_style = GovukAdminTemplate.environment_style %> -<% environment_label = GovukAdminTemplate.environment_label %> <% environment = GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment %> <% admin_template ||= false %> - diff --git a/app/views/shared/_legacy_header.html.erb b/app/views/shared/_legacy_header.html.erb new file mode 100644 index 00000000000..84ca8de9967 --- /dev/null +++ b/app/views/shared/_legacy_header.html.erb @@ -0,0 +1,88 @@ +<% environment_style = GovukAdminTemplate.environment_style %> +<% environment_label = GovukAdminTemplate.environment_label %> +<% environment = GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment %> +<% admin_template ||= false %> + + diff --git a/test/functional/admin/base_controller_test.rb b/test/functional/admin/base_controller_test.rb new file mode 100644 index 00000000000..df2bb0fb605 --- /dev/null +++ b/test/functional/admin/base_controller_test.rb @@ -0,0 +1,24 @@ +require "test_helper" + +class Admin::BaseControllerTest < ActionController::TestCase + setup do + login_as_preview_design_system_user :gds_editor + end + + view_test "should render new header component if login as a design system user" do + @controller = Admin::DashboardController.new + get :index + + assert_select ".gem-c-layout-header__logo", text: /Whitehall Publisher/ + assert_select ".govuk-header__navigation-item", text: "Dashboard" + end + + view_test "should render legacy header component if login as a non design system user" do + login_as :gds_editor + @controller = Admin::DashboardController.new + get :index + + assert_select ".govuk-header__navigation-item", false + assert_select ".nav.navbar-nav", text: /Dashboard/ + end +end From 6bef557dbf2b107df214eccc3635c3b752d4393d Mon Sep 17 00:00:00 2001 From: Mark Taylor <138604938+mtaylorgds@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:58:44 +0100 Subject: [PATCH 2/4] Transition sub nav bar to design system Updates to use the `NewDocumentController` instead of the `DashboardController`, since the `DashboardController` has a dependency on a signed-in user. Moves the login line from setup to each test, since different tests have different requirements. --- app/helpers/admin/sub_nav_helper.rb | 9 ++ app/views/shared/_header.html.erb | 116 +++++++------- test/functional/admin/base_controller_test.rb | 146 +++++++++++++++++- 3 files changed, 201 insertions(+), 70 deletions(-) create mode 100644 app/helpers/admin/sub_nav_helper.rb diff --git a/app/helpers/admin/sub_nav_helper.rb b/app/helpers/admin/sub_nav_helper.rb new file mode 100644 index 00000000000..b1fd84062ec --- /dev/null +++ b/app/helpers/admin/sub_nav_helper.rb @@ -0,0 +1,9 @@ +module Admin::SubNavHelper + def sub_nav_item(name, path) + { + label: name, + href: path, + current: request.path.start_with?(path), + } + end +end diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 4a574348ebd..94596a49550 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -1,71 +1,61 @@ <% environment = GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment %> <% admin_template ||= false %> +<% organisation = current_user&.organisation %> - <%= render "govuk_publishing_components/components/layout_header", { - product_name: "Whitehall Publisher", - environment: environment, - navigation_items: [ - { - text: "Dashboard", - href: admin_root_path, - }, - { - text: "View website", - href: Whitehall.public_root, - }, - { - text: "Switch app", - href: Plek.external_url_for("signon"), - }, +<%= render "govuk_publishing_components/components/layout_header", { + product_name: "Whitehall Publisher", + environment: environment, + navigation_items: [ + { + text: "Dashboard", + href: admin_root_path, + }, + { + text: "View website", + href: Whitehall.public_root, + }, + { + text: "Switch app", + href: Plek.external_url_for("signon"), + }, + *( + if user_signed_in? + [{ + text: current_user.name, + href: admin_user_path(current_user), + }, + { + text: "Logout", + href: "/auth/gds/sign_out", + }] + end), + { + text: "All users", + href: admin_users_path, + }, + ], +} %> + +
+ <%= render "components/sub_navigation", { + items: [ + sub_nav_item("New document", admin_new_document_path), + sub_nav_item("Documents", admin_editions_path), + sub_nav_item("Statistics announcements", admin_statistics_announcements_path), *( - if user_signed_in? - [{ - text: current_user.name, - href: admin_user_path(current_user), - }, - { - text: "Logout", - href: "/auth/gds/sign_out", - }] + if user_signed_in? && organisation + [ + sub_nav_item("Featured documents", features_admin_organisation_path(organisation, locale: nil)), + sub_nav_item("Corporate information", admin_organisation_corporate_information_pages_path(organisation)), + ] end), - { - text: "All users", - href: admin_users_path, - }, + sub_nav_item("More", admin_more_path), ], } %> +
-
- -
- <% if admin_template %> -
- <%= render partial: "shared/notices" %> -
- <% end %> +<% if admin_template %> +
+ <%= render partial: "shared/notices" %> +
+<% end %> diff --git a/test/functional/admin/base_controller_test.rb b/test/functional/admin/base_controller_test.rb index df2bb0fb605..c02b654f981 100644 --- a/test/functional/admin/base_controller_test.rb +++ b/test/functional/admin/base_controller_test.rb @@ -1,24 +1,156 @@ require "test_helper" class Admin::BaseControllerTest < ActionController::TestCase - setup do - login_as_preview_design_system_user :gds_editor - end + include GdsApi::TestHelpers::PublishingApi + + view_test "renders new header component if login as a design system user" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::NewDocumentController.new - view_test "should render new header component if login as a design system user" do - @controller = Admin::DashboardController.new get :index assert_select ".gem-c-layout-header__logo", text: /Whitehall Publisher/ assert_select ".govuk-header__navigation-item", text: "Dashboard" end - view_test "should render legacy header component if login as a non design system user" do + view_test "renders new sub-navigation header component if login as a design system user" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::NewDocumentController.new + + get :index + + assert_select ".app-c-sub-navigation", count: 1 + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/new-document\"]", text: "New document" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/editions\"]", text: "Documents" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/statistics_announcements\"]", text: "Statistics announcements" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/organisations/my-test-org/features\"]", text: "Featured documents" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/organisations/my-test-org/corporate_information_pages\"]", text: "Corporate information" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/more\"]", text: "More" + end + + view_test "highlights the 'New documents' tab when it is the currently selected tab" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::NewDocumentController.new + + get :index + + assert_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/organisations/my-test-org/features") + assert_not_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/more") + end + + view_test "highlights the 'Documents' tab when it is the currently selected tab" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::EditionsController.new + + get :index, params: { type: 1 } + + assert_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/organisations/my-test-org/features") + assert_not_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/more") + end + + view_test "highlights the 'Statistics announcements' tab when it is the currently selected tab" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::StatisticsAnnouncementsController.new + + get :index + + assert_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/organisations/my-test-org/features") + assert_not_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/more") + end + + view_test "highlights the 'Features' tab when it is the currently selected tab" do + my_test_org = create(:organisation, name: "my-test-org") + login_as_preview_design_system_user :gds_editor, my_test_org + @controller = Admin::OrganisationsController.new + + get :features, params: { id: my_test_org } + + assert_current_item("/government/admin/organisations/my-test-org/features") + assert_not_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/more") + end + + view_test "highlights the 'Corporate information pages' tab when it is the currently selected tab" do + my_test_org = create(:organisation, name: "my-test-org") + login_as_preview_design_system_user :gds_editor, my_test_org + @controller = Admin::CorporateInformationPagesController.new + + get :index, params: { organisation_id: my_test_org } + + assert_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/organisations/my-test-org/features") + assert_not_current_item("/government/admin/more") + end + + view_test "highlights the 'More' tab when it is the currently selected tab" do + login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") + @controller = Admin::MoreController.new + + get :index + + assert_current_item("/government/admin/more") + assert_not_current_item("/government/admin/new-document") + assert_not_current_item("/government/admin/editions") + assert_not_current_item("/government/admin/statistics_announcements") + assert_not_current_item("/government/admin/organisations/my-test-org/corporate_information_pages") + assert_not_current_item("/government/admin/organisations/my-test-org/features") + end + + view_test "only renders non-organisation header links if not logged in" do + # It's not possible, at the moment, to show the new design system layout if no user is signed in, + # but once we remove the legacy layout, the design system will be the default layout. In order to + # test this for now we stub some BaseController methods—this stubbing won't be necessary once the + # design system transition has been completed. + Admin::BaseController.any_instance.stubs(:show_new_header?).returns(true) + Admin::BaseController.any_instance.stubs(:preview_design_system?).returns(true) + @controller = Admin::NewDocumentController.new + + get :index + + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/organisations/my-test-org/features\"]", false + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/organisations/my-test-org/corporate_information_pages\"]", false + + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/new-document\"]" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/editions\"]" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/statistics_announcements\"]" + assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/more\"]" + end + + view_test "renders legacy header component if login as a non design system user" do login_as :gds_editor - @controller = Admin::DashboardController.new + @controller = Admin::NewDocumentController.new + get :index assert_select ".govuk-header__navigation-item", false assert_select ".nav.navbar-nav", text: /Dashboard/ end + +private + + def assert_not_current_item(path) + assert_select ".app-c-sub-navigation__list-item--current a[href=\"#{path}\"]", false + end + + def assert_current_item(path) + assert_select ".app-c-sub-navigation__list-item--current a[href=\"#{path}\"]" + end end From 41bb0aef7ba5b1aa8acc534327972f5906416778 Mon Sep 17 00:00:00 2001 From: farahTW Date: Fri, 27 Oct 2023 15:12:14 +0100 Subject: [PATCH 3/4] Modified sub-navigation component to make styling generic This commit removes govuk grid div styles which seems not required. --- app/views/components/_sub_navigation.html.erb | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/views/components/_sub_navigation.html.erb b/app/views/components/_sub_navigation.html.erb index 6eef58d4ba3..b9adf185563 100644 --- a/app/views/components/_sub_navigation.html.erb +++ b/app/views/components/_sub_navigation.html.erb @@ -1,20 +1,16 @@ <% items ||= [] %> -<%= tag.div class: "govuk-grid-row app-c-sub-navigation" do %> - <%= tag.div class: "govuk-grid-column-full" do %> - <%= tag.nav role: "navigation", aria: { label: "Sub Navigation" } do %> - <%= tag.ul class: "app-c-sub-navigation__list" do %> - <% items.each do |item| %> - <% - item_classes = %w( app-c-sub-navigation__list-item ) - item_classes << "app-c-sub-navigation__list-item--current" if item[:current] - item_aria_attributes = { current: "page" } if item[:current] - %> - <%= tag.li class: item_classes do %> - <%= link_to item[:label], item[:href], class: "govuk-link govuk-link--no-visited-state govuk-link--no-underline app-c-sub-navigation__list-item-link", data: item[:data_attributes], aria: item_aria_attributes %> - <% end %> - <% end %> +<%= tag.nav class: "app-c-sub-navigation", role: "navigation", aria: { label: "Sub Navigation" } do %> + <%= tag.ul class: "app-c-sub-navigation__list" do %> + <% items.each do |item| %> + <% + item_classes = %w( app-c-sub-navigation__list-item ) + item_classes << "app-c-sub-navigation__list-item--current" if item[:current] + item_aria_attributes = { current: "page" } if item[:current] + %> + <%= tag.li class: item_classes do %> + <%= link_to item[:label], item[:href], class: "govuk-link govuk-link--no-visited-state govuk-link--no-underline app-c-sub-navigation__list-item-link", data: item[:data_attributes], aria: item_aria_attributes %> <% end %> <% end %> <% end %> From 8d8a9c5f757a3bcd8dbbc77e3763bc3c01cc954c Mon Sep 17 00:00:00 2001 From: farahTW Date: Wed, 1 Nov 2023 16:28:00 +0000 Subject: [PATCH 4/4] Design changes for main header navigation. This commit includes: -Update main navigation to show active tabs highlighted. -Rename the sub-nav helper to header_helper to keep generic. -Added test to base controller. --- app/helpers/admin/header_helper.rb | 17 ++++++ app/helpers/admin/sub_nav_helper.rb | 9 ---- app/views/shared/_header.html.erb | 25 ++++----- test/functional/admin/base_controller_test.rb | 53 ++++++++++++++++--- 4 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 app/helpers/admin/header_helper.rb delete mode 100644 app/helpers/admin/sub_nav_helper.rb diff --git a/app/helpers/admin/header_helper.rb b/app/helpers/admin/header_helper.rb new file mode 100644 index 00000000000..a4603e9a5d5 --- /dev/null +++ b/app/helpers/admin/header_helper.rb @@ -0,0 +1,17 @@ +module Admin::HeaderHelper + def sub_nav_item(name, path) + { + label: name, + href: path, + current: request.path.start_with?(path), + } + end + + def main_nav_item(name, path) + { + text: name, + href: path, + active: request.path.end_with?(path), + } + end +end diff --git a/app/helpers/admin/sub_nav_helper.rb b/app/helpers/admin/sub_nav_helper.rb deleted file mode 100644 index b1fd84062ec..00000000000 --- a/app/helpers/admin/sub_nav_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Admin::SubNavHelper - def sub_nav_item(name, path) - { - label: name, - href: path, - current: request.path.start_with?(path), - } - end -end diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index 94596a49550..915f51000f3 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -1,15 +1,13 @@ <% environment = GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment %> <% admin_template ||= false %> <% organisation = current_user&.organisation %> +<% user = current_user %> <%= render "govuk_publishing_components/components/layout_header", { product_name: "Whitehall Publisher", environment: environment, navigation_items: [ - { - text: "Dashboard", - href: admin_root_path, - }, + main_nav_item("Dashboard", admin_root_path), { text: "View website", href: Whitehall.public_root, @@ -20,19 +18,14 @@ }, *( if user_signed_in? - [{ - text: current_user.name, - href: admin_user_path(current_user), - }, - { - text: "Logout", - href: "/auth/gds/sign_out", - }] + [ + main_nav_item(user.name, admin_user_path(user)), + { + text: "Logout", + href: "/auth/gds/sign_out", + }] end), - { - text: "All users", - href: admin_users_path, - }, + main_nav_item("All users", admin_users_path), ], } %> diff --git a/test/functional/admin/base_controller_test.rb b/test/functional/admin/base_controller_test.rb index c02b654f981..9335502a963 100644 --- a/test/functional/admin/base_controller_test.rb +++ b/test/functional/admin/base_controller_test.rb @@ -13,6 +13,39 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_select ".govuk-header__navigation-item", text: "Dashboard" end + view_test "highlights the 'Dashboard' tab when it is the currently selected tab- Main navigation" do + login_as_preview_design_system_user :gds_editor + @controller = Admin::DashboardController.new + + get :index + + assert_active_item("/government/admin") + assert_not_active_item("/government/admin/users") + assert_not_active_item("/government/admin/users/1") + end + + view_test "highlights the 'All users' tab when it is the currently selected tab- Main navigation" do + login_as_preview_design_system_user :gds_editor + @controller = Admin::UsersController.new + + get :index + + assert_active_item("/government/admin/users") + assert_not_active_item("/government/admin") + assert_not_active_item("/government/admin/users/1") + end + + view_test "highlights the current user name tab when it is the currently selected tab-Main navigation" do + user = login_as_preview_design_system_user :gds_editor + @controller = Admin::UsersController.new + + get :show, params: { id: user.id } + + assert_active_item("/government/admin/users/#{user.id}") + assert_not_active_item("/government/admin") + assert_not_active_item("/government/admin/users") + end + view_test "renders new sub-navigation header component if login as a design system user" do login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") @controller = Admin::NewDocumentController.new @@ -28,7 +61,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_select ".app-c-sub-navigation__list .app-c-sub-navigation__list-item a[href=\"/government/admin/more\"]", text: "More" end - view_test "highlights the 'New documents' tab when it is the currently selected tab" do + view_test "highlights the 'New documents' tab when it is the currently selected tab- Sub-navigation" do login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") @controller = Admin::NewDocumentController.new @@ -42,7 +75,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_not_current_item("/government/admin/more") end - view_test "highlights the 'Documents' tab when it is the currently selected tab" do + view_test "highlights the 'Documents' tab when it is the currently selected tab- Sub-navigation" do login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") @controller = Admin::EditionsController.new @@ -56,7 +89,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_not_current_item("/government/admin/more") end - view_test "highlights the 'Statistics announcements' tab when it is the currently selected tab" do + view_test "highlights the 'Statistics announcements' tab when it is the currently selected tab- Sub-navigation" do login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") @controller = Admin::StatisticsAnnouncementsController.new @@ -70,7 +103,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_not_current_item("/government/admin/more") end - view_test "highlights the 'Features' tab when it is the currently selected tab" do + view_test "highlights the 'Features' tab when it is the currently selected tab- Sub-navigation" do my_test_org = create(:organisation, name: "my-test-org") login_as_preview_design_system_user :gds_editor, my_test_org @controller = Admin::OrganisationsController.new @@ -85,7 +118,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_not_current_item("/government/admin/more") end - view_test "highlights the 'Corporate information pages' tab when it is the currently selected tab" do + view_test "highlights the 'Corporate information pages' tab when it is the currently selected tab- Sub-navigation" do my_test_org = create(:organisation, name: "my-test-org") login_as_preview_design_system_user :gds_editor, my_test_org @controller = Admin::CorporateInformationPagesController.new @@ -100,7 +133,7 @@ class Admin::BaseControllerTest < ActionController::TestCase assert_not_current_item("/government/admin/more") end - view_test "highlights the 'More' tab when it is the currently selected tab" do + view_test "highlights the 'More' tab when it is the currently selected tab- Sub-navigation" do login_as_preview_design_system_user :gds_editor, create(:organisation, name: "my-test-org") @controller = Admin::MoreController.new @@ -153,4 +186,12 @@ def assert_not_current_item(path) def assert_current_item(path) assert_select ".app-c-sub-navigation__list-item--current a[href=\"#{path}\"]" end + + def assert_not_active_item(path) + assert_select ".govuk-header__navigation-item--active a[href=\"#{path}\"]", false + end + + def assert_active_item(path) + assert_select ".govuk-header__navigation-item--active a[href=\"#{path}\"]" + end end