discourse/spec/system/page_objects/components/d_toggle_switch.rb
Osama Sayegh 91e33664ae
FIX: Improve automation on/off toggle (#33482)
This commit replaces the "enabled" checkbox on the automation page with a
toggle at the top of the automation page. We've made this change to make
the automation edit page consistent with the automations list page where
a toggle is used for turning on/off automations, and also consistent
with the rest of admin pages where we've been using toggle for
controlling the enable/disable state.

Internal topic: t/153523.
2025-08-14 10:16:20 +03:00

41 lines
1 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class DToggleSwitch < PageObjects::Components::Base
attr_reader :context
def initialize(context)
@context = context
end
def label_component
find(context, visible: :all).ancestor("label.d-toggle-switch__label")
end
def toggle
label_component.click
end
def checked?
label_component.has_css?(".d-toggle-switch__checkbox[aria-checked=\"true\"]", visible: :all)
end
def unchecked?
label_component.has_css?(
".d-toggle-switch__checkbox[aria-checked=\"false\"]",
visible: :all,
)
end
def disabled?
label_component.has_css?(".d-toggle-switch__checkbox[disabled]", visible: :all)
end
def enabled?
label_component.has_no_css?(".d-toggle-switch__checkbox[disabled]", visible: :all) &&
label_component.has_css?(".d-toggle-switch__checkbox", visible: :all)
end
end
end
end