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
57c037de
Commit
57c037de
authored
Nov 19, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make QA runtime browser an actable object
[ci skip]
parent
e11886f4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
60 deletions
+56
-60
qa/qa/page/base.rb
qa/qa/page/base.rb
+0
-15
qa/qa/page/main/login.rb
qa/qa/page/main/login.rb
+4
-4
qa/qa/page/mattermost/login.rb
qa/qa/page/mattermost/login.rb
+4
-4
qa/qa/runtime/browser.rb
qa/qa/runtime/browser.rb
+47
-36
qa/qa/specs/features/mattermost/login_spec.rb
qa/qa/specs/features/mattermost/login_spec.rb
+1
-1
No files found.
qa/qa/page/base.rb
View file @
57c037de
...
@@ -39,24 +39,9 @@ module QA
...
@@ -39,24 +39,9 @@ module QA
yield
if
block_given?
yield
if
block_given?
end
end
##
# If you want to use specific page class as an entrypoint
# for Runtime::Browser.session, you need to implement this
# method in a subclass.
#
def
self
.
address
def
self
.
address
raise
NotImplementedError
raise
NotImplementedError
end
end
## TODO
# When we navigate through pages, we want to check if we are on a
# valid page everytime we instantiate a new Page object.
#
# See gitlab-org/gitlab-qa#111
#
# def self.pattern
# raise NotImplementedError
# end
end
end
end
end
end
end
qa/qa/page/main/login.rb
View file @
57c037de
...
@@ -2,10 +2,6 @@ module QA
...
@@ -2,10 +2,6 @@ module QA
module
Page
module
Page
module
Main
module
Main
class
Login
<
Page
::
Base
class
Login
<
Page
::
Base
def
self
.
address
Runtime
::
Scenario
.
gitlab_address
+
'/users/sign_in'
end
def
initialize
def
initialize
wait
(
'.application'
,
time:
500
)
wait
(
'.application'
,
time:
500
)
end
end
...
@@ -21,6 +17,10 @@ module QA
...
@@ -21,6 +17,10 @@ module QA
fill_in
:user_password
,
with:
Runtime
::
User
.
password
fill_in
:user_password
,
with:
Runtime
::
User
.
password
click_button
'Sign in'
click_button
'Sign in'
end
end
def
self
.
address
Runtime
::
Scenario
.
gitlab_address
+
'/users/sign_in'
end
end
end
end
end
end
end
...
...
qa/qa/page/mattermost/login.rb
View file @
57c037de
...
@@ -2,10 +2,6 @@ module QA
...
@@ -2,10 +2,6 @@ module QA
module
Page
module
Page
module
Mattermost
module
Mattermost
class
Login
<
Page
::
Base
class
Login
<
Page
::
Base
def
self
.
address
Runtime
::
Scenario
.
mattermost_address
+
'/login'
end
def
sign_in_using_oauth
def
sign_in_using_oauth
click_link
class:
'btn btn-custom-login gitlab'
click_link
class:
'btn btn-custom-login gitlab'
...
@@ -13,6 +9,10 @@ module QA
...
@@ -13,6 +9,10 @@ module QA
click_button
'Authorize'
click_button
'Authorize'
end
end
end
end
def
self
.
address
Runtime
::
Scenario
.
gitlab_address
+
'/login'
end
end
end
end
end
end
end
...
...
qa/qa/runtime/browser.rb
View file @
57c037de
...
@@ -5,49 +5,24 @@ require 'selenium-webdriver'
...
@@ -5,49 +5,24 @@ require 'selenium-webdriver'
module
QA
module
QA
module
Runtime
module
Runtime
module
Browser
class
Browser
extend
self
include
Scenario
::
Actable
def
visit
(
entry
,
&
block
)
def
initialize
address
=
entry
.
is_a?
(
String
)
?
entry
:
entry
.
address
self
.
class
.
configure!
configure!
page
.
visit
(
address
)
if
block_given?
block
.
call
(
page
)
page
.
visit
(
address
)
reset_domain_session!
end
rescue
# 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
def
visit
(
page
,
&
block
)
Browser
::
Session
.
new
(
page
).
tap
do
|
session
|
session
.
perform
(
&
block
)
end
end
##
# Current session, when Capybara::DSL is included `page` method is
# mixed in as well.
#
def
page
Capybara
.
current_session
end
end
def
reset_domain_session
(
address
)
def
self
.
visit
(
page
,
&
block
)
##
new
.
visit
(
page
,
&
block
)
# Selenium allows to reset session cookies for current domain only.
#
# See gitlab-org/gitlab-qa#102
#
Capybar
.
reset_session!
end
end
def
configure!
def
self
.
configure!
return
if
Capybara
.
drivers
.
include?
(
:chrome
)
return
if
Capybara
.
drivers
.
include?
(
:chrome
)
Capybara
.
register_driver
:chrome
do
|
app
|
Capybara
.
register_driver
:chrome
do
|
app
|
...
@@ -73,6 +48,42 @@ module QA
...
@@ -73,6 +48,42 @@ module QA
config
.
save_path
=
'tmp'
config
.
save_path
=
'tmp'
end
end
end
end
class
Session
include
Capybara
::
DSL
attr_reader
:address
def
initialize
(
page
)
@address
=
page
.
is_a?
(
String
)
?
page
:
page
.
address
end
def
perform
(
&
block
)
visit
(
@address
)
block
.
call
if
block_given?
rescue
# 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
raise
ensure
clear!
if
block_given?
end
##
# Selenium allows to reset session cookies for current domain only.
#
# See gitlab-org/gitlab-qa#102
#
def
clear!
visit
(
@address
)
Capybara
.
reset_session!
end
end
end
end
end
end
end
end
qa/qa/specs/features/mattermost/login_spec.rb
View file @
57c037de
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
Runtime
::
Browser
.
visit
(
Page
::
Gitlab
::
Login
)
do
Runtime
::
Browser
.
visit
(
Page
::
Main
::
Login
)
do
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
Runtime
::
Browser
.
visit
(
Page
::
Mattermost
::
Login
)
do
Runtime
::
Browser
.
visit
(
Page
::
Mattermost
::
Login
)
do
...
...
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