discourse/spec/system/page_objects/components/d_menu.rb
Yuriy Kurant ae27cac392
UX: enhances messages dropdown with unread count (#33889)
Enhances inbox messages dropdown with unread icon/count per each inbox option.

Dropdown implementation is switched from `select-kit` to `float-kit`.

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-08-01 07:19:04 +08:00

55 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class DMenu < PageObjects::Components::Base
attr_reader :component
def initialize(input)
if input.is_a?(Capybara::Node::Element)
@component = input
else
@component = find(input)
end
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 option(selector, match = nil)
params = {}
params[:match] = match if match
within("#d-menu-portals") { find(selector, **params) }
end
def has_option?(selector, text = nil)
params = {}
params[:text] = text if text
within("#d-menu-portals") { has_css?(selector, **params) }
end
def has_no_option?(selector)
within("#d-menu-portals") { has_no_css?(selector) }
end
def has_value?(value)
component.has_text?(value)
end
end
end
end