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
ed3b23fe
Commit
ed3b23fe
authored
Nov 02, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor wait_for_requests, add slow_requests block helper
parent
187a4f6c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
64 additions
and
50 deletions
+64
-50
spec/features/issues/filtered_search/dropdown_assignee_spec.rb
...features/issues/filtered_search/dropdown_assignee_spec.rb
+4
-4
spec/features/issues/filtered_search/dropdown_author_spec.rb
spec/features/issues/filtered_search/dropdown_author_spec.rb
+4
-4
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
+4
-4
spec/features/issues/filtered_search/dropdown_label_spec.rb
spec/features/issues/filtered_search/dropdown_label_spec.rb
+4
-4
spec/features/issues/filtered_search/dropdown_milestone_spec.rb
...eatures/issues/filtered_search/dropdown_milestone_spec.rb
+4
-4
spec/features/projects/user_browses_files_spec.rb
spec/features/projects/user_browses_files_spec.rb
+1
-1
spec/features/uploads/user_uploads_file_to_note_spec.rb
spec/features/uploads/user_uploads_file_to_note_spec.rb
+13
-21
spec/support/inspect_requests.rb
spec/support/inspect_requests.rb
+1
-1
spec/support/wait_for_requests.rb
spec/support/wait_for_requests.rb
+29
-7
No files found.
spec/features/issues/filtered_search/dropdown_assignee_spec.rb
View file @
ed3b23fe
...
@@ -43,11 +43,11 @@ describe 'Dropdown assignee', :js do
...
@@ -43,11 +43,11 @@ describe 'Dropdown assignee', :js do
end
end
it
'should show loading indicator when opened'
do
it
'should show loading indicator when opened'
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
slow_requests
do
filtered_search
.
set
(
'assignee:'
)
filtered_search
.
set
(
'assignee:'
)
expect
(
page
).
to
have_css
(
'#js-dropdown-assignee .filter-dropdown-loading'
,
visible:
true
)
expect
(
page
).
to
have_css
(
'#js-dropdown-assignee .filter-dropdown-loading'
,
visible:
true
)
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
end
it
'should hide loading indicator when loaded'
do
it
'should hide loading indicator when loaded'
do
...
...
spec/features/issues/filtered_search/dropdown_author_spec.rb
View file @
ed3b23fe
...
@@ -51,11 +51,11 @@ describe 'Dropdown author', :js do
...
@@ -51,11 +51,11 @@ describe 'Dropdown author', :js do
end
end
it
'should show loading indicator when opened'
do
it
'should show loading indicator when opened'
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
slow_requests
do
filtered_search
.
set
(
'author:'
)
filtered_search
.
set
(
'author:'
)
expect
(
page
).
to
have_css
(
'#js-dropdown-author .filter-dropdown-loading'
,
visible:
true
)
expect
(
page
).
to
have_css
(
'#js-dropdown-author .filter-dropdown-loading'
,
visible:
true
)
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
end
it
'should hide loading indicator when loaded'
do
it
'should hide loading indicator when loaded'
do
...
...
spec/features/issues/filtered_search/dropdown_emoji_spec.rb
View file @
ed3b23fe
...
@@ -70,11 +70,11 @@ describe 'Dropdown emoji', :js do
...
@@ -70,11 +70,11 @@ describe 'Dropdown emoji', :js do
end
end
it
'should show loading indicator when opened'
do
it
'should show loading indicator when opened'
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
slow_requests
do
filtered_search
.
set
(
'my-reaction:'
)
filtered_search
.
set
(
'my-reaction:'
)
expect
(
page
).
to
have_css
(
'#js-dropdown-my-reaction .filter-dropdown-loading'
,
visible:
true
)
expect
(
page
).
to
have_css
(
'#js-dropdown-my-reaction .filter-dropdown-loading'
,
visible:
true
)
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
end
it
'should hide loading indicator when loaded'
do
it
'should hide loading indicator when loaded'
do
...
...
spec/features/issues/filtered_search/dropdown_label_spec.rb
View file @
ed3b23fe
...
@@ -66,12 +66,12 @@ describe 'Dropdown label', :js do
...
@@ -66,12 +66,12 @@ describe 'Dropdown label', :js do
end
end
it
'shows loading indicator when opened and hides it when loaded'
do
it
'shows loading indicator when opened and hides it when loaded'
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
slow_requests
do
filtered_search
.
set
(
'label:'
)
filtered_search
.
set
(
'label:'
)
expect
(
page
).
to
have_css
(
"
#{
js_dropdown_label
}
.filter-dropdown-loading"
,
visible:
true
)
expect
(
page
).
to
have_css
(
"
#{
js_dropdown_label
}
.filter-dropdown-loading"
,
visible:
true
)
end
expect
(
find
(
js_dropdown_label
)).
not_to
have_css
(
'.filter-dropdown-loading'
)
expect
(
find
(
js_dropdown_label
)).
not_to
have_css
(
'.filter-dropdown-loading'
)
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
it
'loads all the labels when opened'
do
it
'loads all the labels when opened'
do
...
...
spec/features/issues/filtered_search/dropdown_milestone_spec.rb
View file @
ed3b23fe
...
@@ -50,11 +50,11 @@ describe 'Dropdown milestone', :js do
...
@@ -50,11 +50,11 @@ describe 'Dropdown milestone', :js do
end
end
it
'should show loading indicator when opened'
do
it
'should show loading indicator when opened'
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
slow_requests
do
filtered_search
.
set
(
'milestone:'
)
filtered_search
.
set
(
'milestone:'
)
expect
(
page
).
to
have_css
(
'#js-dropdown-milestone .filter-dropdown-loading'
,
visible:
true
)
expect
(
page
).
to
have_css
(
'#js-dropdown-milestone .filter-dropdown-loading'
,
visible:
true
)
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
end
it
'should hide loading indicator when loaded'
do
it
'should hide loading indicator when loaded'
do
...
...
spec/features/projects/user_browses_files_spec.rb
View file @
ed3b23fe
...
@@ -179,7 +179,7 @@ describe 'User browses files' do
...
@@ -179,7 +179,7 @@ describe 'User browses files' do
click_button
(
'Upload file'
)
click_button
(
'Upload file'
)
end
end
block_and_wait_for_requests_complete
wait_for_all_requests
visit
(
project_blob_path
(
project
,
'new_branch_name/logo_sample.svg'
))
visit
(
project_blob_path
(
project
,
'new_branch_name/logo_sample.svg'
))
...
...
spec/features/uploads/user_uploads_file_to_note_spec.rb
View file @
ed3b23fe
...
@@ -21,24 +21,12 @@ feature 'User uploads file to note' do
...
@@ -21,24 +21,12 @@ feature 'User uploads file to note' do
end
end
context
'uploading is in progress'
do
context
'uploading is in progress'
do
before
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
end
after
do
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
it
'shows "Cancel" button on uploading'
,
:js
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
expect
(
page
).
to
have_button
(
'Cancel'
)
end
it
'cancels uploading on clicking to "Cancel" button'
,
:js
do
it
'cancels uploading on clicking to "Cancel" button'
,
:js
do
slow_requests
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
click_button
'Cancel'
click_button
'Cancel'
end
expect
(
page
).
to
have_button
(
'Attach a file'
)
expect
(
page
).
to
have_button
(
'Attach a file'
)
expect
(
page
).
not_to
have_button
(
'Cancel'
)
expect
(
page
).
not_to
have_button
(
'Cancel'
)
...
@@ -46,17 +34,21 @@ feature 'User uploads file to note' do
...
@@ -46,17 +34,21 @@ feature 'User uploads file to note' do
end
end
it
'shows "Attaching a file" message on uploading 1 file'
,
:js
do
it
'shows "Attaching a file" message on uploading 1 file'
,
:js
do
slow_requests
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
expect
(
page
).
to
have_selector
(
'.attaching-file-message'
,
visible:
true
,
text:
'Attaching a file -'
)
expect
(
page
).
to
have_selector
(
'.attaching-file-message'
,
visible:
true
,
text:
'Attaching a file -'
)
end
end
end
it
'shows "Attaching 2 files" message on uploading 2 file'
,
:js
do
it
'shows "Attaching 2 files" message on uploading 2 file'
,
:js
do
slow_requests
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'video_sample.mp4'
),
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'video_sample.mp4'
),
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'dk.png'
)],
0
,
false
)
expect
(
page
).
to
have_selector
(
'.attaching-file-message'
,
visible:
true
,
text:
'Attaching 2 files -'
)
expect
(
page
).
to
have_selector
(
'.attaching-file-message'
,
visible:
true
,
text:
'Attaching 2 files -'
)
end
end
end
it
'shows error message, "retry" and "attach a new file" link a if file is too big'
,
:js
do
it
'shows error message, "retry" and "attach a new file" link a if file is too big'
,
:js
do
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'video_sample.mp4'
)],
0.01
)
dropzone_file
([
Rails
.
root
.
join
(
'spec'
,
'fixtures'
,
'video_sample.mp4'
)],
0.01
)
...
...
spec/support/inspect_requests.rb
View file @
ed3b23fe
...
@@ -9,7 +9,7 @@ module InspectRequests
...
@@ -9,7 +9,7 @@ module InspectRequests
yield
yield
block_and_wait_for_requests_complete
wait_for_all_requests
Gitlab
::
Testing
::
RequestInspectorMiddleware
.
requests
Gitlab
::
Testing
::
RequestInspectorMiddleware
.
requests
ensure
ensure
Gitlab
::
Testing
::
RequestInspectorMiddleware
.
stop_logging!
Gitlab
::
Testing
::
RequestInspectorMiddleware
.
stop_logging!
...
...
spec/support/wait_for_requests.rb
View file @
ed3b23fe
require_relative
'./wait_for_requests'
module
WaitForRequests
module
WaitForRequests
extend
self
extend
self
# This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
# This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
def
block_and_wait_for_requests_complete
def
block_and_wait_for_requests_complete
block_requests
{
wait_for_all_requests
}
end
# Block all requests inside block with 503 response
def
block_requests
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
block_requests!
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
block_requests!
wait_for
(
'pending requests complete'
)
do
yield
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
num_active_requests
.
zero?
&&
finished_all_requests?
ensure
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
# Slow down requests inside block by injecting `sleep 0.2` before each response
def
slow_requests
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
slow_requests!
yield
ensure
ensure
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
allow_requests!
end
end
# Wait for client-side AJAX requests
def
wait_for_requests
def
wait_for_requests
wait_for
(
'JS requests'
)
{
finished_all_requests?
}
wait_for
(
'JS requests complete'
)
{
finished_all_js_requests?
}
end
# Wait for active Rack requests and client-side AJAX requests
def
wait_for_all_requests
wait_for
(
'pending requests complete'
)
do
finished_all_rack_reqiests?
&&
finished_all_js_requests?
end
end
end
private
private
def
finished_all_requests?
def
finished_all_rack_reqiests?
Gitlab
::
Testing
::
RequestBlockerMiddleware
.
num_active_requests
.
zero?
end
def
finished_all_js_requests?
return
true
unless
javascript_test?
return
true
unless
javascript_test?
finished_all_ajax_requests?
&&
finished_all_ajax_requests?
&&
...
...
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