discourse/spec/system/page_objects/components/d_menu.rb
Martin Brennan 1ce5697430
UX: Add or remove category types with a dropdown (#39477)
The current UX of removing category types ("Remove X type" button
in the relevant tab like Support/Ideas is not ideal, nor
is the way of adding more category types (hunting down the
right setting and enabling it).

This PR solves both problems by adding a multi-select dropdown
to the General tab of the category edit page, which lists all available
category types and allows adding or removing them in one place.

On our hosting, certain category types will be gated by plan
level.
2026-04-30 11:38:50 +10:00

69 lines
1.7 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class DMenu < PageObjects::Components::Base
attr_reader :component
def initialize(trigger_input, identifier = nil)
if trigger_input.is_a?(Capybara::Node::Element)
@component = trigger_input
else
@component = find(trigger_input)
end
@identifier = identifier
end
def expand
raise "DMenu is already expanded" if is_expanded?
component.click
end
def collapse
raise "DMenu is already collapsed" if is_collapsed?
component.click
end
def is_expanded?
component["aria-expanded"] == "true"
end
def is_collapsed?
!is_expanded?
end
def portal_with_identifier_selector
if @identifier.nil?
"#d-menu-portals"
else
"#d-menu-portals [data-identifier=\"#{@identifier}\"]"
end
end
def remove_selected_option(title)
find(".d-multi-select-trigger__selected-item", text: title).click
end
def option(selector, match = nil)
params = {}
params[:match] = match if match
within(portal_with_identifier_selector, visible: false) { find(selector, **params) }
end
def has_option?(selector, text = nil)
params = {}
params[:text] = text if text
within(portal_with_identifier_selector) { has_css?(selector, **params) }
end
def has_no_option?(selector)
within(portal_with_identifier_selector) { has_no_css?(selector) }
end
def has_value?(value)
component.has_text?(value)
end
end
end
end