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
Léo-Paul Géneau
gitlab-ce
Commits
6762d287
Commit
6762d287
authored
Jan 08, 2018
by
Brett Walker
Committed by
Grzegorz Bizon
Jan 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Allow QA tests to run with `CHROME_HEADLESS=false`"
parent
33fb2f99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
7 deletions
+114
-7
qa/qa.rb
qa/qa.rb
+1
-0
qa/qa/runtime/browser.rb
qa/qa/runtime/browser.rb
+34
-7
qa/qa/runtime/env.rb
qa/qa/runtime/env.rb
+15
-0
qa/spec/runtime/env_spec.rb
qa/spec/runtime/env_spec.rb
+64
-0
No files found.
qa/qa.rb
View file @
6762d287
...
...
@@ -10,6 +10,7 @@ module QA
autoload
:Namespace
,
'qa/runtime/namespace'
autoload
:Scenario
,
'qa/runtime/scenario'
autoload
:Browser
,
'qa/runtime/browser'
autoload
:Env
,
'qa/runtime/env'
end
##
...
...
qa/qa/runtime/browser.rb
View file @
6762d287
...
...
@@ -38,22 +38,49 @@ module QA
Capybara
.
register_driver
:chrome
do
|
app
|
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
'chromeOptions'
=>
{
'args'
=>
%w[headless no-sandbox disable-gpu window-size=1280,1680]
# This enables access to logs with `page.driver.manage.get_log(:browser)`
loggingPrefs:
{
browser:
"ALL"
,
client:
"ALL"
,
driver:
"ALL"
,
server:
"ALL"
}
)
Capybara
::
Selenium
::
Driver
.
new
(
app
,
browser: :chrome
,
desired_capabilities:
capabilities
)
end
options
=
Selenium
::
WebDriver
::
Chrome
::
Options
.
new
options
.
add_argument
(
"window-size=1240,1680"
)
Capybara
::
Screenshot
.
register_driver
(
:chrome
)
do
|
driver
,
path
|
driver
.
browser
.
save_screenshot
(
path
)
# Chrome won't work properly in a Docker container in sandbox mode
options
.
add_argument
(
"no-sandbox"
)
# Run headless by default unless CHROME_HEADLESS is false
if
QA
::
Runtime
::
Env
.
chrome_headless?
options
.
add_argument
(
"headless"
)
# Chrome documentation says this flag is needed for now
# https://developers.google.com/web/updates/2017/04/headless-chrome#cli
options
.
add_argument
(
"disable-gpu"
)
end
# Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
options
.
add_argument
(
"disable-dev-shm-usage"
)
if
QA
::
Runtime
::
Env
.
running_in_ci?
Capybara
::
Selenium
::
Driver
.
new
(
app
,
browser: :chrome
,
desired_capabilities:
capabilities
,
options:
options
)
end
# Keep only the screenshots generated from the last failing test suite
Capybara
::
Screenshot
.
prune_strategy
=
:keep_last_run
# From https://github.com/mattheworiordan/capybara-screenshot/issues/84#issuecomment-41219326
Capybara
::
Screenshot
.
register_driver
(
:chrome
)
do
|
driver
,
path
|
driver
.
browser
.
save_screenshot
(
path
)
end
Capybara
.
configure
do
|
config
|
config
.
default_driver
=
:chrome
config
.
javascript_driver
=
:chrome
...
...
qa/qa/runtime/env.rb
0 → 100644
View file @
6762d287
module
QA
module
Runtime
module
Env
extend
self
def
chrome_headless?
(
ENV
[
'CHROME_HEADLESS'
]
=~
/^(false|no|0)$/i
)
!=
0
end
def
running_in_ci?
ENV
[
'CI'
]
||
ENV
[
'CI_SERVER'
]
end
end
end
end
qa/spec/runtime/env_spec.rb
0 → 100644
View file @
6762d287
describe
QA
::
Runtime
::
Env
do
before
do
allow
(
ENV
).
to
receive
(
:[]
).
and_call_original
end
describe
'.chrome_headless?'
do
context
'when there is an env variable set'
do
it
'returns false when falsey values specified'
do
stub_env
(
'CHROME_HEADLESS'
,
'false'
)
expect
(
described_class
.
chrome_headless?
).
to
be_falsey
stub_env
(
'CHROME_HEADLESS'
,
'no'
)
expect
(
described_class
.
chrome_headless?
).
to
be_falsey
stub_env
(
'CHROME_HEADLESS'
,
'0'
)
expect
(
described_class
.
chrome_headless?
).
to
be_falsey
end
it
'returns true when anything else specified'
do
stub_env
(
'CHROME_HEADLESS'
,
'true'
)
expect
(
described_class
.
chrome_headless?
).
to
be_truthy
stub_env
(
'CHROME_HEADLESS'
,
'1'
)
expect
(
described_class
.
chrome_headless?
).
to
be_truthy
stub_env
(
'CHROME_HEADLESS'
,
'anything'
)
expect
(
described_class
.
chrome_headless?
).
to
be_truthy
end
end
context
'when there is no env variable set'
do
it
'returns the default, true'
do
stub_env
(
'CHROME_HEADLESS'
,
nil
)
expect
(
described_class
.
chrome_headless?
).
to
be_truthy
end
end
end
describe
'.running_in_ci?'
do
context
'when there is an env variable set'
do
it
'returns true if CI'
do
stub_env
(
'CI'
,
'anything'
)
expect
(
described_class
.
running_in_ci?
).
to
be_truthy
end
it
'returns true if CI_SERVER'
do
stub_env
(
'CI_SERVER'
,
'anything'
)
expect
(
described_class
.
running_in_ci?
).
to
be_truthy
end
end
context
'when there is no env variable set'
do
it
'returns true'
do
stub_env
(
'CI'
,
nil
)
stub_env
(
'CI_SERVER'
,
nil
)
expect
(
described_class
.
running_in_ci?
).
to
be_falsey
end
end
end
def
stub_env
(
name
,
value
)
allow
(
ENV
).
to
receive
(
:[]
).
with
(
name
).
and_return
(
value
)
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