Skip to content

Commit

Permalink
try creating a system test and running in Travis (#4888)
Browse files Browse the repository at this point in the history
* try creating a system test

* Create application_system_test_case.rb

* Update .travis.yml

* Update Gemfile

* Update Gemfile

* Update .travis.yml

* Update application_system_test_case.rb

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Fix system test

* Disable system test on production for now

* Comment system test related configs from .travis.yml

* Update Gemfile

* Update Gemfile.lock

* Update application_system_test_case.rb

* Update .travis.yml

* update gemfile.lock

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update application_system_test_case.rb

* apt-get install google-chrome-stable chromium-chromedriver

* wget/dpkg install of chromium and chromedriver

* Update .travis.yml

* Update .travis.yml

* gemfile.lock update

* Gemfile.lock update

* change curl to wget

* Chromedriver 2.35 and removed finds missing

* Turn off binary option

* Add command to start Chrome

* update selenium-webdriver to 3.141.0

* --no-sandbox

* export DISPLAY=:99.0

* Xvfb : nohup Xvfb -ac :9 -screen 0 1280x1024x16 &

* Remove prefix

* Chromedriver 73.0.3683.68

* Add chrome flags to ruby initializer

* comment out first start of chrome, remove extraneous comments

* commenting out `xvfb` and `DISPLAY`

* move passenger to general gems; move back if it fails

* cleaning up commented lines

* Update Gemfile

* Update Gemfile

* Update Gemfile

* Update application_system_test_case.rb
  • Loading branch information
jywarren authored Mar 31, 2019
1 parent f7e5f35 commit a95ba1f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ install:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then gem install danger danger-junit; fi'

script:
- docker-compose exec web bash -c "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
- docker-compose exec web bash -c "dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install"
- docker-compose exec web bash -c "wget https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_linux64.zip" # https://sites.google.com/a/chromium.org/chromedriver/
- docker-compose exec web bash -c "unzip chromedriver_linux64.zip"
- docker-compose exec web bash -c "mv chromedriver /usr/local/bin/chromedriver"
- docker-compose exec web bash -c "chmod +x /usr/local/bin/chromedriver"
- docker-compose exec web bash -c "CI=TRUE GENERATE_REPORT=true rake test:all"
- docker-compose exec web bash -c "CI=TRUE GENERATE_REPORT=true rails test -d"
- docker-compose exec web bash -c "CI=TRUE GENERATE_REPORT=true rails test:system"
- echo -e '<?xml version="1.0" encoding="UTF-8"?>' > output.xml
- tail -n +2 -q ./test/reports/TEST*.xml >> output.xml
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then danger --verbose; fi'

3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ group :development do
end

group :test, :development do
gem 'capybara'
gem 'ci_reporter_test_unit'
gem 'coveralls', require: false
gem 'jasmine-jquery-rails'
Expand All @@ -107,10 +108,12 @@ group :test, :development do
gem 'minitest-reporters', '~> 1.3.6'
gem 'openssl', '~> 2.1.2'
gem 'phantomjs'
gem 'puma', '~> 3.12'
gem 'rails-perftest'
gem 'rake', '~> 12.3.2'
gem 'rest-client'
gem 'rspec'
gem 'selenium-webdriver', '~> 3.141.0'
gem 'test-unit'
gem 'teaspoon-mocha'
gem 'timecop'
Expand Down
37 changes: 30 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,20 @@ GEM
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bindex (0.5.0)
bindex (0.6.0)
buftok (0.2.0)
builder (3.2.3)
byebug (11.0.1)
capybara (3.16.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chronic (0.10.2)
ci_reporter (2.0.0)
builder (>= 2.1.2)
Expand Down Expand Up @@ -148,7 +158,7 @@ GEM
grape-swagger-ui (2.2.8)
railties (>= 3.1)
hashie (3.6.0)
highline (2.0.0)
highline (2.0.1)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
Expand Down Expand Up @@ -244,7 +254,7 @@ GEM
netrc (0.11.0)
nifty-generators (0.4.6)
nio4r (2.3.1)
nokogiri (1.10.1)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
nokogumbo (2.0.1)
nokogiri (~> 1.8, >= 1.8.4)
Expand All @@ -263,7 +273,7 @@ GEM
omniauth-github (1.3.0)
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0, < 2.0)
omniauth-google-oauth2 (0.6.0)
omniauth-google-oauth2 (0.6.1)
jwt (>= 2.0)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.5)
Expand All @@ -284,8 +294,8 @@ GEM
mime-types
mimemagic (~> 0.3.0)
terrapin (~> 0.6.0)
parallel (1.14.0)
parser (2.6.0.0)
parallel (1.16.2)
parser (2.6.2.0)
ast (~> 2.4.0)
passenger (6.0.2)
rack
Expand All @@ -303,10 +313,11 @@ GEM
pry (>= 0.10.4)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.1)
rack (2.0.6)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.0.2)
rack-cors (1.0.3)
rack-openid (1.4.2)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
Expand Down Expand Up @@ -359,6 +370,7 @@ GEM
json
redis (4.1.0)
ref (2.0.0)
regexp_parser (1.3.0)
request_store (1.4.1)
rack (>= 1.4)
responders (2.4.1)
Expand Down Expand Up @@ -394,6 +406,7 @@ GEM
ruby-openid (2.7.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
rubyzip (1.2.2)
sanitize (5.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
Expand All @@ -411,6 +424,10 @@ GEM
tilt (>= 1.1, < 3)
scrypt (3.0.6)
ffi-compiler (>= 1.0, < 2.0)
selenium-webdriver (3.3.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
websocket (~> 1.0)
sentry-raven (2.9.0)
faraday (>= 0.7.6, < 1.0)
sidekiq (5.2.5)
Expand Down Expand Up @@ -487,6 +504,7 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket (1.2.8)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
Expand All @@ -495,6 +513,8 @@ GEM
will_paginate (3.1.7)
will_paginate-bootstrap (1.0.2)
will_paginate (>= 3.0.3)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
Expand All @@ -504,6 +524,7 @@ DEPENDENCIES
authlogic (= 4.4.2)
authlogic-oid
byebug
capybara
ci_reporter_test_unit
coffee-rails (~> 4.2.2)
composite_primary_keys
Expand Down Expand Up @@ -553,6 +574,7 @@ DEPENDENCIES
php-serialize
progress_bar
pry-rails
puma (~> 3.12)
rack-cors
rack-openid
rack-test (= 1.1.0)
Expand All @@ -575,6 +597,7 @@ DEPENDENCIES
sanitize
sass-rails (~> 5.0, >= 5.0.7)
scrypt (~> 3)
selenium-webdriver (~> 3.3.0)
sentry-raven
sidekiq
skylight
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ For information on how to install for use with the cloud environment, please see
9. By default, start rails with `passenger start` from the Rails root and open http://localhost:3000 in a web browser.
(for local SSL work, see [SSL](#ssl+in+development) below)
10. Wheeeee! You're up and running! Log in with test usernames "user", "moderator", or "admin", and password "password".
11. Run `rails test -d` to confirm that your install is working properly.
11. Run `rails test` to confirm that your install is working properly. Or `rails test:system` for system tests.

## SSL in Development

Expand Down
7 changes: 7 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
chromeOptions = %w(--headless --disable-gpu --no-sandbox --remote-debugging-port=9222)
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => chromeOptions})
driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { desired_capabilities: caps }
end
13 changes: 13 additions & 0 deletions test/system/search_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "application_system_test_case"
# https://guides.rubyonrails.org/testing.html#implementing-a-system-test

class SearchTest < ApplicationSystemTestCase
test 'searching an item from the homepage' do
visit '/'

fill_in("searchform_input", with: "Canon")
find('button.btn-default').click

assert_selector('h2', text: 'Results for Canon')
end
end

0 comments on commit a95ba1f

Please sign in to comment.