fix specs
This commit is contained in:
parent
75c155c284
commit
c88e6ab75c
3 changed files with 30 additions and 24 deletions
|
@ -70,22 +70,15 @@ module SystemHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add a new type de champ in the procedure editor
|
# Add a new type de champ in the procedure editor
|
||||||
def add_champ(options = {})
|
def add_champ
|
||||||
add_champs(**options)
|
click_on 'Ajouter un champ'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add several new type de champ in the procedure editor
|
def remove_flash_message
|
||||||
def add_champs(count: 1, remove_flash_message: false)
|
|
||||||
within '.buttons' do
|
|
||||||
count.times { click_on 'Ajouter un champ' }
|
|
||||||
end
|
|
||||||
|
|
||||||
if remove_flash_message
|
|
||||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||||
expect(page).to have_content('Formulaire enregistré')
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
execute_script("document.querySelector('#flash_message').remove();")
|
execute_script("document.querySelector('#flash_message').remove();")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def blur
|
def blur
|
||||||
page.find('body').click
|
page.find('body').click
|
||||||
|
|
|
@ -33,12 +33,14 @@ describe 'Creating a new procedure', js: true, retry: 3 do
|
||||||
scenario 'an admin can add types de champs' do
|
scenario 'an admin can add types de champs' do
|
||||||
visit champs_admin_procedure_path(procedure)
|
visit champs_admin_procedure_path(procedure)
|
||||||
|
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
fill_in 'Libellé du champ', with: 'libelle de champ'
|
fill_in 'Libellé du champ', with: 'libelle de champ'
|
||||||
blur
|
blur
|
||||||
expect(page).to have_content('Formulaire enregistré')
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
expect(page).to have_selector('select > optgroup', count: 8)
|
expect(page).to have_selector('select > optgroup', count: 8)
|
||||||
|
|
||||||
|
page.refresh
|
||||||
add_champ
|
add_champ
|
||||||
expect(page).to have_selector('.type-de-champ', count: 1)
|
expect(page).to have_selector('.type-de-champ', count: 1)
|
||||||
end
|
end
|
||||||
|
@ -47,7 +49,8 @@ describe 'Creating a new procedure', js: true, retry: 3 do
|
||||||
visit champs_admin_procedure_path(procedure)
|
visit champs_admin_procedure_path(procedure)
|
||||||
|
|
||||||
# Add an empty repetition type de champ
|
# Add an empty repetition type de champ
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
select('Bloc répétable', from: 'Type de champ')
|
select('Bloc répétable', from: 'Type de champ')
|
||||||
fill_in 'Libellé du champ', with: 'libellé de champ'
|
fill_in 'Libellé du champ', with: 'libellé de champ'
|
||||||
blur
|
blur
|
||||||
|
|
|
@ -29,7 +29,12 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
|
|
||||||
scenario "adding multiple champs" do
|
scenario "adding multiple champs" do
|
||||||
# Champs are created when clicking the 'Add field' button
|
# Champs are created when clicking the 'Add field' button
|
||||||
add_champs(count: 3)
|
add_champ
|
||||||
|
page.refresh
|
||||||
|
add_champ
|
||||||
|
within(find('.type-de-champ-add-button', match: :first)) {
|
||||||
|
add_champ
|
||||||
|
}
|
||||||
|
|
||||||
# Champs are automatically saved
|
# Champs are automatically saved
|
||||||
expect(page).to have_button('Ajouter un champ', disabled: false)
|
expect(page).to have_button('Ajouter un champ', disabled: false)
|
||||||
|
@ -64,7 +69,8 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "removing champs" do
|
scenario "removing champs" do
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
|
|
||||||
fill_in 'Libellé du champ', with: 'libellé de champ'
|
fill_in 'Libellé du champ', with: 'libellé de champ'
|
||||||
expect(page).to have_content('Formulaire enregistré')
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
|
@ -82,7 +88,8 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "adding an invalid champ" do
|
scenario "adding an invalid champ" do
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
|
|
||||||
fill_in 'Libellé du champ', with: ''
|
fill_in 'Libellé du champ', with: ''
|
||||||
fill_in 'Description du champ (optionnel)', with: 'description du champ'
|
fill_in 'Description du champ (optionnel)', with: 'description du champ'
|
||||||
|
@ -93,7 +100,8 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "adding a repetition champ" do
|
scenario "adding a repetition champ" do
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
|
|
||||||
select('Bloc répétable', from: 'Type de champ')
|
select('Bloc répétable', from: 'Type de champ')
|
||||||
fill_in 'Libellé du champ', with: 'libellé de champ'
|
fill_in 'Libellé du champ', with: 'libellé de champ'
|
||||||
|
@ -110,9 +118,7 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
expect(page).to have_content('Formulaire enregistré')
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
expect(page).to have_content('Supprimer', count: 2)
|
expect(page).to have_content('Supprimer', count: 2)
|
||||||
|
|
||||||
within '.buttons' do
|
page.all('.fr-icon-add-line')[2].click
|
||||||
click_on 'Ajouter un champ'
|
|
||||||
end
|
|
||||||
|
|
||||||
within '.type-de-champ:nth-child(2)' do
|
within '.type-de-champ:nth-child(2)' do
|
||||||
select('Bloc répétable', from: 'Type de champ')
|
select('Bloc répétable', from: 'Type de champ')
|
||||||
|
@ -123,7 +129,8 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "adding a carte champ" do
|
scenario "adding a carte champ" do
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
|
|
||||||
select('Carte', from: 'Type de champ')
|
select('Carte', from: 'Type de champ')
|
||||||
fill_in 'Libellé du champ', with: 'Libellé de champ carte', fill_options: { clear: :backspace }
|
fill_in 'Libellé du champ', with: 'Libellé de champ carte', fill_options: { clear: :backspace }
|
||||||
|
@ -133,6 +140,7 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
wait_until { procedure.active_revision.types_de_champ_public.first.libelle == 'Libellé de champ carte' }
|
wait_until { procedure.active_revision.types_de_champ_public.first.libelle == 'Libellé de champ carte' }
|
||||||
expect(page).to have_content('Formulaire enregistré')
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
|
|
||||||
|
page.refresh
|
||||||
preview_window = window_opened_by { click_on 'Prévisualiser le formulaire' }
|
preview_window = window_opened_by { click_on 'Prévisualiser le formulaire' }
|
||||||
within_window(preview_window) do
|
within_window(preview_window) do
|
||||||
expect(page).to have_content('Libellé de champ carte')
|
expect(page).to have_content('Libellé de champ carte')
|
||||||
|
@ -143,7 +151,8 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "adding a dropdown champ" do
|
scenario "adding a dropdown champ" do
|
||||||
add_champ(remove_flash_message: true)
|
add_champ
|
||||||
|
remove_flash_message
|
||||||
|
|
||||||
select('Choix simple', from: 'Type de champ')
|
select('Choix simple', from: 'Type de champ')
|
||||||
fill_in 'Libellé du champ', with: 'Libellé de champ menu déroulant', fill_options: { clear: :backspace }
|
fill_in 'Libellé du champ', with: 'Libellé de champ menu déroulant', fill_options: { clear: :backspace }
|
||||||
|
@ -203,6 +212,7 @@ describe 'As an administrateur I can edit types de champ', js: true, retry: 3 do
|
||||||
first_header = procedure.active_revision.types_de_champ_public.first
|
first_header = procedure.active_revision.types_de_champ_public.first
|
||||||
select('Titre de niveau 1', from: dom_id(first_header, :header_section_level))
|
select('Titre de niveau 1', from: dom_id(first_header, :header_section_level))
|
||||||
|
|
||||||
|
page.refresh
|
||||||
add_champ
|
add_champ
|
||||||
wait_until { procedure.reload.active_revision.types_de_champ_public.count == 2 }
|
wait_until { procedure.reload.active_revision.types_de_champ_public.count == 2 }
|
||||||
second_header = procedure.active_revision.types_de_champ_public.last
|
second_header = procedure.active_revision.types_de_champ_public.last
|
||||||
|
|
Loading…
Reference in a new issue