2023-10-19 12:23:41 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 23:49:49 +08:00
|
|
|
describe "Admin Revamp | Sidebar Navigation", type: :system do
|
2023-11-10 06:47:59 +08:00
|
|
|
fab!(:admin)
|
2024-01-12 12:49:08 +08:00
|
|
|
|
2023-12-18 09:48:25 +08:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-01-12 12:49:08 +08:00
|
|
|
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
|
2024-02-28 09:15:02 +08:00
|
|
|
let(:filter) { PageObjects::Components::Filter.new }
|
2023-10-19 12:23:41 +08:00
|
|
|
|
|
|
|
before do
|
2024-01-09 07:06:27 +08:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-10-19 12:23:41 +08:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2023-12-18 09:48:25 +08:00
|
|
|
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
|
2023-10-19 12:23:41 +08:00
|
|
|
visit("/latest")
|
2024-01-12 12:49:08 +08:00
|
|
|
expect(sidebar).to have_section("community")
|
2023-12-18 09:48:25 +08:00
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to be_visible
|
2024-01-12 12:49:08 +08:00
|
|
|
expect(sidebar).to have_no_section("community")
|
2023-12-18 09:48:25 +08:00
|
|
|
expect(page).to have_no_css(".admin-main-nav")
|
2024-03-07 11:48:16 +08:00
|
|
|
filter.click_back_to_forum
|
2023-12-18 09:48:25 +08:00
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
|
|
|
end
|
|
|
|
|
2024-02-16 12:31:42 +08: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-12 12:49:08 +08: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")
|
2024-03-07 11:48:16 +08:00
|
|
|
filter.click_back_to_forum
|
2024-01-12 12:49:08 +08:00
|
|
|
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 09:37:20 +08:00
|
|
|
context "when the setting is disabled" do
|
2024-01-09 07:06:27 +08:00
|
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
2023-12-21 09:37:20 +08: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 12:23:41 +08:00
|
|
|
end
|
2024-02-28 09:15:02 +08:00
|
|
|
|
|
|
|
it "allows links to be filtered" do
|
|
|
|
visit("/admin")
|
|
|
|
all_links_count = page.all(".sidebar-section-link-content-text").count
|
|
|
|
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(all_links_count)
|
|
|
|
expect(page).to have_no_css(".sidebar-no-results")
|
|
|
|
|
|
|
|
filter.filter("ie")
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(2)
|
|
|
|
expect(links.map(&:text)).to eq(["Preview Summary", "User Fields"])
|
|
|
|
expect(page).to have_no_css(".sidebar-no-results")
|
|
|
|
|
|
|
|
filter.filter("ieeee")
|
|
|
|
expect(page).to have_no_css(".sidebar-section-link-content-text")
|
|
|
|
expect(page).to have_css(".sidebar-no-results")
|
|
|
|
|
|
|
|
filter.clear
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(all_links_count)
|
|
|
|
expect(page).to have_no_css(".sidebar-no-results")
|
2024-03-07 11:48:16 +08:00
|
|
|
expect(page).to have_css(".sidebar-sections__back-to-forum")
|
2024-02-28 09:15:02 +08:00
|
|
|
|
|
|
|
# When match section title, display all links
|
|
|
|
filter.filter("Backups")
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(2)
|
|
|
|
expect(links.map(&:text)).to eq(%w[Backups Logs])
|
|
|
|
end
|
2023-10-19 12:23:41 +08:00
|
|
|
end
|