mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 09:13:05 +08:00
Fix cucumber tests, switch to chromium-driver [SCI-3786]
This commit is contained in:
parent
f94b8165dc
commit
3a87296c7b
10 changed files with 41 additions and 88 deletions
|
@ -3,6 +3,8 @@ env:
|
|||
|
||||
sudo: required
|
||||
language: ruby
|
||||
addons:
|
||||
chrome: stable
|
||||
install: true
|
||||
services:
|
||||
- docker
|
||||
|
|
|
@ -15,7 +15,8 @@ RUN apt-get update -qq && \
|
|||
poppler-utils \
|
||||
sudo graphviz --no-install-recommends \
|
||||
libreoffice \
|
||||
libfile-mimeinfo-perl && \
|
||||
libfile-mimeinfo-perl \
|
||||
chromium-driver && \
|
||||
npm install -g yarn && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
|
5
Gemfile
5
Gemfile
|
@ -132,11 +132,10 @@ end
|
|||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'capybara-email'
|
||||
gem 'cucumber-rails', '~> 1.5', require: false
|
||||
gem 'cucumber-rails', '~> 1.7', require: false
|
||||
gem 'database_cleaner'
|
||||
gem 'json_matchers'
|
||||
gem 'phantomjs', require: 'phantomjs/poltergeist'
|
||||
gem 'poltergeist'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'shoulda-matchers'
|
||||
gem 'simplecov', require: false
|
||||
gem 'webmock'
|
||||
|
|
18
Gemfile.lock
18
Gemfile.lock
|
@ -174,7 +174,6 @@ GEM
|
|||
childprocess (1.0.1)
|
||||
rake (< 13.0)
|
||||
climate_control (0.2.0)
|
||||
cliver (0.3.2)
|
||||
coderay (1.1.2)
|
||||
coffee-rails (5.0.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
|
@ -341,7 +340,7 @@ GEM
|
|||
rails (>= 3.2.0)
|
||||
newrelic_rpm (6.5.0.357)
|
||||
nio4r (2.4.0)
|
||||
nokogiri (1.10.3)
|
||||
nokogiri (1.10.4)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
nokogumbo (2.0.1)
|
||||
nokogiri (~> 1.8, >= 1.8.4)
|
||||
|
@ -379,11 +378,6 @@ GEM
|
|||
pg_search (2.3.0)
|
||||
activerecord (>= 4.2)
|
||||
activesupport (>= 4.2)
|
||||
phantomjs (2.1.1.0)
|
||||
poltergeist (1.18.1)
|
||||
capybara (>= 2.1, < 4)
|
||||
cliver (~> 0.3.1)
|
||||
websocket-driver (>= 0.2.0)
|
||||
polyglot (0.3.5)
|
||||
pry (0.12.2)
|
||||
coderay (~> 1.1.0)
|
||||
|
@ -424,7 +418,7 @@ GEM
|
|||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.1.0)
|
||||
rails-html-sanitizer (1.2.0)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
rails_12factor (0.0.3)
|
||||
rails_serve_static_assets
|
||||
|
@ -513,6 +507,9 @@ GEM
|
|||
railties (>= 4.0.0)
|
||||
sdoc (1.0.0)
|
||||
rdoc (>= 5.0)
|
||||
selenium-webdriver (3.142.3)
|
||||
childprocess (>= 0.5, < 2.0)
|
||||
rubyzip (~> 1.2, >= 1.2.2)
|
||||
shoulda-matchers (4.1.2)
|
||||
activesupport (>= 4.2.0)
|
||||
silencer (1.0.1)
|
||||
|
@ -604,7 +601,7 @@ DEPENDENCIES
|
|||
capybara-email
|
||||
caracal-rails
|
||||
commit_param_routing
|
||||
cucumber-rails (~> 1.5)
|
||||
cucumber-rails (~> 1.7)
|
||||
database_cleaner
|
||||
deface (~> 1.0)
|
||||
delayed_job_active_record
|
||||
|
@ -645,8 +642,6 @@ DEPENDENCIES
|
|||
paperclip (~> 6.1)
|
||||
pg (~> 1.1)
|
||||
pg_search
|
||||
phantomjs
|
||||
poltergeist
|
||||
pry
|
||||
pry-byebug
|
||||
pry-rails
|
||||
|
@ -669,6 +664,7 @@ DEPENDENCIES
|
|||
sassc-rails
|
||||
scenic (~> 1.4)
|
||||
sdoc (~> 1.0)
|
||||
selenium-webdriver
|
||||
shoulda-matchers
|
||||
silencer
|
||||
simple_token_authentication (~> 1.15.1)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<%
|
||||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
||||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
||||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
||||
rerun = rerun.strip.gsub /\s/, ' '
|
||||
rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
||||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'"
|
||||
%>
|
||||
default: <%= std_opts %> features
|
||||
wip: --tags @wip:3 --wip features
|
||||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
||||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip'
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = false
|
||||
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
config.after_initialize do
|
||||
|
@ -58,21 +60,7 @@ Rails.application.configure do
|
|||
}
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.default_url_options = { host: Rails.application.secrets.mail_server_url }
|
||||
config.action_mailer.default_options = { from: Rails.application.secrets.mail_from }
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
# config.action_mailer.delivery_method = :smtp
|
||||
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: Rails.application.secrets.mailer_address,
|
||||
port: Rails.application.secrets.mailer_port,
|
||||
domain: Rails.application.secrets.mailer_domain,
|
||||
authentication: Rails.application.secrets.mailer_authentication,
|
||||
enable_starttls_auto: true,
|
||||
user_name: Rails.application.secrets.mailer_user_name,
|
||||
password: Rails.application.secrets.mailer_password
|
||||
}
|
||||
#config.action_mailer.perform_deliveries = false
|
||||
|
||||
# Randomize the order test cases are executed.
|
||||
config.active_support.test_order = :random
|
||||
|
|
|
@ -26,14 +26,6 @@ Scenario: Unsuccessful avatar image upload, file is too big
|
|||
And I trigger click '#user-avatar-field .btn-success'
|
||||
And I should see "Your avatar file cannot be larger than 0.2 MB. (Please try again with a smaller file.)" error message
|
||||
|
||||
@javascript
|
||||
Scenario: Unsuccessful avatar image upload, file is invalid
|
||||
Given I'm on the profile page
|
||||
Then I click on image within ".avatar-container" element
|
||||
And I attach a "File.txt" file to "user_raw_avatar" field
|
||||
And I click on "Upload"
|
||||
And I should see "Avatar content type is invalid" error message
|
||||
|
||||
@javascript
|
||||
Scenario: Successful upload avatar image
|
||||
Given I'm on the profile page
|
||||
|
|
|
@ -3,7 +3,7 @@ When(/^I click "(.+)" button$/) do |button|
|
|||
end
|
||||
|
||||
Then("I trigger click {string}") do |string|
|
||||
find(string).trigger('click')
|
||||
page.execute_script("$('#{string}').trigger('click')")
|
||||
end
|
||||
|
||||
Given(/^Show me the page$/) do
|
||||
|
|
|
@ -3,49 +3,25 @@
|
|||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||
# files.
|
||||
ENV['CUCUMBER'] = 'cucumber'
|
||||
|
||||
require 'cucumber/rails'
|
||||
require 'capybara'
|
||||
require 'capybara/cucumber'
|
||||
require 'simplecov'
|
||||
require 'capybara/poltergeist'
|
||||
require 'phantomjs'
|
||||
require 'capybara/email'
|
||||
|
||||
Capybara.register_driver :poltergeist do |app|
|
||||
options = {
|
||||
# inspector: true,
|
||||
screen_size: [2560, 900],
|
||||
js_errors: false,
|
||||
timeout: 30,
|
||||
phantomjs: Phantomjs.path,
|
||||
phantomjs_options: [
|
||||
'--ignore-ssl-errors=yes',
|
||||
'--output-encoding=utf8'
|
||||
]
|
||||
}
|
||||
Capybara::Poltergeist::Driver.new(app, options)
|
||||
end
|
||||
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
Capybara.default_max_wait_time = 30
|
||||
Capybara.asset_host = 'http://localhost:3001'
|
||||
Capybara.server_port = 3001
|
||||
|
||||
# Capybara.asset_host = 'http://localhost:3001'
|
||||
# Capybara.server_port = 3001
|
||||
require 'selenium/webdriver'
|
||||
# enables email helper methods
|
||||
World(Capybara::Email::DSL)
|
||||
|
||||
# Precompile webpacker to avoid render bugs in capybara webkit
|
||||
# global hook throws an error :( https://github.com/cucumber/cucumber/wiki/Hooks
|
||||
Capybara.register_driver :chrome do |app|
|
||||
options = Selenium::WebDriver::Chrome::Options.new(args: %w(no-sandbox headless disable-gpu))
|
||||
|
||||
# No need to run webpacker since we don't user React in the momemnt
|
||||
# compiled = false
|
||||
# Before do
|
||||
# unless compiled
|
||||
# system('NODE_ENV=production bundle exec rails webpacker:compile')
|
||||
# compiled = true
|
||||
# end
|
||||
# end
|
||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
||||
end
|
||||
|
||||
Capybara.javascript_driver = :chrome
|
||||
|
||||
# Capybara defaults to CSS3 selectors rather than XPath.
|
||||
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
||||
|
@ -83,12 +59,15 @@ end
|
|||
# See the DatabaseCleaner documentation for details. Example:
|
||||
#
|
||||
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
||||
# # { :except => [:widgets] } may not do what you expect here
|
||||
# # { except: [:widgets] } may not do what you expect here
|
||||
# # as Cucumber::Rails::Database.javascript_strategy overrides
|
||||
# # this setting.
|
||||
# DatabaseCleaner.strategy = :truncation
|
||||
# end
|
||||
#
|
||||
# Before('not @no-txn', 'not @selenium', 'not @culerity', 'not @celerity', 'not @javascript') do
|
||||
# DatabaseCleaner.strategy = :transaction
|
||||
# end
|
||||
#
|
||||
|
||||
# Possible values are :truncation and :transaction
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||
# files.
|
||||
|
||||
# Don't load anything when running the gems:* tasks
|
||||
unless ARGV.any? { |a| a =~ /^gems/ }
|
||||
|
||||
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
||||
|
||||
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
||||
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
||||
|
@ -14,22 +14,19 @@ begin
|
|||
require 'cucumber/rake/task'
|
||||
|
||||
namespace :cucumber do
|
||||
Cucumber::Rake::Task.new({ ok: 'test:prepare' },
|
||||
'Run features that should pass') do |t|
|
||||
Cucumber::Rake::Task.new({ok: 'test:prepare'}, 'Run features that should pass') do |t|
|
||||
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
||||
t.fork = true # You may get faster startup if you set this to false
|
||||
t.profile = 'default'
|
||||
end
|
||||
|
||||
Cucumber::Rake::Task.new({ wip: 'test:prepare' },
|
||||
'Run features that are being worked on') do |t|
|
||||
Cucumber::Rake::Task.new({wip: 'test:prepare'}, 'Run features that are being worked on') do |t|
|
||||
t.binary = vendored_cucumber_bin
|
||||
t.fork = true # You may get faster startup if you set this to false
|
||||
t.profile = 'wip'
|
||||
end
|
||||
|
||||
Cucumber::Rake::Task.new({ rerun: 'test:prepare' },
|
||||
'Record failing features and run only them if any exist') do |t|
|
||||
Cucumber::Rake::Task.new({rerun: 'test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
||||
t.binary = vendored_cucumber_bin
|
||||
t.fork = true # You may get faster startup if you set this to false
|
||||
t.profile = 'rerun'
|
||||
|
@ -41,16 +38,14 @@ begin
|
|||
task :statsetup do
|
||||
require 'rails/code_statistics'
|
||||
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
||||
::CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features')
|
||||
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
|
||||
end
|
||||
|
||||
task :annotations_setup do
|
||||
Rails.application.configure do
|
||||
if config.respond_to?(:annotations)
|
||||
config.annotations.directories << 'features'
|
||||
config.annotations.register_extensions('feature') do |tag|
|
||||
/#\s*(#{tag}):?\s*(.*)$/
|
||||
end
|
||||
config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue