mirror of
https://github.com/discourse/discourse.git
synced 2024-12-25 07:33:43 +08:00
40 lines
792 B
Ruby
40 lines
792 B
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)
|
||
|
within("#d-menu-portals") { find(selector) }
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|