diff options
author | Stan Hu <stanhu@gmail.com> | 2017-06-16 22:07:14 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-06-16 22:07:14 -0700 |
commit | ddbb88010e05f6295dd6e46724d585494c8cc84a (patch) | |
tree | afff3cfb97d959827246252b95e6bd1ffbd9bacb | |
parent | ad521bde1bb556709edd39d8a9aa67ee47605b91 (diff) | |
download | gitlab-ce-ddbb88010e05f6295dd6e46724d585494c8cc84a.tar.gz |
Replace PhantomJS with headless Chrome for Rspec tests
Closes #30876
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 18 | ||||
-rw-r--r-- | features/support/capybara.rb | 22 | ||||
-rw-r--r-- | scripts/prepare_build.sh | 3 | ||||
-rw-r--r-- | spec/support/capybara.rb | 23 |
6 files changed, 32 insertions, 38 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0c266485b6..0f04df31e0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.3-golang-1.8-git-2.7-phantomjs-2.1-node-7.1-postgresql-9.6" +image: "dev.gitlab.org:5005/gitlab/gitlab-build-images:ruby-2.3.3-golang-1.8-git-2.7-chrome-59.0-node-7.1-postgresql-9.6" cache: key: "ruby-233-with-yarn" @@ -325,7 +325,7 @@ group :development, :test do gem 'capybara', '~> 2.6.2' gem 'capybara-screenshot', '~> 1.0.0' - gem 'poltergeist', '~> 1.9.0' + gem 'selenium-webdriver', '~> 2.53' gem 'spring', '~> 2.0.0' gem 'spring-commands-rspec', '~> 1.0.4' diff --git a/Gemfile.lock b/Gemfile.lock index 6755c75e331..b1d8b7356e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,12 +114,13 @@ GEM mime-types (>= 1.16) cause (0.1) charlock_holmes (0.7.3) + childprocess (0.7.0) + ffi (~> 1.0, >= 1.0.11) chronic (0.10.2) chronic_duration (0.10.6) numerizer (~> 0.1.1) chunky_png (1.3.5) citrus (3.0.2) - cliver (0.3.2) coderay (1.1.1) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -584,11 +585,6 @@ GEM pg (0.18.4) po_to_json (1.0.1) json (>= 1.6.0) - poltergeist (1.9.0) - capybara (~> 2.1) - cliver (~> 0.3.1) - multi_json (~> 1.0) - websocket-driver (>= 0.2.0) posix-spawn (0.3.11) powerpack (0.1.1) premailer (1.8.6) @@ -769,6 +765,10 @@ GEM activesupport (>= 3.1) select2-rails (3.5.9.3) thor (~> 0.14) + selenium-webdriver (2.53.4) + childprocess (~> 0.5) + rubyzip (~> 1.0) + websocket (~> 1.0) sentry-raven (2.4.0) faraday (>= 0.7.6, < 1.0) settingslogic (2.0.9) @@ -891,9 +891,7 @@ GEM hashdiff webpack-rails (0.9.10) railties (>= 3.2.0) - websocket-driver (0.6.3) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket (1.2.4) wikicloth (0.8.1) builder expression_parser @@ -1042,7 +1040,6 @@ DEPENDENCIES peek-redis (~> 1.2.0) peek-sidekiq (~> 1.0.3) pg (~> 0.18.2) - poltergeist (~> 1.9.0) premailer-rails (~> 1.9.0) prometheus-client-mmap (~> 0.7.0.beta5) pry-byebug (~> 3.4.1) @@ -1081,6 +1078,7 @@ DEPENDENCIES scss_lint (~> 0.47.0) seed-fu (~> 2.3.5) select2-rails (~> 3.5.9) + selenium-webdriver (~> 2.53) sentry-raven (~> 2.4.0) settingslogic (~> 2.0.9) sham_rack (~> 1.3.6) diff --git a/features/support/capybara.rb b/features/support/capybara.rb index f4691647d4b..1d1626a064b 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -1,22 +1,18 @@ -require 'capybara/poltergeist' require 'capybara-screenshot/spinach' # Give CI some extra time timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 -Capybara.javascript_driver = :poltergeist -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new( - app, - js_errors: true, - timeout: timeout, - window_size: [1366, 768], - url_whitelist: %w[localhost 127.0.0.1], - url_blacklist: %w[.mp4 .png .gif .avi .bmp .jpg .jpeg], - phantomjs_options: [ - '--load-images=yes' - ] +Capybara.javascript_driver = :chrome +Capybara.register_driver :chrome do |app| + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( + 'chromeOptions' => { + 'args' => %w[headless no-sandbox disable-gpu] + } ) + + Capybara::Selenium::Driver + .new(app, browser: :chrome, desired_capabilities: capabilities) end Capybara.default_max_wait_time = timeout diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 03de59f27ad..07bbf901ad0 100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -1,5 +1,8 @@ . scripts/utils.sh +wget -q https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip +unzip chromedriver_linux64.zip -d /usr/local/bin + export SETUP_DB=${SETUP_DB:-true} export USE_BUNDLE_INSTALL=${USE_BUNDLE_INSTALL:-true} export BUNDLE_INSTALL_FLAGS="--without production --jobs $(nproc) --path vendor --retry 3 --quiet" diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 4aa81a03558..fbe8ae30565 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,25 +1,22 @@ # rubocop:disable Style/GlobalVars require 'capybara/rails' require 'capybara/rspec' -require 'capybara/poltergeist' require 'capybara-screenshot/rspec' +require 'selenium-webdriver' # Give CI some extra time timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30 -Capybara.javascript_driver = :poltergeist -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new( - app, - js_errors: true, - timeout: timeout, - window_size: [1366, 768], - url_whitelist: %w[localhost 127.0.0.1], - url_blacklist: %w[.mp4 .png .gif .avi .bmp .jpg .jpeg], - phantomjs_options: [ - '--load-images=yes' - ] +Capybara.javascript_driver = :chrome +Capybara.register_driver :chrome do |app| + capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( + 'chromeOptions' => { + 'args' => %w[headless no-sandbox disable-gpu] + } ) + + Capybara::Selenium::Driver + .new(app, browser: :chrome, desired_capabilities: capabilities) end Capybara.default_max_wait_time = timeout |