mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 20:47:07 +08:00
9bcbfbba43
Some sites are still on the legacy "hamburger dropdown" navigation_menu setting. In this case to avoid confusion, we want to show both the sidebar icon and the header dropdown hamburger when visiting the admin portal. Otherwise, the hamburger switches sides from right to left for admins and takes on different behaviour. The hamburger in this case _only_ shows the main panel, not other sidebar panels like the admin one.
120 lines
4.0 KiB
Ruby
120 lines
4.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Navigation menu states", type: :system, js: true do
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
let!(:sidebar_navigation) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
|
let!(:header_dropdown) { PageObjects::Components::NavigationMenu::HeaderDropdown.new }
|
|
|
|
before { sign_in(current_user) }
|
|
|
|
context "when navigation_menu is 'header dropdown'" do
|
|
before { SiteSetting.navigation_menu = "header dropdown" }
|
|
|
|
it "does not show the sidebar" do
|
|
visit "/"
|
|
expect(sidebar_navigation).to be_not_visible
|
|
end
|
|
|
|
it "opens and closes the hamburger menu from the toggle" do
|
|
visit "/"
|
|
expect(header_dropdown).to be_visible
|
|
header_dropdown.open
|
|
expect(header_dropdown).to have_dropdown_visible
|
|
expect(header_dropdown).to have_sidebar_panel("main")
|
|
expect(header_dropdown).to have_no_sidebar_panel("admin")
|
|
header_dropdown.close
|
|
expect(header_dropdown).to have_no_dropdown_visible
|
|
end
|
|
|
|
context "for admins" do
|
|
fab!(:current_user) { Fabricate(:admin, refresh_auto_groups: true) }
|
|
|
|
it "shows the sidebar and allows toggling it" do
|
|
visit "/admin"
|
|
expect(sidebar_navigation).to be_visible
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_not_visible
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_visible
|
|
expect(find(sidebar_navigation.header_toggle_css)).to have_css(".d-icon-discourse-sidebar")
|
|
end
|
|
|
|
it "shows the hamburger menu and allows toggling it, which shows the MAIN_PANEL onls" do
|
|
visit "/admin"
|
|
expect(header_dropdown).to be_visible
|
|
header_dropdown.open
|
|
expect(header_dropdown).to have_dropdown_visible
|
|
expect(header_dropdown).to have_sidebar_panel("main")
|
|
expect(header_dropdown).to have_no_sidebar_panel("admin")
|
|
header_dropdown.close
|
|
expect(header_dropdown).to have_no_dropdown_visible
|
|
end
|
|
|
|
context "when the user is not in admin_sidebar_enabled_groups" do
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
|
|
|
it "does not show the sidebar" do
|
|
visit "/admin"
|
|
expect(sidebar_navigation).to be_not_visible
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
context "when navigation_menu is 'sidebar'" do
|
|
before { SiteSetting.navigation_menu = "sidebar" }
|
|
|
|
it "shows the sidebar" do
|
|
visit "/"
|
|
expect(sidebar_navigation).to be_visible
|
|
end
|
|
|
|
it "does not show the hamburger menu" do
|
|
visit "/"
|
|
expect(header_dropdown).to be_not_visible
|
|
end
|
|
|
|
it "opens and closes the sidebar from the toggle" do
|
|
visit "/"
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_not_visible
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_visible
|
|
end
|
|
|
|
context "for admins" do
|
|
fab!(:current_user) { Fabricate(:admin, refresh_auto_groups: true) }
|
|
|
|
it "shows the sidebar and allows toggling it" do
|
|
visit "/admin"
|
|
expect(sidebar_navigation).to be_visible
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_not_visible
|
|
sidebar_navigation.click_header_toggle
|
|
expect(sidebar_navigation).to be_visible
|
|
expect(find(sidebar_navigation.header_toggle_css)).to have_css(".d-icon-bars")
|
|
end
|
|
|
|
it "does not show the hamburger menu" do
|
|
visit "/admin"
|
|
expect(header_dropdown).to be_not_visible
|
|
end
|
|
|
|
context "when the user is not in admin_sidebar_enabled_groups" do
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
|
|
|
it "shows the MAIN_PANEL of the sidebar" do
|
|
visit "/admin"
|
|
expect(sidebar_navigation).to have_no_section("admin-root")
|
|
expect(sidebar_navigation).to have_section("community")
|
|
end
|
|
|
|
it "does show the sidebar toggle" do
|
|
visit "/admin"
|
|
expect(page).to have_css(sidebar_navigation.header_toggle_css)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|