From: Andy Allan Date: Wed, 21 Dec 2022 16:42:02 +0000 (+0000) Subject: Wait for the button to be disabled, before checking the tooltip behaviour X-Git-Tag: live~1838 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6f471c72c93d67bf086c18e6a3cc24fd882fbb2c?ds=inline;hp=7d80c7747f8d77045da516cafa71282b954d0538 Wait for the button to be disabled, before checking the tooltip behaviour Rather than sleeping for a fixed period, we can use Capybara's built-in ability to wait for elements to be present. Since we're only changing the state of existing elements though, we need to wait for their "disabled" property to be set. Fixes some timing-related problems with the test suite. --- diff --git a/test/system/site_test.rb b/test/system/site_test.rb index 0fa524675..d7b9f279e 100644 --- a/test/system/site_test.rb +++ b/test/system/site_test.rb @@ -71,9 +71,10 @@ class SiteTest < ApplicationSystemTestCase find("h1").hover # un-hover original element visit "#map=10/0/0" + find("#{selector}.disabled") # Ensure that capybara has waited for JS to finish processing + assert_no_selector ".tooltip" find(selector).hover - sleep(0.5) assert_selector ".tooltip", :text => "Zoom in" end end