2023-10-19 00:23:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-20 10:49:49 -05:00
|
|
|
describe "Admin Revamp | Sidebar Navigation", type: :system do
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:admin)
|
2024-01-11 23:49:08 -05:00
|
|
|
|
2023-12-17 20:48:25 -05:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-01-11 23:49:08 -05:00
|
|
|
let(:sidebar_dropdown) { PageObjects::Components::SidebarHeaderDropdown.new }
|
2024-02-27 20:15:02 -05:00
|
|
|
let(:filter) { PageObjects::Components::Filter.new }
|
2023-10-19 00:23:41 -04:00
|
|
|
|
|
|
|
before do
|
2024-01-08 18:06:27 -05:00
|
|
|
SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]
|
2023-10-19 00:23:41 -04:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2023-12-17 20:48:25 -05:00
|
|
|
it "shows the sidebar when navigating to an admin route and hides it when leaving" do
|
2023-10-19 00:23:41 -04:00
|
|
|
visit("/latest")
|
2024-03-26 23:42:06 -04:00
|
|
|
expect(sidebar).to have_section("categories")
|
2023-12-17 20:48:25 -05:00
|
|
|
sidebar.click_link_in_section("community", "admin")
|
|
|
|
expect(page).to have_current_path("/admin")
|
|
|
|
expect(sidebar).to be_visible
|
2024-03-26 23:42:06 -04:00
|
|
|
expect(sidebar).to have_no_section("categories")
|
2023-12-17 20:48:25 -05:00
|
|
|
expect(page).to have_no_css(".admin-main-nav")
|
2024-03-06 22:48:16 -05:00
|
|
|
filter.click_back_to_forum
|
2023-12-17 20:48:25 -05:00
|
|
|
expect(page).to have_current_path("/latest")
|
2024-03-26 23:42:06 -04:00
|
|
|
expect(sidebar).to have_no_section("admin-root")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "collapses sections by default" do
|
|
|
|
visit("/admin")
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(2)
|
|
|
|
expect(links.map(&:text)).to eq(["Dashboard", "All Site Settings"])
|
2023-12-17 20:48:25 -05:00
|
|
|
end
|
|
|
|
|
2024-02-15 23:31:42 -05: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-11 23:49:08 -05: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-06 22:48:16 -05:00
|
|
|
filter.click_back_to_forum
|
2024-01-11 23:49:08 -05:00
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
sidebar_dropdown.click
|
2024-03-26 23:42:06 -04:00
|
|
|
expect(sidebar).to have_no_section("admin-root")
|
2024-01-11 23:49:08 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-20 20:37:20 -05:00
|
|
|
context "when the setting is disabled" do
|
2024-01-08 18:06:27 -05:00
|
|
|
before { SiteSetting.admin_sidebar_enabled_groups = "" }
|
2023-12-20 20:37:20 -05: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")
|
2024-03-26 23:42:06 -04:00
|
|
|
expect(sidebar).to have_no_section("admin-root")
|
2023-12-20 20:37:20 -05:00
|
|
|
end
|
2023-10-19 00:23:41 -04:00
|
|
|
end
|
2024-02-27 20:15:02 -05:00
|
|
|
|
|
|
|
it "allows links to be filtered" do
|
|
|
|
visit("/admin")
|
2024-03-26 23:42:06 -04:00
|
|
|
sidebar.toggle_all_sections
|
2024-02-27 20:15:02 -05:00
|
|
|
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)
|
2024-03-12 19:18:08 -04:00
|
|
|
expect(links.map(&:text)).to eq(["User Fields", "Preview Summary"])
|
2024-02-27 20:15:02 -05:00
|
|
|
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-06 22:48:16 -05:00
|
|
|
expect(page).to have_css(".sidebar-sections__back-to-forum")
|
2024-02-27 20:15:02 -05:00
|
|
|
|
|
|
|
# When match section title, display all links
|
2024-03-12 19:18:08 -04:00
|
|
|
filter.filter("Email Sett")
|
2024-02-27 20:15:02 -05:00
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
2024-03-12 19:18:08 -04:00
|
|
|
expect(links.count).to eq(3)
|
|
|
|
expect(links.map(&:text)).to eq(["Appearance", "Preview Summary", "Server Setup"])
|
2024-02-27 20:15:02 -05:00
|
|
|
end
|
2024-03-13 21:28:08 -04:00
|
|
|
|
2024-04-18 20:55:17 -04:00
|
|
|
it "allows further filtering of site settings or users if links do not show results" do
|
|
|
|
visit("/admin")
|
|
|
|
filter.filter("user locale")
|
|
|
|
find(".sidebar-additional-filter-settings").click
|
|
|
|
expect(page).to have_current_path(
|
|
|
|
"/admin/site_settings/category/all_results?filter=user%20locale",
|
|
|
|
)
|
|
|
|
expect(page).to have_content(I18n.t("site_settings.allow_user_locale"))
|
|
|
|
|
|
|
|
filter.filter("log_search_queries")
|
|
|
|
find(".sidebar-additional-filter-settings").click
|
|
|
|
expect(page).to have_current_path(
|
|
|
|
"/admin/site_settings/category/all_results?filter=log_search_queries",
|
|
|
|
)
|
|
|
|
expect(page).to have_content(I18n.t("site_settings.log_search_queries"))
|
|
|
|
|
|
|
|
user_1 = Fabricate(:user, username: "moltisanti", name: "Christopher Moltisanti")
|
|
|
|
user_2 = Fabricate(:user, username: "bevelaqua", name: "Matthew Bevelaqua")
|
|
|
|
|
|
|
|
filter.filter("bevelaqua")
|
|
|
|
find(".sidebar-additional-filter-users").click
|
|
|
|
expect(page).to have_current_path("/admin/users/list/active?username=bevelaqua")
|
|
|
|
within(".users-list-container") { expect(page).to have_content("bevelaqua") }
|
|
|
|
|
|
|
|
filter.filter("moltisanti")
|
|
|
|
find(".sidebar-additional-filter-users").click
|
|
|
|
expect(page).to have_current_path("/admin/users/list/active?username=moltisanti")
|
|
|
|
within(".users-list-container") { expect(page).to have_content("moltisanti") }
|
|
|
|
end
|
|
|
|
|
2024-03-26 23:42:06 -04:00
|
|
|
it "allows sections to be expanded" do
|
|
|
|
visit("/admin")
|
|
|
|
sidebar.toggle_all_sections
|
|
|
|
all_links_count = page.all(".sidebar-section-link-content-text").count
|
|
|
|
sidebar.toggle_all_sections
|
|
|
|
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(2)
|
|
|
|
expect(links.map(&:text)).to eq(["Dashboard", "All Site Settings"])
|
|
|
|
|
|
|
|
sidebar.toggle_all_sections
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(all_links_count)
|
|
|
|
end
|
|
|
|
|
2024-03-13 21:28:08 -04:00
|
|
|
it "accepts hidden keywords like installed plugin names for filter" do
|
|
|
|
Discourse.instance_variable_set(
|
|
|
|
"@plugins",
|
|
|
|
Plugin::Instance.find_all("#{Rails.root}/spec/fixtures/plugins"),
|
|
|
|
)
|
|
|
|
|
|
|
|
visit("/admin")
|
2024-03-26 23:42:06 -04:00
|
|
|
sidebar.toggle_all_sections
|
2024-03-13 21:28:08 -04:00
|
|
|
filter.filter("csp_extension")
|
|
|
|
links = page.all(".sidebar-section-link-content-text")
|
|
|
|
expect(links.count).to eq(1)
|
|
|
|
expect(links.map(&:text)).to eq(["Installed"])
|
|
|
|
end
|
2024-04-08 01:21:24 -04:00
|
|
|
|
|
|
|
it "does not show the button to customize sidebar sections, that is only supported in the main panel" do
|
|
|
|
visit("/")
|
|
|
|
expect(sidebar).to have_add_section_button
|
|
|
|
visit("/admin")
|
|
|
|
expect(sidebar).to have_no_add_section_button
|
|
|
|
end
|
2023-10-19 00:23:41 -04:00
|
|
|
end
|