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
0430524b
Commit
0430524b
authored
Nov 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP Handle domain sessions better in QA test scenario
[ci skip]
parent
9799d363
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
48 deletions
+61
-48
qa/qa.rb
qa/qa.rb
+1
-0
qa/qa/page/base.rb
qa/qa/page/base.rb
+14
-0
qa/qa/page/main/entry.rb
qa/qa/page/main/entry.rb
+2
-14
qa/qa/runtime/browser.rb
qa/qa/runtime/browser.rb
+33
-26
qa/qa/scenario/entrypoint.rb
qa/qa/scenario/entrypoint.rb
+0
-1
qa/qa/specs/features/login/standard_spec.rb
qa/qa/specs/features/login/standard_spec.rb
+1
-1
qa/qa/specs/features/mattermost/login_spec.rb
qa/qa/specs/features/mattermost/login_spec.rb
+9
-5
qa/qa/specs/runner.rb
qa/qa/specs/runner.rb
+1
-1
No files found.
qa/qa.rb
View file @
0430524b
...
@@ -9,6 +9,7 @@ module QA
...
@@ -9,6 +9,7 @@ module QA
autoload
:User
,
'qa/runtime/user'
autoload
:User
,
'qa/runtime/user'
autoload
:Namespace
,
'qa/runtime/namespace'
autoload
:Namespace
,
'qa/runtime/namespace'
autoload
:Scenario
,
'qa/runtime/scenario'
autoload
:Scenario
,
'qa/runtime/scenario'
autoload
:Browser
,
'qa/runtime/browser'
end
end
##
##
...
...
qa/qa/page/base.rb
View file @
0430524b
...
@@ -7,6 +7,20 @@ module QA
...
@@ -7,6 +7,20 @@ module QA
def
refresh
def
refresh
visit
current_url
visit
current_url
end
end
def
wait
(
css
=
'.application'
,
time:
60
)
# This resolves cold boot / background tasks problems
#
Time
.
now
.
tap
do
|
start
|
while
Time
.
now
-
start
<
time
break
if
page
.
has_css?
(
css
,
wait:
5
)
puts
"Waiting for `
#{
css
}
on `
#{
current_url
}
`"
refresh
end
end
yield
if
block_given?
end
end
end
end
end
end
end
qa/qa/page/main/entry.rb
View file @
0430524b
...
@@ -3,20 +3,8 @@ module QA
...
@@ -3,20 +3,8 @@ module QA
module
Main
module
Main
class
Entry
<
Page
::
Base
class
Entry
<
Page
::
Base
def
visit_login_page
def
visit_login_page
visit
(
"
#{
Runtime
::
Scenario
.
gitlab_address
}
/users/sign_in"
)
wait
(
time:
500
)
do
wait_for_instance_to_be_ready
visit
(
"
#{
Runtime
::
Scenario
.
gitlab_address
}
/users/sign_in"
)
end
private
def
wait_for_instance_to_be_ready
# This resolves cold boot / background tasks problems
#
start
=
Time
.
now
while
Time
.
now
-
start
<
240
break
if
page
.
has_css?
(
'.application'
,
wait:
10
)
refresh
end
end
end
end
end
end
...
...
qa/qa/
specs/config
.rb
→
qa/qa/
runtime/browser
.rb
View file @
0430524b
...
@@ -3,37 +3,45 @@ require 'capybara/rspec'
...
@@ -3,37 +3,45 @@ require 'capybara/rspec'
require
'capybara-screenshot/rspec'
require
'capybara-screenshot/rspec'
require
'selenium-webdriver'
require
'selenium-webdriver'
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/LineLength
module
QA
module
QA
module
Specs
module
Runtime
class
Config
<
Scenario
::
Template
module
Browser
include
Scenario
::
Actable
extend
self
def
perform
configure_rspec!
configure_capybara!
end
def
configure_rspec!
def
session
(
address
,
&
block
)
RSpec
.
configure
do
|
config
|
configure!
config
.
expect_with
:rspec
do
|
expectations
|
page
.
visit
(
address
)
expectations
.
include_chain_clauses_in_custom_matcher_descriptions
=
true
end
config
.
mock_with
:rspec
do
|
mocks
|
block
.
call
(
page
)
mocks
.
verify_partial_doubles
=
true
end
config
.
order
=
:random
page
.
visit
(
address
)
Kernel
.
srand
config
.
seed
reset_domain_session!
config
.
formatter
=
:documentation
rescue
config
.
color
=
true
# RSpec examples will take care of screenshots on their own
#
unless
block
.
binding
.
receiver
.
class
<
RSpec
::
Core
::
ExampleGroup
Capybara
::
Screenshot
.
screenshot_and_save_page
end
end
raise
end
def
page
Capybara
.
current_session
end
def
reset_domain_session
(
address
)
##
# Selenium allows to reset session cookies for current domain only.
#
# See gitlab-org/gitlab-qa#102
#
Capybar
.
reset_session!
end
end
def
configure_capybara!
def
configure!
return
if
Capybara
.
drivers
.
include?
(
:chrome
)
Capybara
.
register_driver
:chrome
do
|
app
|
Capybara
.
register_driver
:chrome
do
|
app
|
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
'chromeOptions'
=>
{
'chromeOptions'
=>
{
...
@@ -52,8 +60,7 @@ module QA
...
@@ -52,8 +60,7 @@ module QA
Capybara
.
configure
do
|
config
|
Capybara
.
configure
do
|
config
|
config
.
default_driver
=
:chrome
config
.
default_driver
=
:chrome
config
.
javascript_driver
=
:chrome
config
.
javascript_driver
=
:chrome
config
.
default_max_wait_time
=
10
config
.
default_max_wait_time
=
4
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
config
.
save_path
=
'tmp'
config
.
save_path
=
'tmp'
end
end
...
...
qa/qa/scenario/entrypoint.rb
View file @
0430524b
...
@@ -8,7 +8,6 @@ module QA
...
@@ -8,7 +8,6 @@ module QA
include
Bootable
include
Bootable
def
perform
(
address
,
*
files
)
def
perform
(
address
,
*
files
)
Specs
::
Config
.
act
{
configure_capybara!
}
Runtime
::
Scenario
.
define
(
:gitlab_address
,
address
)
Runtime
::
Scenario
.
define
(
:gitlab_address
,
address
)
##
##
...
...
qa/qa/specs/features/login/standard_spec.rb
View file @
0430524b
module
QA
module
QA
feature
'standard
root
login'
,
:core
do
feature
'standard
user
login'
,
:core
do
scenario
'user logs in using credentials'
do
scenario
'user logs in using credentials'
do
Page
::
Main
::
Entry
.
act
{
visit_login_page
}
Page
::
Main
::
Entry
.
act
{
visit_login_page
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
...
...
qa/qa/specs/features/mattermost/login_spec.rb
View file @
0430524b
module
QA
module
QA
feature
'logging in to Mattermost'
,
:mattermost
do
feature
'logging in to Mattermost'
,
:mattermost
do
scenario
'can use gitlab oauth'
do
scenario
'can use gitlab oauth'
do
Page
::
Main
::
Entry
.
act
{
visit_login_page
}
Runtime
::
Browser
.
session
(
Page
::
Gitlab
::
Login
)
do
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Mattermost
::
Login
.
act
{
sign_in_using_oauth
}
Page
::
Mattermost
::
Main
.
perform
do
|
page
|
Runtime
::
Browser
.
session
(
Page
::
Mattermost
::
Login
)
do
expect
(
page
).
to
have_content
(
/(Welcome to: Mattermost|Logout GitLab Mattermost)/
)
Page
::
Mattermost
::
Login
.
act
{
sign_in_using_oauth
}
Page
::
Mattermost
::
Main
.
perform
do
|
page
|
expect
(
page
).
to
have_content
(
/(Welcome to: Mattermost|Logout GitLab Mattermost)/
)
end
end
end
end
end
end
end
end
...
...
qa/qa/specs/runner.rb
View file @
0430524b
...
@@ -17,7 +17,7 @@ module QA
...
@@ -17,7 +17,7 @@ module QA
tags
.
to_a
.
each
{
|
tag
|
args
.
push
([
'-t'
,
tag
.
to_s
])
}
tags
.
to_a
.
each
{
|
tag
|
args
.
push
([
'-t'
,
tag
.
to_s
])
}
args
.
push
(
files
)
args
.
push
(
files
)
Specs
::
Config
.
perform
Runtime
::
Browser
.
configure!
RSpec
::
Core
::
Runner
.
run
(
args
.
flatten
,
$stderr
,
$stdout
).
tap
do
|
status
|
RSpec
::
Core
::
Runner
.
run
(
args
.
flatten
,
$stderr
,
$stdout
).
tap
do
|
status
|
abort
if
status
.
nonzero?
abort
if
status
.
nonzero?
...
...
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