2022-01-04 14:44:17 +01:00
|
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
describe 'As an administrateur, I want to manage the procedure’s attestation', js: true do
|
2022-01-04 14:44:17 +01:00
|
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
|
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
|
let(:procedure) do
|
2022-12-20 11:21:52 +01:00
|
|
|
|
create(:procedure, :with_service, :with_instructeur, :with_zone,
|
2022-01-04 14:44:17 +01:00
|
|
|
|
aasm_state: :brouillon,
|
|
|
|
|
administrateurs: [administrateur],
|
|
|
|
|
libelle: 'libellé de la procédure',
|
|
|
|
|
path: 'libelle-de-la-procedure')
|
|
|
|
|
end
|
|
|
|
|
before { login_as(administrateur.user, scope: :user) }
|
|
|
|
|
|
|
|
|
|
def find_attestation_card(with_nested_selector: nil)
|
|
|
|
|
full_selector = [
|
2022-10-14 16:55:29 +02:00
|
|
|
|
"a[href=\"#{edit_admin_procedure_attestation_template_path(procedure)}\"]",
|
2022-01-04 14:44:17 +01:00
|
|
|
|
with_nested_selector
|
|
|
|
|
].compact.join(" ")
|
|
|
|
|
page.find(full_selector)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'Enable, publish, Disable' do
|
|
|
|
|
scenario do
|
|
|
|
|
visit admin_procedure_path(procedure)
|
|
|
|
|
# start with no attestation
|
2023-11-15 15:54:19 +01:00
|
|
|
|
expect(page).to have_content('Désactivée')
|
|
|
|
|
find_attestation_card(with_nested_selector: ".fr-badge")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
|
|
|
|
|
# now process to enable attestation
|
|
|
|
|
find_attestation_card.click
|
2022-12-15 13:08:20 +01:00
|
|
|
|
fill_in "Titre de l’attestation", with: 'BOOM'
|
2022-12-16 14:56:46 +01:00
|
|
|
|
fill_in "Contenu de l’attestation", with: 'BOOM'
|
2022-01-04 14:44:17 +01:00
|
|
|
|
find('.toggle-switch-control').click
|
|
|
|
|
click_on 'Enregistrer'
|
2022-12-15 13:08:20 +01:00
|
|
|
|
|
|
|
|
|
page.find(".alert-success", text: "Le modèle de l’attestation a bien été enregistré")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
|
|
|
|
|
# check attestation
|
|
|
|
|
visit admin_procedure_path(procedure)
|
2023-11-15 15:54:19 +01:00
|
|
|
|
expect(page).to have_content('Activée')
|
|
|
|
|
find_attestation_card(with_nested_selector: ".fr-badge--success")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
|
|
|
|
|
# publish procedure
|
|
|
|
|
# click CTA for publication screen
|
|
|
|
|
click_on("Publier")
|
|
|
|
|
# validate publication
|
2023-10-10 16:51:06 +02:00
|
|
|
|
within('form') { click_on 'Publier' }
|
2023-11-06 17:46:22 +01:00
|
|
|
|
click_on("Revenir à la page de la démarche")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
|
|
|
|
|
# now process to disable attestation
|
|
|
|
|
find_attestation_card.click
|
|
|
|
|
find('.toggle-switch-control').click
|
|
|
|
|
click_on 'Enregistrer'
|
2022-12-15 13:08:20 +01:00
|
|
|
|
page.find(".alert-success", text: "Le modèle de l’attestation a bien été modifié")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
|
|
|
|
|
# check attestation is now disabled
|
|
|
|
|
visit admin_procedure_path(procedure)
|
2023-11-15 15:54:19 +01:00
|
|
|
|
expect(page).to have_content('Désactivée')
|
|
|
|
|
find_attestation_card(with_nested_selector: ".fr-badge")
|
2022-01-04 14:44:17 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|