Skip to content

A platform for community discussion. Free, open, simple.

DEV: correct flaky interface selector spec (#36823)

Sam881d84f49b92
diff --git a/spec/system/page_objects/components/interface_color_selector.rb b/spec/system/page_objects/components/interface_color_selector.rb
index b987026e197..b87773e3608 100644
--- a/spec/system/page_objects/components/interface_color_selector.rb
+++ b/spec/system/page_objects/components/interface_color_selector.rb
@@ -6,33 +6,40 @@ module PageObjects
attr_reader :container_selector
SELECTOR = ".interface-color-selector"
+ TRIGGER_SELECTOR = ".interface-color-selector-trigger"
+ CONTENT_SELECTOR = ".interface-color-selector-content"
def initialize(container_selector)
@container_selector = container_selector
end
def available?
- find(container_selector).has_css?(SELECTOR)
+ find(container_selector).has_css?(TRIGGER_SELECTOR)
end
def not_available?
- find(container_selector).has_no_css?(SELECTOR)
+ find(container_selector).has_no_css?(TRIGGER_SELECTOR)
end
def expand
- find(container_selector).find(SELECTOR).click
+ # Ensure the menu is closed before we try to expand it.
+ # This prevents flakiness if the menu is still closing from a previous action.
+ page.has_no_css?(CONTENT_SELECTOR)
+
+ find(container_selector).find(TRIGGER_SELECTOR).click
+ find(CONTENT_SELECTOR)
end
def has_light_as_current_mode?
- has_css?(SELECTOR + "[data-current-mode='light']")
+ has_css?(TRIGGER_SELECTOR + "[data-current-mode='light']")
end
def has_dark_as_current_mode?
- has_css?(SELECTOR + "[data-current-mode='dark']")
+ has_css?(TRIGGER_SELECTOR + "[data-current-mode='dark']")
end
def has_auto_as_current_mode?
- has_css?(SELECTOR + "[data-current-mode='auto']")
+ has_css?(TRIGGER_SELECTOR + "[data-current-mode='auto']")
end
def light_option