2019-01-10 18:18:42 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'As an administrateur I edit procedure', js: true do
|
|
|
|
let(:administrateur) { procedure.administrateur }
|
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
|
|
|
|
before do
|
2019-01-17 15:15:46 +01:00
|
|
|
Flipflop::FeatureSet.current.test!.switch!(:champ_repetition, true)
|
2019-01-10 18:18:42 +01:00
|
|
|
login_as administrateur, scope: :administrateur
|
|
|
|
visit champs_procedure_path(procedure)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "Add a new champ" do
|
2019-02-04 17:08:41 +01:00
|
|
|
click_on 'Supprimer'
|
|
|
|
|
2019-01-10 18:18:42 +01:00
|
|
|
within '.footer' do
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
end
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_0_libelle')
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ'
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
|
|
|
|
page.refresh
|
|
|
|
within '.footer' do
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
end
|
|
|
|
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "Add multiple champs" do
|
|
|
|
within '.footer' do
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
end
|
|
|
|
expect(page).not_to have_content('Le libellé doit être rempli.')
|
|
|
|
expect(page).not_to have_content('Modifications non sauvegardées.')
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).not_to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ 0'
|
|
|
|
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_0_libelle')
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_1_libelle')
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_2_libelle')
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_3_libelle')
|
|
|
|
|
|
|
|
expect(page).to have_content('Le libellé doit être rempli.')
|
|
|
|
expect(page).to have_content('Modifications non sauvegardées.')
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).not_to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
fill_in 'procedure_types_de_champ_attributes_2_libelle', with: 'libellé de champ 2'
|
|
|
|
|
|
|
|
within '.draggable-item-3' do
|
|
|
|
click_on 'Supprimer'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('Le libellé doit être rempli.')
|
|
|
|
expect(page).to have_content('Modifications non sauvegardées.')
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).not_to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
fill_in 'procedure_types_de_champ_attributes_1_libelle', with: 'libellé de champ 1'
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Le libellé doit être rempli.')
|
|
|
|
expect(page).not_to have_content('Modifications non sauvegardées.')
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
page.refresh
|
|
|
|
|
|
|
|
expect(page).to have_content('Supprimer', count: 3)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "Remove champs" do
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ'
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
page.refresh
|
|
|
|
|
|
|
|
click_on 'Supprimer'
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
expect(page).not_to have_content('Supprimer')
|
|
|
|
page.refresh
|
|
|
|
|
2019-02-04 17:08:41 +01:00
|
|
|
expect(page).to have_content('Supprimer', count: 1)
|
2019-01-10 18:18:42 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it "Only add valid champs" do
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_0_description')
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_description', with: 'déscription du champ'
|
|
|
|
expect(page).to have_content('Le libellé doit être rempli.')
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).not_to have_content('Formulaire mis à jour')
|
2019-01-10 18:18:42 +01:00
|
|
|
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ'
|
2019-01-17 15:15:46 +01:00
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "Add repetition champ" do
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_0_libelle')
|
|
|
|
select('Bloc répétable', from: 'procedure_types_de_champ_attributes_0_type_champ')
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ'
|
|
|
|
|
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
|
|
|
page.refresh
|
|
|
|
|
|
|
|
within '.flex-grow' do
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_types_de_champ_attributes_0_libelle', with: 'libellé de champ 1'
|
|
|
|
|
|
|
|
expect(page).to have_content('Formulaire mis à jour')
|
|
|
|
expect(page).to have_content('Supprimer', count: 2)
|
|
|
|
|
|
|
|
within '.footer' do
|
|
|
|
click_on 'Ajouter un champ'
|
|
|
|
end
|
|
|
|
|
|
|
|
select('Bloc répétable', from: 'procedure_types_de_champ_attributes_1_type_champ')
|
|
|
|
fill_in 'procedure_types_de_champ_attributes_1_libelle', with: 'libellé de champ 2'
|
|
|
|
|
|
|
|
expect(page).to have_content('Supprimer', count: 3)
|
2019-01-10 18:18:42 +01:00
|
|
|
end
|
|
|
|
end
|