A platform for community discussion. Free, open, simple.
DEV: Resolve flaky chat preferences spec (#34978)
David Taylor667f5252922b
diff --git a/plugins/chat/spec/system/page_objects/pages/user_preferences_chat.rb b/plugins/chat/spec/system/page_objects/pages/user_preferences_chat.rbindex 6dfb20d3813..962900b8e2a 100644--- a/plugins/chat/spec/system/page_objects/pages/user_preferences_chat.rb+++ b/plugins/chat/spec/system/page_objects/pages/user_preferences_chat.rb@@ -31,11 +31,10 @@ module PageObjectsenddef save_changes_and_refresh- page.find(".save-changes").click- # reloading the page happens in JS on save but capybara doesnt wait for it- # which can mess up navigating away too soon in tests- # so doing a manual refresh here to mimic- page.refresh+ button_element = page.find(".save-changes")+ button_element.click++ wait_until_hidden(button_element)endendenddiff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rbindex e56f7f05726..478c47110ec 100644--- a/spec/support/system_helpers.rb+++ b/spec/support/system_helpers.rb@@ -357,4 +357,12 @@ module SystemHelpersdef wait_for_timeout(ms = 100)page.driver.with_playwright_page { |pw_page| pw_page.wait_for_timeout(ms) }end++ def wait_until_hidden(element)+ element.with_playwright_element_handle do |playwright_element|+ playwright_element.wait_for_element_state("hidden")+ rescue Playwright::Error => e+ raise e unless e.message.match?(/Element is not attached to the DOM/)+ end+ endend