demarches-normaliennes/spec/features/admin/procedure_creation_spec.rb

115 lines
3.7 KiB
Ruby
Raw Normal View History

require 'spec_helper'
2018-05-23 23:32:49 +02:00
require 'features/admin/procedure_spec_helper'
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
let(:administrateur) { create(:administrateur, :with_procedure) }
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
click_on 'draft-procedures'
expect(page).to have_current_path(admin_procedures_draft_path)
end
scenario 'Finding active procedures' do
click_on 'active-procedures'
expect(page).to have_current_path(admin_procedures_path)
end
scenario 'Finding archived procedures' do
click_on 'archived-procedures'
expect(page).to have_current_path(admin_procedures_archived_path)
end
end
context 'Creating a new procedure' do
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
click_on 'from-scratch'
expect(page).to have_current_path(new_admin_procedure_path)
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'
fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6'
click_on 'save-procedure'
expect(page).to have_text('Libelle doit être rempli')
fill_in_dummy_procedure_details
click_on 'save-procedure'
2018-11-14 16:28:02 +01:00
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
end
end
end
context 'Editing a new procedure' do
before 'Create procedure' do
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
click_on 'save-procedure'
procedure = Procedure.last
procedure.update(service: create(:service))
end
2019-07-25 14:03:18 +02:00
scenario 'Add champ, add file, visualize them in procedure preview' do
page.refresh
expect(page).to have_current_path(champs_procedure_path(Procedure.last))
2019-07-25 14:03:18 +02:00
expect(page).to have_selector('#champ-0-libelle')
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-07-25 14:03:18 +02:00
within '.buttons' do
click_on 'Ajouter un champ'
end
2019-07-25 14:03:18 +02:00
expect(page).to have_selector('#champ-1-libelle')
2019-07-25 14:03:18 +02:00
click_on Procedure.last.libelle
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
expect(page).to have_current_path(apercu_procedure_path(Procedure.last))
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
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é')
2019-07-25 14:03:18 +02:00
click_on Procedure.last.libelle
expect(page).to have_current_path(admin_procedure_path(Procedure.last))
2019-07-25 14:03:18 +02:00
expect(page).to have_selector('#publish-procedure', visible: true)
find('#publish-procedure').click
2019-07-25 14:03:18 +02:00
within '#publish-modal' do
expect(page).to have_field('procedure_path')
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'publish'
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')
end
end
end