From 25c971ed00664bb24d53a946590c88cb7bf5c70d Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Fri, 4 Mar 2022 13:21:07 +0100 Subject: [PATCH] Maintenance: Stabilize Selenium tests by improving the wait_for_empty_ajax_queue logic. --- spec/support/capybara/browser_test_helper.rb | 2 +- test/browser/abb_one_group_test.rb | 2 ++ test/browser_test_helper.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/support/capybara/browser_test_helper.rb b/spec/support/capybara/browser_test_helper.rb index dac2f23d2..e52e21011 100644 --- a/spec/support/capybara/browser_test_helper.rb +++ b/spec/support/capybara/browser_test_helper.rb @@ -90,7 +90,7 @@ module BrowserTestHelper end wait(5, interval: 0.1).until_constant do - page.evaluate_script('App.Ajax.queue().length').zero? && page.evaluate_script('Object.keys(App.FormHandlerCoreWorkflow.getRequests()).length').zero? + page.evaluate_script('App.Ajax.queue().length === 0 && $.active === 0 && Object.keys(App.FormHandlerCoreWorkflow.getRequests()).length === 0').present? end rescue nil diff --git a/test/browser/abb_one_group_test.rb b/test/browser/abb_one_group_test.rb index a24addd58..57ec06858 100644 --- a/test/browser/abb_one_group_test.rb +++ b/test/browser/abb_one_group_test.rb @@ -62,6 +62,7 @@ class AgentTicketActionLevel0Test < TestCase click( css: '.modal button.btn.btn--primary', fast: true, + ajax: false, ) watch_for( css: 'body div.modal', @@ -98,6 +99,7 @@ class AgentTicketActionLevel0Test < TestCase click( css: '.modal button.btn.btn--primary', fast: true, + ajax: false, ) watch_for( css: 'body div.modal', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 2ceff4b36..e69e2bb27 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -4881,7 +4881,7 @@ wait untill text in selector disabppears sleep 0.5 break if instance.execute_script('return typeof(App) === "undefined"') - break if instance.execute_script('return App.Ajax.queue().length').zero? && instance.execute_script('return Object.keys(App.FormHandlerCoreWorkflow.getRequests()).length').zero? + break if instance.execute_script('return App.Ajax.queue().length === 0 && $.active === 0 && Object.keys(App.FormHandlerCoreWorkflow.getRequests()).length === 0').present? end end