discourse/spec/system/edit_category_settings_spec.rb
Martin Brennan e7cbdaea81
DEV: Remove ComboBox usage from category forms (#39598)
Instead of using ComboBox, we can use the native
select field type in FormKit. This commit updates
the Appearance, Settings, and Moderations new category
forms.

Also included are a couple of FormKit tweaks:

* DSelect now has special handling for when the value
  arg is null, underfined, or "", resolving it to the
  special NO_VALUE_OPTION under the hood to avoid
  strange rerender issues
* The FormKit select field now accepts a @nonePlaceholderLabel
  arg to override the Select.../None label in the dropdown when
  no value is selected
2026-04-29 09:54:13 +10:00

68 lines
2.2 KiB
Ruby
Vendored

# frozen_string_literal: true
describe "Edit Category Settings" do
fab!(:admin)
fab!(:category)
let(:category_page) { PageObjects::Pages::Category.new }
let(:form) { PageObjects::Components::FormKit.new(".form-kit") }
let(:category_default_view_select_kit) do
PageObjects::Components::SelectKit.new("#category-default-view")
end
before { sign_in(admin) }
describe "default view" do
it "allows selecting hot as the default view" do
category_page.visit_appearance(category)
form.field("default_view").select("hot")
category_page.save_settings
expect(form.field("default_view").value).to eq("hot")
visit "/c/#{category.slug}/#{category.id}"
expect(page).to have_css(".navigation-container .hot.active", text: "Hot")
end
end
describe "topic posting review mode" do
fab!(:group)
let(:dialog) { PageObjects::Components::Dialog.new }
it "allows selecting 'everyone' mode" do
category_page.visit_moderation(category)
category_page.topic_posting_review_mode_chooser.expand
category_page.topic_posting_review_mode_chooser.select_row_by_value("everyone")
category_page.save_settings
category_page.visit_moderation(category)
expect(category_page).to have_topic_posting_review_mode("everyone")
end
it "allows selecting 'everyone_except' mode with groups" do
category_page.visit_moderation(category)
category_page.topic_posting_review_mode_chooser.expand
category_page.topic_posting_review_mode_chooser.select_row_by_value("everyone_except")
category_page.topic_posting_review_mode_chooser.collapse
category_page.save_settings
expect(form.field("topic_posting_review_group_ids")).to have_errors(
I18n.t("js.category.validations.groups_required"),
)
category_page.topic_posting_review_group_chooser.expand
category_page.topic_posting_review_group_chooser.select_row_by_value(group.id)
category_page.topic_posting_review_group_chooser.collapse
category_page.save_settings
category_page.visit_moderation(category)
expect(category_page).to have_topic_posting_review_mode("everyone_except")
expect(category_page).to have_topic_posting_review_groups(group)
end
end
end