Commit 60a5273d authored by Rémy Coutable's avatar Rémy Coutable

Wait for AJAX requests at the JS level in addition to wait for requests at the middleware level

Hopefully, this can solve transient failures such as
https://gitlab.com/gitlab-org/gitlab-ce/issues/29836.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 3ff8d802
require_relative './wait_for_ajax'
module WaitForRequests module WaitForRequests
extend self extend self
include WaitForAjax
# This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests # This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
def wait_for_requests_complete def wait_for_requests_complete
Gitlab::Testing::RequestBlockerMiddleware.block_requests! Gitlab::Testing::RequestBlockerMiddleware.block_requests!
wait_for('pending AJAX requests complete') do wait_for('pending AJAX requests complete') do
Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero? Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero? &&
finished_all_ajax_requests?
end end
ensure ensure
Gitlab::Testing::RequestBlockerMiddleware.allow_requests! Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment