2023-10-19 00:23:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 10:49:49 -05:00
|
|
|
describe "Admin Revamp | Sidebar Navigation", type: :system do
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:admin)
|
2024-01-11 23:49:08 -05:00
|
|
|
|
2023-12-17 20:48:25 -05:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-01-11 23:49:08 -05:00
|
|
|
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
|
2023-10-19 00:23:41 -04:00
|
|
|
|
|
|
|
before do
|
2024-01-08 18:06:27 -05:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-10-19 00:23:41 -04:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2023-12-17 20:48:25 -05:00
|
|
|
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
|
2023-10-19 00:23:41 -04:00
|
|
|
visit("/latest")
|
2024-01-11 23:49:08 -05:00
|
|
|
expect(sidebar).to have_section("community")
|
2023-12-17 20:48:25 -05:00
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to be_visible
|
2024-01-11 23:49:08 -05:00
|
|
|
expect(sidebar).to have_no_section("community")
|
2023-12-17 20:48:25 -05: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-02-15 23:31:42 -05:00
|
|
|
it "respects the user homepage preference for the Back to Forum link" do
|
|
|
|
admin.user_option.update!(
|
|
|
|
homepage_id: UserOption::HOMEPAGES.find { |id, value| value == "categories" }.first,
|
|
|
|
)
|
|
|
|
visit("/admin")
|
|
|
|
expect(page).to have_link("Back to Forum", href: "/categories")
|
|
|
|
end
|
|
|
|
|
2024-01-11 23:49:08 -05: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-20 20:37:20 -05:00
|
|
|
context "when the setting is disabled" do
|
2024-01-08 18:06:27 -05:00
|
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
2023-12-20 20:37:20 -05: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 00:23:41 -04:00
|
|
|
end
|
|
|
|
end
|