Merge pull request #2323 from betagouv/fix-flacky-features
Améliore la stabilité de tests peu fiables
This commit is contained in:
commit
8b23cbd272
8 changed files with 20 additions and 15 deletions
|
@ -5,7 +5,8 @@ module.exports = {
|
||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
},
|
},
|
||||||
globals: {
|
globals: {
|
||||||
'$': true
|
'$': true,
|
||||||
|
'process': true
|
||||||
},
|
},
|
||||||
plugins: ['prettier'],
|
plugins: ['prettier'],
|
||||||
extends: ['eslint:recommended', 'prettier'],
|
extends: ['eslint:recommended', 'prettier'],
|
||||||
|
|
|
@ -18,8 +18,14 @@ Rails.start();
|
||||||
Turbolinks.start();
|
Turbolinks.start();
|
||||||
ActiveStorage.start();
|
ActiveStorage.start();
|
||||||
|
|
||||||
|
// Disable jQuery-driven animations during tests
|
||||||
|
if (process.env['RAILS_ENV'] === 'test') {
|
||||||
|
jQuery.fx.off = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Expose globals
|
// Expose globals
|
||||||
window.Bloodhound = Bloodhound;
|
window.Bloodhound = Bloodhound;
|
||||||
window.Chartkick = Chartkick;
|
window.Chartkick = Chartkick;
|
||||||
|
// Export jQuery globally for legacy Javascript files used in the old design
|
||||||
window.$ = jQuery;
|
window.$ = jQuery;
|
||||||
window.jQuery = jQuery;
|
window.jQuery = jQuery;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as ActiveStorage from 'activestorage';
|
||||||
|
|
||||||
import Chartkick from 'chartkick';
|
import Chartkick from 'chartkick';
|
||||||
import Highcharts from 'highcharts';
|
import Highcharts from 'highcharts';
|
||||||
|
import jQuery from 'jquery';
|
||||||
|
|
||||||
import 'select2';
|
import 'select2';
|
||||||
import 'typeahead.js';
|
import 'typeahead.js';
|
||||||
|
@ -45,6 +46,11 @@ Rails.start();
|
||||||
Turbolinks.start();
|
Turbolinks.start();
|
||||||
ActiveStorage.start();
|
ActiveStorage.start();
|
||||||
|
|
||||||
|
// Disable jQuery-driven animations during tests
|
||||||
|
if (process.env['RAILS_ENV'] === 'test') {
|
||||||
|
jQuery.fx.off = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Expose globals
|
// Expose globals
|
||||||
window.DS = window.DS || DS;
|
window.DS = window.DS || DS;
|
||||||
window.Chartkick = Chartkick;
|
window.Chartkick = Chartkick;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
|
= stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track': "reload"
|
||||||
= javascript_pack_tag 'application-old', defer: true, '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'
|
= javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload'
|
||||||
|
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
|
@ -26,14 +25,8 @@
|
||||||
#beta
|
#beta
|
||||||
Env Test
|
Env Test
|
||||||
|
|
||||||
- if Rails.env == 'test'
|
|
||||||
%script{ type: 'text/javascript' }
|
|
||||||
(typeof jQuery !== 'undefined') && (jQuery.fx.off = true);
|
|
||||||
|
|
||||||
|
|
||||||
= render partial: 'layouts/ie_lt_10'
|
= render partial: 'layouts/ie_lt_10'
|
||||||
|
|
||||||
|
|
||||||
#wrap
|
#wrap
|
||||||
.row
|
.row
|
||||||
#header.navbar
|
#header.navbar
|
||||||
|
|
|
@ -44,6 +44,3 @@
|
||||||
= javascript_include_tag :xray
|
= javascript_include_tag :xray
|
||||||
|
|
||||||
= yield :charts_js
|
= yield :charts_js
|
||||||
- if Rails.env == "test"
|
|
||||||
%script{ type: "text/javascript" }
|
|
||||||
(typeof jQuery !== "undefined") && (jQuery.fx.off = true);
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ feature 'As a User I wanna create a dossier' do
|
||||||
login_as user, scope: :user
|
login_as user, scope: :user
|
||||||
visit commencer_path(procedure_path: procedure_with_siret.path)
|
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))
|
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=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
|
||||||
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/)
|
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'))
|
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/)
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/)
|
||||||
.to_return(status: 404, body: '')
|
.to_return(status: 404, body: '')
|
||||||
|
|
||||||
page.find_by_id('dossier-siret').set siret
|
page.find_by_id('dossier-siret').set siret
|
||||||
page.find_by_id('submit-siret').click
|
page.find_by_id('submit-siret').click
|
||||||
|
wait_for_ajax
|
||||||
|
|
||||||
expect(page).to have_css('#recap-info-entreprise')
|
expect(page).to have_css('#recap-info-entreprise')
|
||||||
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
|
|
|
@ -47,8 +47,6 @@ Capybara.register_driver :headless_chrome do |app|
|
||||||
desired_capabilities: capabilities
|
desired_capabilities: capabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
ActiveSupport::Deprecation.silenced = true
|
|
||||||
|
|
||||||
Capybara.default_max_wait_time = 1
|
Capybara.default_max_wait_time = 1
|
||||||
|
|
||||||
# Save a snapshot of the HTML page when an integration test fails
|
# 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.
|
# If you are not using ActiveRecord, you can remove this line.
|
||||||
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
||||||
|
|
||||||
|
ActiveSupport::Deprecation.silenced = true
|
||||||
|
|
||||||
VCR.configure do |c|
|
VCR.configure do |c|
|
||||||
c.ignore_localhost = true
|
c.ignore_localhost = true
|
||||||
c.hook_into :webmock
|
c.hook_into :webmock
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# spec/support/wait_for_ajax.rb
|
|
||||||
module WaitForAjax
|
module WaitForAjax
|
||||||
def wait_for_ajax
|
def wait_for_ajax
|
||||||
Timeout.timeout(Capybara.default_max_wait_time) do
|
Timeout.timeout(Capybara.default_max_wait_time) do
|
||||||
|
|
Loading…
Reference in a new issue