Maintenance: Stabilize Selenium tests by improving the wait_for_empty_ajax_queue logic.

This commit is contained in:
Martin Gruner 2022-03-04 13:21:07 +01:00
parent 8e537754bf
commit 25c971ed00
3 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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',

View file

@ -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