2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-10-03 17:21:20 +08:00

DEV: Resolve flaky chat preferences spec (#34978)

This commit is contained in:
David Taylor 2025-09-25 13:35:25 +01:00 committed by GitHub
parent 2c84945853
commit 667f525292
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View file

@ -31,11 +31,10 @@ module PageObjects
end

def 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)
end
end
end

View file

@ -357,4 +357,12 @@ module SystemHelpers
def 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
end
end