2023-10-19 14:23:41 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 16:49:49 +01:00
|
|
|
describe "Admin Revamp | Sidebar Navigation", type: :system do
|
2023-11-09 16:47:59 -06:00
|
|
|
fab!(:admin)
|
2024-01-12 14:49:08 +10:00
|
|
|
|
2023-12-18 11:48:25 +10:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-01-12 14:49:08 +10:00
|
|
|
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
|
2024-02-28 12:15:02 +11:00
|
|
|
let(:filter) { PageObjects::Components::Filter.new }
|
2023-10-19 14:23:41 +10:00
|
|
|
|
|
|
|
before do
|
2024-01-09 09:06:27 +10:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-10-19 14:23:41 +10:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2023-12-18 11:48:25 +10:00
|
|
|
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
|
2023-10-19 14:23:41 +10:00
|
|
|
visit("/latest")
|
2024-01-12 14:49:08 +10:00
|
|
|
expect(sidebar).to have_section("community")
|
2023-12-18 11:48:25 +10:00
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to be_visible
|
2024-01-12 14:49:08 +10:00
|
|
|
expect(sidebar).to have_no_section("community")
|
2023-12-18 11:48:25 +10:00
|
|
|
expect(page).to have_no_css(".admin-main-nav")
|
2024-03-07 14:48:16 +11:00
|
|
|
filter.click_back_to_forum
|
2023-12-18 11:48:25 +10:00
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
expect(sidebar).to have_no_section("admin-nav-section-root")
|
|
|
|
end
|
|
|
|
|
2024-02-16 14:31:42 +10: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 14:49:08 +10: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 14:48:16 +11:00
|
|
|
filter.click_back_to_forum
|
2024-01-12 14:49:08 +10: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 11:37:20 +10:00
|
|
|
context "when the setting is disabled" do
|
2024-01-09 09:06:27 +10:00
|
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
2023-12-21 11:37:20 +10: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 14:23:41 +10:00
|
|
|
end
|
2024-02-28 12:15:02 +11: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 14:48:16 +11:00
|
|
|
expect(page).to have_css(".sidebar-sections__back-to-forum")
|
2024-02-28 12:15:02 +11: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 14:23:41 +10:00
|
|
|
end
|