features: refactor the editor specs

- Add an `add_champ` helper
- Stop relying on a default champ being created
- Wait for all champs to be created by watching the "Add champ" button 

This should fix the flakiness of these tests.

Refs #4417
This commit is contained in:
Pierre de La Morinerie 2019-11-27 09:19:55 +00:00
parent 52051914aa
commit a328e8d94a
3 changed files with 49 additions and 34 deletions

View file

@ -69,14 +69,12 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
page.refresh
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
expect(page).to have_selector('#champ-0-libelle')
add_champ(remove_flash_message: true)
fill_in 'champ-0-libelle', with: 'libelle de champ'
blur
expect(page).to have_content('Formulaire enregistré')
within '.buttons' do
click_on 'Ajouter un champ'
end
add_champ
expect(page).to have_selector('#champ-1-libelle')
click_on Procedure.last.libelle
@ -91,6 +89,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do
scenario 'After adding champ and file, make publication' do
page.refresh
add_champ(remove_flash_message: true)
fill_in 'champ-0-libelle', with: 'libelle de champ'
blur
expect(page).to have_content('Formulaire enregistré')