Commit 040fc991 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'dm-wait-for-requests' into 'master'

Wait for requests after each Spinach scenario instead of feature

See merge request !11349
parents cec971b6 718350dc
......@@ -30,8 +30,8 @@ Spinach.hooks.before_run do
include FactoryGirl::Syntax::Methods
end
Spinach.hooks.after_feature do |feature_data|
if feature_data.scenarios.flat_map(&:tags).include?('javascript')
Spinach.hooks.after_scenario do |scenario_data, step_definitions|
if scenario_data.tags.include?('javascript')
include WaitForRequests
wait_for_requests_complete
end
......
......@@ -10,17 +10,12 @@ module WaitForRequests
def wait_for_requests_complete
Gitlab::Testing::RequestBlockerMiddleware.block_requests!
wait_for('pending AJAX requests complete') do
Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero? &&
finished_all_requests?
Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero?
end
ensure
Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
end
def finished_all_requests?
finished_all_ajax_requests? && finished_all_vue_resource_requests?
end
# Waits until the passed block returns true
def wait_for(condition_name, max_wait_time: Capybara.default_max_wait_time, polling_interval: 0.01)
wait_until = Time.now + max_wait_time.seconds
......
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