2021-11-25 16:26:55 +01:00
|
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
2016-12-26 10:56:48 +01:00
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
describe 'As an administrateur I wanna clone a 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-26 10:56:48 +01:00
|
|
|
|
|
|
|
|
|
before do
|
2022-12-20 17:22:19 +01:00
|
|
|
|
create(:procedure, :with_service, :with_instructeur, :with_zone,
|
2020-08-27 19:56:34 +02:00
|
|
|
|
aasm_state: :publiee,
|
2019-08-14 18:05:01 +02:00
|
|
|
|
administrateurs: [administrateur],
|
|
|
|
|
libelle: 'libellé de la procédure',
|
2023-02-02 06:59:46 +01:00
|
|
|
|
path: 'libelle-de-la-procedure',
|
|
|
|
|
published_at: Time.zone.now)
|
2019-08-09 10:46:39 +02:00
|
|
|
|
login_as administrateur.user, scope: :user
|
2016-12-26 10:56:48 +01:00
|
|
|
|
end
|
2023-02-13 15:08:55 +01:00
|
|
|
|
context 'Visit all admin procedures' do
|
|
|
|
|
let(:download_dir) { Rails.root.join('tmp/capybara') }
|
|
|
|
|
let(:download_file_pattern) { download_dir.join('*.xlsx') }
|
2016-12-26 10:56:48 +01:00
|
|
|
|
|
2023-02-13 15:08:55 +01:00
|
|
|
|
scenario do
|
|
|
|
|
Dir[download_file_pattern].map { File.delete(_1) }
|
|
|
|
|
visit all_admin_procedures_path
|
|
|
|
|
|
|
|
|
|
click_on "Exporter les résultats"
|
|
|
|
|
Timeout.timeout(Capybara.default_max_wait_time,
|
|
|
|
|
Timeout::Error,
|
|
|
|
|
"File download timeout! can't download procedure/all.xlsx") do
|
|
|
|
|
sleep 0.1 until !Dir[download_file_pattern].empty?
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2019-08-14 18:05:01 +02:00
|
|
|
|
context 'Cloning a procedure owned by the current admin' do
|
|
|
|
|
scenario do
|
|
|
|
|
visit admin_procedures_path
|
2016-12-26 10:56:48 +01:00
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
2023-06-27 14:33:49 +02:00
|
|
|
|
page.all('.card .dropdown .fr-btn').first.click
|
2016-12-26 10:56:48 +01:00
|
|
|
|
page.all('.clone-btn').first.click
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2019-08-14 18:05:01 +02:00
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
|
|
|
click_on Procedure.last.libelle
|
2022-08-17 09:06:04 +02:00
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(id: Procedure.last))
|
2019-08-14 18:05:01 +02:00
|
|
|
|
|
2022-08-17 09:06:04 +02:00
|
|
|
|
# select service
|
2022-10-14 16:55:29 +02:00
|
|
|
|
find("#service .fr-btn").click
|
2022-08-17 17:55:10 +02:00
|
|
|
|
click_on "Assigner"
|
2022-08-17 09:06:04 +02:00
|
|
|
|
|
2022-12-20 17:22:19 +01:00
|
|
|
|
# select zone
|
|
|
|
|
find("#zones .fr-btn").click
|
2023-09-05 10:33:08 +02:00
|
|
|
|
check Zone.last.current_label, allow_label_click: true
|
2022-12-20 17:22:19 +01:00
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
2022-08-17 09:06:04 +02:00
|
|
|
|
# then publish
|
2020-07-15 10:48:11 +02:00
|
|
|
|
find('#publish-procedure-link').click
|
2024-03-14 17:17:47 +01:00
|
|
|
|
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure-2'
|
|
|
|
|
fill_in 'procedure_path', with: 'libelle-de-la-procedure'
|
|
|
|
|
expect(page).to have_content 'Si vous publiez cette démarche, l’ancienne sera dépubliée et ne sera plus accessible au public.'
|
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
|
click_on 'publish'
|
2019-08-14 18:05:01 +02:00
|
|
|
|
|
|
|
|
|
page.refresh
|
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "archivees")
|
2019-08-14 18:05:01 +02:00
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2019-08-14 18:05:01 +02:00
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
|
2016-12-26 10:56:48 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
2023-02-02 06:59:46 +01:00
|
|
|
|
|
|
|
|
|
context 'Cloning a procedure from the all procedure page' do
|
|
|
|
|
scenario do
|
|
|
|
|
visit all_admin_procedures_path
|
|
|
|
|
expect(page).to have_content(Procedure.last.libelle)
|
|
|
|
|
find('.button_to>button').click
|
|
|
|
|
click_on 'Cloner'
|
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
|
|
|
click_on Procedure.last.libelle
|
|
|
|
|
expect(page).to have_current_path(admin_procedure_path(id: Procedure.last))
|
|
|
|
|
|
|
|
|
|
# select service
|
|
|
|
|
find("#service .fr-btn").click
|
|
|
|
|
click_on "Assigner"
|
|
|
|
|
|
|
|
|
|
# select zone
|
|
|
|
|
find("#zones .fr-btn").click
|
2023-09-05 10:33:08 +02:00
|
|
|
|
check Zone.last.current_label, allow_label_click: true
|
2023-02-02 06:59:46 +01:00
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
|
|
|
|
# then publish
|
|
|
|
|
find('#publish-procedure-link').click
|
2024-03-14 17:17:47 +01:00
|
|
|
|
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure-2'
|
|
|
|
|
fill_in 'procedure_path', with: 'libelle-de-la-procedure'
|
|
|
|
|
expect(page).to have_content 'Si vous publiez cette démarche, l’ancienne sera dépubliée et ne sera plus accessible au public.'
|
2023-02-02 06:59:46 +01:00
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
|
click_on 'publish'
|
|
|
|
|
|
|
|
|
|
page.refresh
|
|
|
|
|
|
|
|
|
|
visit admin_procedures_path(statut: "archivees")
|
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
|
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-12-26 10:56:48 +01:00
|
|
|
|
end
|