2016-12-14 17:13:40 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-12-26 10:56:48 +01:00
|
|
|
feature 'As an administrateur I wanna create a new procedure', js: true do
|
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-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('draft-procedures').click
|
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-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('active-procedures').click
|
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-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('archived-procedures').click
|
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
|
|
|
|
scenario 'Finding new procedure link' do
|
|
|
|
page.find_by_id('new-procedure').click
|
2018-05-09 16:16:09 +02:00
|
|
|
page.find_by_id('from-scratch').click
|
2018-01-23 17:14:13 +01:00
|
|
|
expect(page).to have_current_path(new_admin_procedure_path)
|
2016-12-14 17:13:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Finding save button for new procedure, libelle and description required' do
|
|
|
|
page.find_by_id('new-procedure').click
|
2018-05-09 16:16:09 +02:00
|
|
|
page.find_by_id('from-scratch').click
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('save-procedure').click
|
|
|
|
page.find_by_id('flash_message').visible?
|
|
|
|
fill_in 'procedure_libelle', with: 'libelle de la procedure'
|
2018-03-28 17:30:08 +02:00
|
|
|
page.execute_script("$('#procedure_description').val('description de la procedure')")
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('save-procedure').click
|
|
|
|
expect(page).to have_current_path(admin_procedure_types_de_champ_path(Procedure.first.id.to_s))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'Editing a new procedure' do
|
|
|
|
before 'Create procedure' do
|
|
|
|
page.find_by_id('new-procedure').click
|
2018-05-09 16:16:09 +02:00
|
|
|
page.find_by_id('from-scratch').click
|
2016-12-14 17:13:40 +01:00
|
|
|
fill_in 'procedure_libelle', with: 'libelle de la procedure'
|
2018-03-28 17:30:08 +02:00
|
|
|
page.execute_script("$('#procedure_description').val('description de la procedure')")
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('save-procedure').click
|
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
|
|
|
|
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set 'libelle de champ'
|
|
|
|
page.find_by_id('add_type_de_champ').click
|
|
|
|
page.find_by_id('procedure_types_de_champ_attributes_1_libelle')
|
|
|
|
expect(Procedure.first.types_de_champ.first.libelle).to eq('libelle de champ')
|
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-pieces').click
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_current_path(admin_procedure_pieces_justificatives_path(Procedure.first.id.to_s))
|
|
|
|
page.find_by_id('procedure_types_de_piece_justificative_attributes_0_libelle').set 'libelle de piece'
|
|
|
|
page.find_by_id('add_piece_justificative').click
|
|
|
|
page.find_by_id('procedure_types_de_piece_justificative_attributes_1_libelle')
|
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-preview').click
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_current_path(admin_procedure_previsualisation_path(Procedure.first.id.to_s))
|
2017-04-10 17:33:05 +02:00
|
|
|
expect(page.find("input[type='text']")['placeholder']).to eq('libelle de champ')
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page.first('.piece-libelle').text).to eq('libelle de piece')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'After adding champ and file, check impossibility to publish procedure, add accompagnateur and make publication' do
|
|
|
|
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set 'libelle de champ'
|
|
|
|
page.find_by_id('add_type_de_champ').click
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-pieces').click
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('procedure_types_de_piece_justificative_attributes_0_libelle').set 'libelle de piece'
|
|
|
|
page.find_by_id('add_piece_justificative').click
|
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-infos').click
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_current_path(admin_procedure_path(Procedure.first.id.to_s))
|
2018-01-04 10:46:33 +01:00
|
|
|
expect(page.find_by_id('publish-procedure')['disabled']).to eq('true')
|
2016-12-14 17:13:40 +01:00
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-accompagnateurs').click
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_current_path(admin_procedure_accompagnateurs_path(Procedure.first.id.to_s))
|
2017-01-03 11:54:03 +01:00
|
|
|
page.find_by_id('gestionnaire_email').set 'gestionnaire@apientreprise.fr'
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('add-gestionnaire-email').click
|
|
|
|
page.first('.gestionnaire-affectation').click
|
|
|
|
|
2018-01-04 10:46:33 +01:00
|
|
|
page.find_by_id('onglet-infos').click
|
2016-12-14 17:13:40 +01:00
|
|
|
expect(page).to have_selector('#publish-procedure', visible: true)
|
|
|
|
page.find_by_id('publish-procedure').click
|
|
|
|
|
2017-04-14 11:34:53 +02:00
|
|
|
expect(page.find_by_id('procedure_path')['value']).to eq('libelle-de-la-procedure')
|
2016-12-14 17:13:40 +01:00
|
|
|
page.find_by_id('publish').click
|
|
|
|
expect(page).to have_selector('.procedure-lien')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|