2023-10-19 14:23:41 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 16:49:49 +01:00
|
|
|
describe "Admin Revamp | Sidebar Navigation", type: :system do
|
2023-11-09 16:47:59 -06:00
|
|
|
fab!(:admin)
|
2024-01-12 14:49:08 +10:00
|
|
|
|
2023-12-18 11:48:25 +10:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-01-12 14:49:08 +10:00
|
|
|
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
|
2023-10-19 14:23:41 +10:00
|
|
|
|
|
|
|
before do
|
2024-01-09 09:06:27 +10:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-10-19 14:23:41 +10:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2023-12-18 11:48:25 +10:00
|
|
|
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
|
2023-10-19 14:23:41 +10:00
|
|
|
visit("/latest")
|
2024-01-12 14:49:08 +10:00
|
|
|
expect(sidebar).to have_section("community")
|
2023-12-18 11:48:25 +10:00
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to be_visible
|
2024-01-12 14:49:08 +10:00
|
|
|
expect(sidebar).to have_no_section("community")
|
2023-12-18 11:48:25 +10:00
|
|
|
expect(page).to have_no_css(".admin-main-nav")
|
|
|
|
sidebar.click_link_in_section("admin-nav-section-root", "back_to_forum")
|
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
|
|
|
end
|
|
|
|
|
2024-01-12 14:49:08 +10:00
|
|
|
context "when on mobile" do
|
|
|
|
it "shows the admin sidebar links in the header-dropdown when navigating to an admin route and hides them when leaving",
|
|
|
|
mobile: true do
|
|
|
|
visit("/latest")
|
|
|
|
sidebar_dropdown.click
|
|
|
|
expect(sidebar).to have_section("community")
|
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
sidebar_dropdown.click
|
|
|
|
expect(sidebar).to have_no_section("community")
|
|
|
|
expect(page).to have_no_css(".admin-main-nav")
|
|
|
|
sidebar.click_link_in_section("admin-nav-section-root", "back_to_forum")
|
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
sidebar_dropdown.click
|
|
|
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-21 11:37:20 +10:00
|
|
|
context "when the setting is disabled" do
|
2024-01-09 09:06:27 +10:00
|
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
2023-12-21 11:37:20 +10:00
|
|
|
|
|
|
|
it "does not show the admin sidebar" do
|
|
|
|
visit("/latest")
|
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
|
|
|
end
|
2023-10-19 14:23:41 +10:00
|
|
|
end
|
|
|
|
end
|