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
|
|
|
|
|
2019-01-03 17:42:43 +01:00
|
|
|
let(:administrateur) { create(:administrateur, :with_procedure) }
|
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
|
|
|
|
|
|
|
|
context 'Right after sign_in I shall see all procedure states links' do
|
|
|
|
scenario 'Finding draft procedures' do
|
2020-07-28 15:15:56 +02:00
|
|
|
page.all('.tabs li a')[1].click
|
|
|
|
expect(page).to have_current_path(admin_procedures_path(statut: 'brouillons'))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Finding active procedures' do
|
2020-07-28 15:15:56 +02:00
|
|
|
page.all('.tabs li a').first.click
|
|
|
|
expect(page).to have_current_path(admin_procedures_path(statut: 'publiees'))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Finding archived procedures' do
|
2020-07-28 15:15:56 +02:00
|
|
|
page.all('.tabs li a').last.click
|
|
|
|
expect(page).to have_current_path(admin_procedures_path(statut: 'archivees'))
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Creating a new procedure' do
|
2018-09-19 17:12:12 +02:00
|
|
|
context "when publish_draft enabled" do
|
|
|
|
scenario 'Finding save button for new procedure, libelle, description and cadre_juridique required' do
|
|
|
|
expect(page).to have_selector('#new-procedure')
|
|
|
|
find('#new-procedure').click
|
|
|
|
|
2020-07-30 11:33:53 +02:00
|
|
|
expect(page).to have_current_path(new_from_existing_admin_procedures_path)
|
|
|
|
click_on 'Créer une nouvelle démarche de zéro'
|
2019-07-10 18:47:19 +02:00
|
|
|
expect(find('#procedure_for_individual_true')).to be_checked
|
|
|
|
expect(find('#procedure_for_individual_false')).not_to be_checked
|
2018-09-19 17:12:12 +02:00
|
|
|
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
|
|
|
fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6'
|
2019-10-21 18:12:57 +02:00
|
|
|
click_on 'Créer la démarche'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
|
|
expect(page).to have_text('Libelle doit être rempli')
|
|
|
|
fill_in_dummy_procedure_details
|
2019-10-21 18:12:57 +02:00
|
|
|
click_on 'Créer la démarche'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
2020-07-07 12:03:32 +02:00
|
|
|
expect(page).to have_current_path(champs_admin_procedure_path(Procedure.last))
|
2018-09-19 17:12:12 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-14 17:13:40 +01:00
|
|
|
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
|
|
|
|
|
2020-07-30 11:33:53 +02:00
|
|
|
expect(page).to have_current_path(new_from_existing_admin_procedures_path)
|
|
|
|
click_on 'Créer une nouvelle démarche de zéro'
|
2018-05-23 23:32:49 +02:00
|
|
|
fill_in_dummy_procedure_details
|
2019-10-21 18:12:57 +02:00
|
|
|
click_on 'Créer la démarche'
|
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
|
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
scenario 'Add champ, add file, visualize them in procedure preview' do
|
|
|
|
page.refresh
|
2020-07-07 12:03:32 +02:00
|
|
|
expect(page).to have_current_path(champs_admin_procedure_path(Procedure.last))
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2019-11-27 10:19:55 +01:00
|
|
|
add_champ(remove_flash_message: true)
|
2019-07-25 14:03:18 +02:00
|
|
|
fill_in 'champ-0-libelle', with: 'libelle de champ'
|
|
|
|
blur
|
|
|
|
expect(page).to have_content('Formulaire enregistré')
|
2018-11-14 16:28:02 +01:00
|
|
|
|
2019-11-27 10:19:55 +01:00
|
|
|
add_champ
|
2019-07-25 14:03:18 +02:00
|
|
|
expect(page).to have_selector('#champ-1-libelle')
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
click_on Procedure.last.libelle
|
2020-07-15 10:48:11 +02:00
|
|
|
find('#publish-procedure-link').click
|
2018-11-14 16:28:02 +01:00
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
preview_window = window_opened_by { click_on 'onglet-preview' }
|
|
|
|
within_window(preview_window) do
|
2020-07-07 12:03:32 +02:00
|
|
|
expect(page).to have_current_path(apercu_admin_procedure_path(Procedure.last))
|
2019-07-25 14:03:18 +02:00
|
|
|
expect(page).to have_field('libelle de champ')
|
|
|
|
end
|
|
|
|
end
|
2018-11-14 16:28:02 +01:00
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
scenario 'After adding champ and file, make publication' do
|
|
|
|
page.refresh
|
2018-12-18 17:52:33 +01:00
|
|
|
|
2019-11-27 10:19:55 +01:00
|
|
|
add_champ(remove_flash_message: true)
|
2019-07-25 14:03:18 +02:00
|
|
|
fill_in 'champ-0-libelle', with: 'libelle de champ'
|
|
|
|
blur
|
|
|
|
expect(page).to have_content('Formulaire enregistré')
|
2018-12-18 17:52:33 +01:00
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
click_on Procedure.last.libelle
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(Procedure.last))
|
2020-07-15 10:48:11 +02:00
|
|
|
find('#publish-procedure-link').click
|
2019-08-14 18:05:01 +02:00
|
|
|
expect(page).to have_content('en test')
|
|
|
|
# Only check the path even though the link is the complete URL
|
|
|
|
# (Capybara runs the app on an arbitrary host/port.)
|
|
|
|
expect(page).to have_link(nil, href: /#{commencer_test_path(Procedure.last.path)}/)
|
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
expect(page).to have_selector('#publish-procedure', visible: true)
|
|
|
|
find('#publish-procedure').click
|
2018-12-18 17:52:33 +01:00
|
|
|
|
2019-07-25 14:03:18 +02:00
|
|
|
within '#publish-modal' do
|
2019-08-14 18:05:01 +02:00
|
|
|
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'
|
2019-07-25 14:03:18 +02:00
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
click_on 'publish'
|
2018-12-18 17:52:33 +01:00
|
|
|
end
|
2019-07-25 14:03:18 +02:00
|
|
|
|
|
|
|
expect(page).to have_text('Démarche publiée')
|
|
|
|
expect(page).to have_selector('.procedure-lien')
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|