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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
340f164e
Commit
340f164e
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 and fix a flaky test
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
65e7821f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
17 deletions
+24
-17
ee/spec/features/projects/audit_events_spec.rb
ee/spec/features/projects/audit_events_spec.rb
+3
-3
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.
ee/spec/features/projects/audit_events_spec.rb
View file @
340f164e
...
...
@@ -80,11 +80,11 @@ describe 'Projects > Audit Events', :js do
find
(
'.ic-remove'
).
click
end
wait_for_all_requests
visit
project_audit_events_path
(
project
)
expect
(
page
).
to
have_content
(
'Remove deploy key'
)
wait_for
(
'Audit event background creation job is done'
,
polling_interval:
0.5
,
reload:
true
)
do
page
.
has_content?
(
'Remove deploy key'
,
wait:
0
)
end
end
end
...
...
spec/spec_helper.rb
View file @
340f164e
...
...
@@ -85,6 +85,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 @
340f164e
...
...
@@ -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 @
340f164e
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