2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 23:54:20 +08:00
discourse/spec/system/admin_site_setting_topic_chooser_spec.rb
Ted Johansson 540dc392cd
FEATURE: Add new configurable moderation guide (#36287)
This PR adds a new site setting for configuring a community moderation topic that will be linked from the reviewable sidebar.

It involves adding a new site setting type "topic" which uses the TopicChooser component in the front-end.
2025-12-01 10:30:32 +08:00

42 lines
1.4 KiB
Ruby

# frozen_string_literal: true
describe "Admin Site Setting Topic Selector Component", type: :system do
let(:settings_page) { PageObjects::Pages::AdminSiteSettings.new }
let(:banner) { PageObjects::Components::AdminChangesBanner.new }
fab!(:admin)
fab!(:topic) { Fabricate(:topic, title: "Moderator guide", fancy_title: "Moderator guide") }
fab!(:post) { Fabricate(:post, topic: topic) }
before { sign_in(admin) }
it "can configure the setting with a topic" do
settings_page.visit
settings_page.type_in_search("moderator guide topic")
expect(settings_page).to have_n_results(1)
settings_page.find(".topic-chooser > summary").click
expect(settings_page).to have_css("input.filter-input")
settings_page.find("input.filter-input").fill_in(with: topic.id)
settings_page.find(".topic-row").click
expect(settings_page).to have_css(".selected-name", text: "Moderator guide")
banner.click_save
expect(settings_page).to have_overridden_topic_setting("moderator_guide_topic", value: topic.id)
end
it "can load a topics title when loading the component" do
SiteSetting.moderator_guide_topic = topic.id
settings_page.visit
settings_page.type_in_search("moderator guide topic")
expect(settings_page).to have_n_results(1)
expect(settings_page).to have_css(".selected-name", text: "Moderator guide")
end
end