Wait for ajax for every merge request spinach test
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
146e0cbc4d
commit
82033e2edc
5 changed files with 9 additions and 14 deletions
|
@ -9,6 +9,10 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
|
||||||
include SharedUser
|
include SharedUser
|
||||||
include WaitForAjax
|
include WaitForAjax
|
||||||
|
|
||||||
|
after do
|
||||||
|
wait_for_ajax if javascript_test?
|
||||||
|
end
|
||||||
|
|
||||||
step 'I click link "New Merge Request"' do
|
step 'I click link "New Merge Request"' do
|
||||||
click_link "New Merge Request"
|
click_link "New Merge Request"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require Rails.root.join('features/support/wait_for_ajax')
|
|
||||||
|
|
||||||
module SharedNote
|
module SharedNote
|
||||||
include Spinach::DSL
|
include Spinach::DSL
|
||||||
include WaitForAjax
|
include WaitForAjax
|
||||||
|
|
|
@ -15,7 +15,7 @@ if ENV['CI']
|
||||||
Knapsack::Adapters::SpinachAdapter.bind
|
Knapsack::Adapters::SpinachAdapter.bind
|
||||||
end
|
end
|
||||||
|
|
||||||
%w(select2_helper test_env repo_helpers).each do |f|
|
%w(select2_helper test_env repo_helpers wait_for_ajax).each do |f|
|
||||||
require Rails.root.join('spec', 'support', f)
|
require Rails.root.join('spec', 'support', f)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
module WaitForAjax
|
|
||||||
def wait_for_ajax
|
|
||||||
Timeout.timeout(Capybara.default_max_wait_time) do
|
|
||||||
loop until finished_all_ajax_requests?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def finished_all_ajax_requests?
|
|
||||||
page.evaluate_script('jQuery.active').zero?
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -8,4 +8,8 @@ module WaitForAjax
|
||||||
def finished_all_ajax_requests?
|
def finished_all_ajax_requests?
|
||||||
page.evaluate_script('jQuery.active').zero?
|
page.evaluate_script('jQuery.active').zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def javascript_test?
|
||||||
|
[:selenium, :webkit, :chrome, :poltergeist].include?(Capybara.current_driver)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue