2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-11-25 16:26:55 +01:00
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
describe 'Creating a new procedure', js: true do
|
2018-05-23 23:32:49 +02:00
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
2024-06-01 22:50:48 +02:00
|
|
|
let(:administrateur) { administrateurs(:default_admin) }
|
2016-12-14 17:13:40 +01:00
|
|
|
|
|
|
|
before do
|
2019-08-09 10:46:39 +02:00
|
|
|
login_as administrateur.user, scope: :user
|
2016-12-14 17:13:40 +01:00
|
|
|
visit root_path
|
|
|
|
end
|
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
scenario 'an admin can create a new procedure from scratch' do
|
|
|
|
expect(page).to have_selector('#new-procedure')
|
|
|
|
find('#new-procedure').click
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
expect(page).to have_current_path(new_from_existing_admin_procedures_path)
|
|
|
|
click_on 'Créer une nouvelle démarche de zéro'
|
|
|
|
expect(find('#procedure_for_individual_true')).to be_checked
|
|
|
|
expect(find('#procedure_for_individual_false')).not_to be_checked
|
|
|
|
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
|
|
|
click_on 'Créer la démarche'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
fill_in_dummy_procedure_details
|
|
|
|
click_on 'Créer la démarche'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
expect(page).to have_current_path(champs_admin_procedure_path(Procedure.last))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
context 'with an empty procedure' do
|
|
|
|
let(:procedure) { create(:procedure, :with_service, administrateur: administrateur) }
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2021-11-23 14:12:27 +01:00
|
|
|
scenario 'an admin can add types de champs' do
|
|
|
|
visit champs_admin_procedure_path(procedure)
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2023-10-17 12:25:58 +02:00
|
|
|
add_champ
|
2023-11-23 14:45:54 +01:00
|
|
|
hide_autonotice_message
|
|
|
|
|
2022-06-16 14:56:53 +02:00
|
|
|
fill_in 'Libellé du champ', with: 'libelle de champ'
|
2019-07-25 14:03:18 +02:00
|
|
|
blur
|
|
|
|
expect(page).to have_content('Formulaire enregistré')
|
2022-11-28 17:41:46 +01:00
|
|
|
expect(page).to have_selector('select > optgroup', count: 8)
|
2018-11-14 16:28:02 +01:00
|
|
|
|
2023-10-19 17:42:10 +02:00
|
|
|
within(find('.type-de-champ-add-button', match: :first)) {
|
|
|
|
add_champ
|
|
|
|
}
|
2022-06-16 14:56:53 +02:00
|
|
|
expect(page).to have_selector('.type-de-champ', count: 1)
|
2019-07-25 14:03:18 +02:00
|
|
|
end
|
2021-11-24 11:08:57 +01:00
|
|
|
|
|
|
|
scenario 'a warning is displayed when creating an invalid procedure' do
|
|
|
|
visit champs_admin_procedure_path(procedure)
|
|
|
|
|
|
|
|
# Add an empty repetition type de champ
|
2023-10-17 12:25:58 +02:00
|
|
|
add_champ
|
2023-11-23 14:45:54 +01:00
|
|
|
hide_autonotice_message
|
2022-06-16 14:56:53 +02:00
|
|
|
select('Bloc répétable', from: 'Type de champ')
|
|
|
|
fill_in 'Libellé du champ', with: 'libellé de champ'
|
2021-11-24 11:08:57 +01:00
|
|
|
blur
|
|
|
|
expect(page).to have_content('Formulaire enregistré')
|
|
|
|
|
|
|
|
click_link procedure.libelle
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(procedure))
|
|
|
|
|
2022-10-14 16:55:29 +02:00
|
|
|
champs_card = find('.fr-tile', text: 'Champs du formulaire')
|
2023-11-28 13:53:43 +01:00
|
|
|
expect(champs_card).to have_selector('.fr-badge--error')
|
2021-11-24 11:08:57 +01:00
|
|
|
expect(champs_card).to have_content('À modifier')
|
|
|
|
end
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
end
|