Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
43591088
Commit
43591088
authored
Apr 18, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce the wait_for helper for system tests
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f38e3f2f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
14 deletions
+21
-14
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/support/helpers/wait_for_requests.rb
spec/support/helpers/wait_for_requests.rb
+0
-14
spec/support/helpers/wait_helpers.rb
spec/support/helpers/wait_helpers.rb
+20
-0
No files found.
spec/spec_helper.rb
View file @
43591088
...
...
@@ -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
...
...
spec/support/helpers/wait_for_requests.rb
View file @
43591088
...
...
@@ -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
...
...
spec/support/helpers/wait_helpers.rb
0 → 100644
View file @
43591088
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment