0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/spec/system/admin_category_management_spec.rb
Martin Brennan d9dfa85e1b
FEATURE: Category management UI for admins (#41218)
Adds a new `/admin/config/category-management` route which shows
the admin filterable lists of each registered category type, as well as
an "All categories" tab which shows all categories regardless of type,
including badges to indicate type.

This makes it a lot easier for admins to find which of their categories
are configured for each type, and jump to the settings for those
categories:

<img width="2898" height="1488" alt="image"
src="https://github.com/user-attachments/assets/8687a18c-6279-4e66-b3ff-e5694e157430"
/>

<img width="2852" height="1376" alt="image"
src="https://github.com/user-attachments/assets/8e9726b5-c268-400b-9764-451c536695c3"
/>

---------

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
2026-07-15 09:17:25 +10:00

62 lines
2 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Admin category management" do
fab!(:admin)
fab!(:public_category) do
Fabricate(
:category,
name: "Alpha Guides",
slug: "alpha-guides",
description: "Documentation and onboarding articles.",
icon: "wrench",
style_type: "icon",
topic_count: 12,
)
end
fab!(:restricted_category) do
Fabricate(
:private_category,
group: Group[:staff],
name: "Beta Staff",
slug: "beta-staff",
description: "Private coordination for staff.",
emoji: "rocket",
style_type: "emoji",
topic_count: 3,
)
end
let(:category_management_page) { PageObjects::Pages::AdminCategoryManagement.new }
before { sign_in(admin) }
it "lets admins review and filter all categories", :aggregate_failures do
category_management_page.visit_all
expect(category_management_page).to have_category_details(
public_category,
description: "Documentation and onboarding articles.",
visibility: I18n.t("admin_js.admin.config.category_management.visibility.public"),
topic_count: 12,
)
expect(category_management_page).to have_category_icon(public_category)
expect(category_management_page).to have_open_settings_link(public_category)
expect(category_management_page).to have_category_details(
restricted_category,
description: "Private coordination for staff.",
visibility: I18n.t("admin_js.admin.config.category_management.visibility.restricted"),
topic_count: 3,
)
expect(category_management_page).to have_category_emoji(restricted_category)
category_management_page.filter_by_name("Alpha")
expect(category_management_page).to have_category(public_category)
expect(category_management_page).to have_no_category(restricted_category)
category_management_page.open_settings(public_category)
expect(page).to have_current_path("#{public_category.slug_url_without_id}/edit/general")
end
end