fix(spec): fix system test

This commit is contained in:
Paul Chavard 2024-06-21 17:03:15 +02:00
parent ecc847ae3d
commit 89fb0abe6e
No known key found for this signature in database
3 changed files with 189 additions and 465 deletions

View file

@ -62,6 +62,10 @@ export class TurboController extends ApplicationController {
// They allow us to preserve certain HTML changes across mutations. // They allow us to preserve certain HTML changes across mutations.
this.#actions.observe(); this.#actions.observe();
this.#actions.ready().then(() => {
document.body.classList.add('dom-ready');
});
// setup spinner events // setup spinner events
this.onGlobal('turbo:submit-start', () => this.startSpinner()); this.onGlobal('turbo:submit-start', () => this.startSpinner());
this.onGlobal('turbo:submit-end', () => this.stopSpinner()); this.onGlobal('turbo:submit-end', () => this.stopSpinner());

File diff suppressed because one or more lines are too long

View file

@ -10,6 +10,10 @@ describe 'The user' do
log_in(user, procedure) log_in(user, procedure)
fill_individual fill_individual
# wait for react components to be initialized
find('.dom-ready')
# fill data # fill data
fill_in('text', with: 'super texte', match: :first) fill_in('text', with: 'super texte', match: :first)
fill_in('textarea', with: 'super textarea') fill_in('textarea', with: 'super textarea')
@ -37,16 +41,23 @@ describe 'The user' do
select('Martinique', from: form_id_for('regions')) select('Martinique', from: form_id_for('regions'))
select('02 Aisne', from: form_id_for('departements')) select('02 Aisne', from: form_id_for('departements'))
scroll_to(find_field('communes'), align: :center)
fill_in('communes', with: '60400') fill_in('communes', with: '60400')
find('.fr-menu__item', text: 'Brétigny (60400)').click find('.fr-menu__item', text: 'Brétigny (60400)').click
wait_until { champ_value_for('communes') == "Brétigny" } wait_until { champ_value_for('communes') == "Brétigny" }
scroll_to(find_field('address'), align: :center)
fill_in('address', with: '78 Rue du Grés 30310 Vergè') fill_in('address', with: '78 Rue du Grés 30310 Vergè')
find('.fr-menu__item', text: '78 Rue du Grés 30310 Vergèze').click find('.fr-menu__item', text: '78 Rue du Grés 30310 Vergèze').click
wait_until { champ_value_for('address') == '78 Rue du Grés 30310 Vergèze' } wait_until { champ_value_for('address') == '78 Rue du Grés 30310 Vergèze' }
wait_until { champ_for('address').full_address? } wait_until { champ_for('address').full_address? }
expect(champ_for('address').departement_code_and_name).to eq('30 Gard') expect(champ_for('address').departement_code_and_name).to eq('30 Gard')
scroll_to(find_field('annuaire_education'), align: :center)
fill_in('annuaire_education', with: 'Moulin')
find('.fr-menu__item', text: 'Ecole primaire Jean Moulin, Moulins (0030323K)').click
wait_until { champ_for('annuaire_education').external_id == "0030323K" }
fill_in('dossier_link', with: '123') fill_in('dossier_link', with: '123')
find('.editable-champ-piece_justificative input[type=file]').attach_file(Rails.root + 'spec/fixtures/files/file.pdf') find('.editable-champ-piece_justificative input[type=file]').attach_file(Rails.root + 'spec/fixtures/files/file.pdf')