2016-12-14 17:13:40 +01:00
|
|
|
require 'spec_helper'
|
2018-05-23 23:32:49 +02:00
|
|
|
require 'features/admin/procedure_spec_helper'
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2016-12-26 10:56:48 +01:00
|
|
|
feature 'As an administrateur I wanna create a new procedure', js: true do
|
2018-05-23 23:32:49 +02:00
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
2016-12-14 17:13:40 +01:00
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
login_as administrateur, scope: :administrateur
|
|
|
|
visit root_path
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Right after sign_in I shall see all procedure states links' do
|
|
|
|
scenario 'Finding draft procedures' do
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'draft-procedures'
|
2018-01-23 17:14:13 +01:00
|
|
|
expect(page).to have_current_path(admin_procedures_draft_path)
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Finding active procedures' do
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'active-procedures'
|
2018-01-23 17:14:13 +01:00
|
|
|
expect(page).to have_current_path(admin_procedures_path)
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Finding archived procedures' do
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'archived-procedures'
|
2018-01-23 17:14:13 +01:00
|
|
|
expect(page).to have_current_path(admin_procedures_archived_path)
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Creating a new procedure' do
|
2018-05-02 15:41:43 +02:00
|
|
|
scenario 'Finding save button for new procedure, libelle, description and cadre_juridique required' do
|
2018-08-07 14:12:32 +02:00
|
|
|
expect(page).to have_selector('#new-procedure')
|
|
|
|
find('#new-procedure').click
|
|
|
|
click_on 'from-scratch'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(new_admin_procedure_path)
|
2018-05-24 14:48:52 +02:00
|
|
|
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
|
|
|
fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6'
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'save-procedure'
|
|
|
|
|
|
|
|
expect(page).to have_text('Libelle doit être rempli')
|
2018-05-23 23:32:49 +02:00
|
|
|
fill_in_dummy_procedure_details
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'save-procedure'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Editing a new procedure' do
|
|
|
|
before 'Create procedure' do
|
2018-08-07 14:12:32 +02:00
|
|
|
expect(page).to have_selector('#new-procedure')
|
|
|
|
find('#new-procedure').click
|
|
|
|
click_on 'from-scratch'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(new_admin_procedure_path)
|
2018-05-23 23:32:49 +02:00
|
|
|
fill_in_dummy_procedure_details
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'save-procedure'
|
2018-04-23 16:14:29 +02:00
|
|
|
|
|
|
|
procedure = Procedure.last
|
|
|
|
procedure.update(service: create(:service))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Add champ, add file, visualize them in procedure preview' do
|
2018-08-07 14:12:32 +02:00
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libelle de champ'
|
|
|
|
click_on 'add_type_de_champ'
|
|
|
|
expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first))
|
|
|
|
expect(page).to have_selector('#procedure_types_de_champ_attributes_1_libelle')
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(Procedure.first.types_de_champ.first.libelle).to eq('libelle de champ')
|
|
|
|
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'onglet-pieces'
|
|
|
|
expect(page).to have_current_path(admin_procedure_pieces_justificatives_path(Procedure.first))
|
|
|
|
fill_in 'procedure_types_de_piece_justificative_attributes_0_libelle', with: 'libelle de piece'
|
|
|
|
click_on 'add_piece_justificative'
|
|
|
|
expect(page).to have_current_path(admin_procedure_pieces_justificatives_path(Procedure.first))
|
|
|
|
expect(page).to have_selector('#procedure_types_de_piece_justificative_attributes_1_libelle')
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2018-08-07 14:12:32 +02:00
|
|
|
preview_window = window_opened_by { click_on 'onglet-preview' }
|
2018-06-15 17:26:05 +02:00
|
|
|
within_window(preview_window) do
|
|
|
|
expect(page).to have_current_path(apercu_procedure_path(Procedure.first))
|
2018-08-07 14:12:32 +02:00
|
|
|
expect(page).to have_field('libelle de champ')
|
|
|
|
expect(page).to have_field('libelle de piece')
|
2018-06-15 17:26:05 +02:00
|
|
|
end
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
2018-08-29 22:11:38 +02:00
|
|
|
scenario 'After adding champ and file, check impossibility to publish procedure, add instructeur and make publication' do
|
2018-08-07 14:12:32 +02:00
|
|
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libelle de champ'
|
|
|
|
click_on 'add_type_de_champ'
|
|
|
|
click_on 'onglet-pieces'
|
|
|
|
|
|
|
|
expect(page).to have_current_path(admin_procedure_pieces_justificatives_path(Procedure.first))
|
|
|
|
fill_in 'procedure_types_de_piece_justificative_attributes_0_libelle', with: 'libelle de piece'
|
|
|
|
click_on 'add_piece_justificative'
|
|
|
|
|
|
|
|
click_on 'onglet-infos'
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(Procedure.first))
|
2018-08-14 15:17:22 +02:00
|
|
|
expect(page).to have_selector('#disabled-publish-procedure')
|
|
|
|
expect(page.find_by_id('disabled-publish-procedure')[:disabled]).to eq('true')
|
2018-08-07 14:12:32 +02:00
|
|
|
|
2018-08-29 22:11:38 +02:00
|
|
|
click_on 'onglet-instructeurs'
|
|
|
|
expect(page).to have_current_path(admin_procedure_instructeurs_path(Procedure.first))
|
2018-08-07 14:12:32 +02:00
|
|
|
fill_in 'gestionnaire_email', with: 'gestionnaire@apientreprise.fr'
|
|
|
|
click_on 'add-gestionnaire-email'
|
2016-12-14 17:13:40 +01:00
|
|
|
page.first('.gestionnaire-affectation').click
|
|
|
|
|
2018-08-07 14:12:32 +02:00
|
|
|
click_on 'onglet-infos'
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(Procedure.first))
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_selector('#publish-procedure', visible: true)
|
2018-08-07 14:12:32 +02:00
|
|
|
find('#publish-procedure').click
|
|
|
|
|
|
|
|
within '#publish-modal' do
|
|
|
|
expect(page).to have_field('procedure_path', with: 'libelle-de-la-procedure')
|
|
|
|
click_on 'publish'
|
|
|
|
end
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2018-09-05 14:48:42 +02:00
|
|
|
expect(page).to have_text('Démarche publiée')
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_selector('.procedure-lien')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|