discourse/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb
Martin Brennan cd6fd515fe
FIX: Prevent admin sidebar errors in safe mode (#25832)
In safe mode plugins are not loaded, so the plugin admin
routes are not loaded. This was causing errors in the
admin sidebar because we are trying to show links to the plugin
admin routes.

This fixes the issue by just not adding the plugin links if
we are in safe mode.
2024-02-23 17:04:42 +10:00

61 lines
2.3 KiB
Ruby

# frozen_string_literal: true
describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system do
fab!(:admin)
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
before do
chat_system_bootstrap
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
sign_in(admin)
end
it "shows links to enabled plugin admin routes" do
visit("/admin")
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat")
end
it "does not duplicate links to enabled plugin admin routes when showing and hiding sidebar" do
visit("/admin")
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat", count: 1)
find(".header-sidebar-toggle").click
find(".header-sidebar-toggle").click
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat", count: 1)
end
it "does not show plugin links in the admin sidebar in safe mode" do
visit("/safe-mode")
find("#btn-enter-safe-mode").click
expect(sidebar).to have_section_link("Admin", href: "/admin")
sidebar.click_link_in_section("community", "admin")
expect(sidebar).to have_no_section_link("Chat", href: "/admin/plugins/chat")
end
describe "admin sidebar respects separated and combined sidebar modes" do
it "reverts to always (separated) mode after entering and leaving admin section" do
admin.user_option.update!(
chat_separate_sidebar_mode: UserOption.chat_separate_sidebar_modes[:always],
)
visit("/")
expect(sidebar).to have_switch_button("chat")
sidebar.click_link_in_section("community", "admin")
expect(sidebar).to have_no_switch_button("chat")
find("#site-logo").click
expect(sidebar).to have_switch_button("chat")
end
it "reverts to the never (combined) mode after entering and leaving admin section" do
admin.user_option.update!(
chat_separate_sidebar_mode: UserOption.chat_separate_sidebar_modes[:never],
)
visit("/")
expect(sidebar).to have_section("chat-channels")
expect(sidebar).to have_no_switch_button("chat")
sidebar.click_link_in_section("community", "admin")
expect(sidebar).to have_no_section("chat-channels")
find("#site-logo").click
expect(sidebar).to have_section("chat-channels")
end
end
end