2023-12-21 09:37:20 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system do
|
|
|
|
fab!(:admin)
|
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-03-20 07:20:06 +08:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2023-12-21 09:37:20 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
chat_system_bootstrap
|
2024-01-09 07:06:27 +08:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-12-21 09:37:20 +08:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows links to enabled plugin admin routes" do
|
|
|
|
visit("/admin")
|
2024-03-27 11:42:06 +08:00
|
|
|
sidebar.toggle_all_sections
|
2023-12-21 09:37:20 +08:00
|
|
|
expect(sidebar).to have_section_link("Chat", href: "/admin/plugins/chat")
|
|
|
|
end
|
2024-02-21 10:58:31 +08:00
|
|
|
|
|
|
|
it "does not duplicate links to enabled plugin admin routes when showing and hiding sidebar" do
|
|
|
|
visit("/admin")
|
2024-03-27 11:42:06 +08:00
|
|
|
sidebar.toggle_all_sections
|
2024-02-21 10:58:31 +08:00
|
|
|
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
|
2024-02-21 12:44:09 +08:00
|
|
|
|
2024-02-23 15:04:42 +08:00
|
|
|
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
|
|
|
|
|
2024-02-21 12:44:09 +08:00
|
|
|
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
|
2024-03-20 07:20:06 +08:00
|
|
|
|
|
|
|
it "keeps the admin sidebar open instead of switching to the main panel when toggling the drawer" do
|
|
|
|
membership =
|
|
|
|
Fabricate(
|
|
|
|
:user_chat_channel_membership,
|
|
|
|
user: admin,
|
|
|
|
chat_channel: Fabricate(:chat_channel),
|
|
|
|
)
|
|
|
|
admin.upsert_custom_fields(::Chat::LAST_CHAT_CHANNEL_ID => membership.chat_channel.id)
|
|
|
|
chat_page.prefers_full_page
|
|
|
|
visit("/admin")
|
2024-03-27 11:42:06 +08:00
|
|
|
expect(sidebar).to have_section("admin-root")
|
2024-03-20 07:20:06 +08:00
|
|
|
chat_page.open_from_header
|
2024-03-27 11:42:06 +08:00
|
|
|
expect(sidebar).to have_no_section("admin-root")
|
2024-03-20 07:20:06 +08:00
|
|
|
chat_page.minimize_full_page
|
|
|
|
expect(chat_page).to have_drawer
|
2024-03-27 11:42:06 +08:00
|
|
|
expect(sidebar).to have_section("admin-root")
|
2024-03-20 07:20:06 +08:00
|
|
|
end
|
2024-02-21 12:44:09 +08:00
|
|
|
end
|
2023-12-21 09:37:20 +08:00
|
|
|
end
|