summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2019-04-18 15:32:35 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2019-04-18 15:32:35 +0000
commitf1b3db3cf237daf8da481b594afeca9bc2df276f (patch)
treef135b88beb2b8f814159665d0905f19fb0d9edf2
parent31378fad47cb23175d2af6917f56c8fddeacd43b (diff)
parent4359108866a6b4f5903fc84bde919d5edba4da02 (diff)
downloadgitlab-ce-f1b3db3cf237daf8da481b594afeca9bc2df276f.tar.gz
Merge branch 'ce-11224-flaky-test-projects-audit-events-adding-an-ssh-key-appears-in-the-project-s-audit-events-ee-spec-features-projects-audit_events_spec' into 'master'
Introduce the wait_for helper for system tests See merge request gitlab-org/gitlab-ce!27483
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/helpers/wait_for_requests.rb14
-rw-r--r--spec/support/helpers/wait_helpers.rb20
3 files changed, 21 insertions, 14 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 60db3e1bc46..8ca4c172707 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -83,6 +83,7 @@ RSpec.configure do |config|
config.include Devise::Test::IntegrationHelpers, type: :feature
config.include LoginHelpers, type: :feature
config.include SearchHelpers, type: :feature
+ config.include WaitHelpers, type: :feature
config.include EmailHelpers, :mailer, type: :mailer
config.include Warden::Test::Helpers, type: :request
config.include Gitlab::Routing, type: :routing
diff --git a/spec/support/helpers/wait_for_requests.rb b/spec/support/helpers/wait_for_requests.rb
index c7f878b7371..45b9faa0fea 100644
--- a/spec/support/helpers/wait_for_requests.rb
+++ b/spec/support/helpers/wait_for_requests.rb
@@ -50,20 +50,6 @@ module WaitForRequests
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
- loop do
- break if yield
-
- if Time.now > wait_until
- raise "Condition not met: #{condition_name}"
- else
- sleep(polling_interval)
- end
- end
- end
-
def finished_all_vue_resource_requests?
Capybara.page.evaluate_script('window.activeVueResources || 0').zero?
end
diff --git a/spec/support/helpers/wait_helpers.rb b/spec/support/helpers/wait_helpers.rb
new file mode 100644
index 00000000000..7e8e25798e8
--- /dev/null
+++ b/spec/support/helpers/wait_helpers.rb
@@ -0,0 +1,20 @@
+module WaitHelpers
+ extend self
+
+ # Waits until the passed block returns true
+ def wait_for(condition_name, max_wait_time: Capybara.default_max_wait_time, polling_interval: 0.01, reload: false)
+ wait_until = Time.now + max_wait_time.seconds
+ loop do
+ result = yield
+ break if result
+
+ page.refresh if reload
+
+ if Time.now > wait_until
+ raise "Condition not met: #{condition_name}"
+ else
+ sleep(polling_interval)
+ end
+ end
+ end
+end