discourse/spec/system/page_objects/components/group_selector.rb
Martin Brennan 29b3b2329a
FEATURE: Use dropdown for upcoming change toggle (#36091)
To make things a bit clearer for admins, and to bury the option to
enable changes only for specific groups a bit since we don't think
most sites will do this, this commit changes the upcoming change
toggle to an "Enabled for:" dropdown with the following options:

* No one
* Everyone
* Staff only
* Specific group(s)

We automatically save the staff site setting group in the background
if staff only is selected, and we only save specific groups (and toggle
the
change on) once more than one group is selected.


---------

Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
2025-11-25 11:26:50 +10:00

48 lines
1.6 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
# NOTE: GroupSelector is the only user of the DMultiSelect component at the moment.
# At some point, we might want to make a separate PageObject for DMultiSelect if
# more components start using it.
class GroupSelector < PageObjects::Components::Base
def initialize(context)
@context = context
end
def hidden?
find("#{@context}").has_no_css?(".group-selector")
end
def has_selected_groups?(*group_names)
selected_groups =
find("#{@context} .group-selector")
.all(".d-multi-select-trigger__selected-item")
.map { |item| item[:innerText] }
expect(selected_groups & group_names).to match_array(group_names)
end
def has_no_selected_groups?
find("#{@context} .group-selector").has_no_css?(".d-multi-select-trigger__selected-item")
end
def open
find(@context).find(".group-selector .d-multi-select-trigger__expand-btn").click
expect(page).to have_css(".fk-d-menu.d-multi-select-content")
end
def add_group(group_name)
self.open
find(".dropdown-menu__item.d-multi-select__search-container").fill_in(with: group_name)
find(".dropdown-menu__item.d-multi-select__result[title='#{group_name}']").click
end
def remove_group(group_name)
find(@context)
.find(".group-selector .d-multi-select-trigger__selected-item", text: group_name)
.find(".d-multi-select-trigger__remove-selection-icon")
.click
end
end
end
end