Merge pull request #2323 from betagouv/fix-flacky-features

Améliore la stabilité de tests peu fiables
This commit is contained in:
Paul Chavard 2018-08-01 11:55:23 +02:00 committed by GitHub
commit 8b23cbd272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 15 deletions

View file

@ -5,7 +5,8 @@ module.exports = {
sourceType: 'module'
},
globals: {
'$': true
'$': true,
'process': true
},
plugins: ['prettier'],
extends: ['eslint:recommended', 'prettier'],

View file

@ -18,8 +18,14 @@ Rails.start();
Turbolinks.start();
ActiveStorage.start();
// Disable jQuery-driven animations during tests
if (process.env['RAILS_ENV'] === 'test') {
jQuery.fx.off = true;
}
// Expose globals
window.Bloodhound = Bloodhound;
window.Chartkick = Chartkick;
// Export jQuery globally for legacy Javascript files used in the old design
window.$ = jQuery;
window.jQuery = jQuery;

View file

@ -4,6 +4,7 @@ import * as ActiveStorage from 'activestorage';
import Chartkick from 'chartkick';
import Highcharts from 'highcharts';
import jQuery from 'jquery';
import 'select2';
import 'typeahead.js';
@ -45,6 +46,11 @@ Rails.start();
Turbolinks.start();
ActiveStorage.start();
// Disable jQuery-driven animations during tests
if (process.env['RAILS_ENV'] === 'test') {
jQuery.fx.off = true;
}
// Expose globals
window.DS = window.DS || DS;
window.Chartkick = Chartkick;

View file

@ -14,7 +14,6 @@
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
= javascript_pack_tag 'application-old', defer: true, 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
= csrf_meta_tags
:javascript
@ -26,14 +25,8 @@
#beta
Env Test
- if Rails.env == 'test'
%script{ type: 'text/javascript' }
(typeof jQuery !== 'undefined') && (jQuery.fx.off = true);
= render partial: 'layouts/ie_lt_10'
#wrap
.row
#header.navbar

View file

@ -44,6 +44,3 @@
= javascript_include_tag :xray
= yield :charts_js
- if Rails.env == "test"
%script{ type: "text/javascript" }
(typeof jQuery !== "undefined") && (jQuery.fx.off = true);

View file

@ -66,7 +66,7 @@ feature 'As a User I wanna create a dossier' do
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_with_siret.path)
expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s))
fill_in 'dossier-siret', with: siret
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/)
@ -75,8 +75,11 @@ feature 'As a User I wanna create a dossier' do
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/)
.to_return(status: 404, body: '')
page.find_by_id('dossier-siret').set siret
page.find_by_id('submit-siret').click
wait_for_ajax
expect(page).to have_css('#recap-info-entreprise')
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
page.find_by_id('etape_suivante').click

View file

@ -47,8 +47,6 @@ Capybara.register_driver :headless_chrome do |app|
desired_capabilities: capabilities
end
ActiveSupport::Deprecation.silenced = true
Capybara.default_max_wait_time = 1
# Save a snapshot of the HTML page when an integration test fails
@ -69,6 +67,8 @@ Dir[Rails.root.join('spec', 'factories', '**', '*.rb')].each { |f| require f }
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
ActiveSupport::Deprecation.silenced = true
VCR.configure do |c|
c.ignore_localhost = true
c.hook_into :webmock

View file

@ -1,4 +1,3 @@
# spec/support/wait_for_ajax.rb
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do