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
d58847b7
Commit
d58847b7
authored
Dec 31, 2019
by
Sanad Liaquat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add wait_for_requests method
Also add it to multiple page base class methods
parent
8f23a3bb
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
3 deletions
+58
-3
qa/qa.rb
qa/qa.rb
+1
-0
qa/qa/ee/page/component/license_management.rb
qa/qa/ee/page/component/license_management.rb
+0
-2
qa/qa/page/base.rb
qa/qa/page/base.rb
+26
-1
qa/qa/resource/base.rb
qa/qa/resource/base.rb
+6
-0
qa/qa/support/wait_for_requests.rb
qa/qa/support/wait_for_requests.rb
+25
-0
No files found.
qa/qa.rb
View file @
d58847b7
...
...
@@ -490,6 +490,7 @@ module QA
autoload
:Dates
,
'qa/support/dates'
autoload
:Waiter
,
'qa/support/waiter'
autoload
:Retrier
,
'qa/support/retrier'
autoload
:WaitForRequests
,
'qa/support/wait_for_requests'
end
end
...
...
qa/qa/ee/page/component/license_management.rb
View file @
d58847b7
...
...
@@ -49,13 +49,11 @@ module QA
def
approve_license
(
name
)
click_license
(
name
)
click_element
(
:approve_license_button
)
wait_for_animated_element
(
:license_management_modal
)
end
def
blacklist_license
(
name
)
click_license
(
name
)
click_element
(
:blacklist_license_button
)
wait_for_animated_element
(
:license_management_modal
)
end
end
end
...
...
qa/qa/page/base.rb
View file @
d58847b7
...
...
@@ -8,6 +8,7 @@ module QA
prepend
Support
::
Page
::
Logging
if
Runtime
::
Env
.
debug?
include
Capybara
::
DSL
include
Scenario
::
Actable
include
Support
::
WaitForRequests
extend
Validatable
extend
SingleForwardable
...
...
@@ -21,6 +22,8 @@ module QA
def
refresh
page
.
refresh
wait_for_requests
end
def
wait
(
max:
60
,
interval:
0.1
,
reload:
true
)
...
...
@@ -42,6 +45,8 @@ module QA
end
def
scroll_to
(
selector
,
text:
nil
)
wait_for_requests
page
.
execute_script
<<~
JS
var elements = Array.from(document.querySelectorAll('
#{
selector
}
'));
var text = '
#{
text
}
';
...
...
@@ -74,6 +79,8 @@ module QA
end
def
find_element
(
name
,
**
kwargs
)
wait_for_requests
find
(
element_selector_css
(
name
),
kwargs
)
end
...
...
@@ -82,6 +89,8 @@ module QA
end
def
all_elements
(
name
,
**
kwargs
)
wait_for_requests
all
(
element_selector_css
(
name
),
**
kwargs
)
end
...
...
@@ -120,6 +129,8 @@ module QA
end
def
has_element?
(
name
,
**
kwargs
)
wait_for_requests
wait
=
kwargs
[
:wait
]
?
kwargs
[
:wait
]
&&
kwargs
.
delete
(
:wait
)
:
Capybara
.
default_max_wait_time
text
=
kwargs
[
:text
]
?
kwargs
[
:text
]
&&
kwargs
.
delete
(
:text
)
:
nil
...
...
@@ -127,6 +138,8 @@ module QA
end
def
has_no_element?
(
name
,
**
kwargs
)
wait_for_requests
wait
=
kwargs
[
:wait
]
?
kwargs
[
:wait
]
&&
kwargs
.
delete
(
:wait
)
:
Capybara
.
default_max_wait_time
text
=
kwargs
[
:text
]
?
kwargs
[
:text
]
&&
kwargs
.
delete
(
:text
)
:
nil
...
...
@@ -134,18 +147,24 @@ module QA
end
def
has_text?
(
text
,
wait:
Capybara
.
default_max_wait_time
)
wait_for_requests
page
.
has_text?
(
text
,
wait:
wait
)
end
def
has_no_text?
(
text
)
wait_for_requests
page
.
has_no_text?
text
end
def
has_normalized_ws_text?
(
text
,
wait:
Capybara
.
default_max_wait_time
)
page
.
has_text?
(
text
.
gsub
(
/\s+/
,
" "
),
wait:
wait
)
has_text?
(
text
.
gsub
(
/\s+/
,
" "
),
wait:
wait
)
end
def
finished_loading?
wait_for_requests
# The number of selectors should be able to be reduced after
# migration to the new spinner is complete.
# https://gitlab.com/groups/gitlab-org/-/epics/956
...
...
@@ -153,6 +172,8 @@ module QA
end
def
finished_loading_block?
wait_for_requests
has_no_css?
(
'.fa-spinner.block-loading'
,
wait:
Capybara
.
default_max_wait_time
)
end
...
...
@@ -220,10 +241,14 @@ module QA
end
def
click_link_with_text
(
text
)
wait_for_requests
click_link
text
end
def
click_body
wait_for_requests
find
(
'body'
).
click
end
...
...
qa/qa/resource/base.rb
View file @
d58847b7
...
...
@@ -66,10 +66,16 @@ module QA
def
visit!
Runtime
::
Logger
.
debug
(
%Q[Visiting
#{
self
.
class
.
name
}
at "
#{
web_url
}
"]
)
# Just in case an async action is not yet complete
Support
::
WaitForRequests
.
wait_for_requests
Support
::
Retrier
.
retry_until
do
visit
(
web_url
)
wait
{
current_url
.
include?
(
URI
.
parse
(
web_url
).
path
.
split
(
'/'
).
last
||
web_url
)
}
end
# Wait until the new page is ready for us to interact with it
Support
::
WaitForRequests
.
wait_for_requests
end
def
populate
(
*
attributes
)
...
...
qa/qa/support/wait_for_requests.rb
0 → 100644
View file @
d58847b7
# frozen_string_literal: true
module
QA
module
Support
module
WaitForRequests
module_function
def
wait_for_requests
Waiter
.
wait
do
finished_all_ajax_requests?
&&
finished_all_axios_requests?
end
end
def
finished_all_axios_requests?
Capybara
.
page
.
evaluate_script
(
'window.pendingRequests || 0'
).
zero?
end
def
finished_all_ajax_requests?
return
true
if
Capybara
.
page
.
evaluate_script
(
'typeof jQuery === "undefined"'
)
Capybara
.
page
.
evaluate_script
(
'jQuery.active'
).
zero?
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