1fa3425d4f
[Accessibilité] Configurer le mode "sombre"
64 lines
2.2 KiB
Ruby
64 lines
2.2 KiB
Ruby
require 'system/administrateurs/procedure_spec_helper'
|
||
|
||
describe 'As an administrateur, I want to manage the procedure’s attestation', js: true do
|
||
include ProcedureSpecHelper
|
||
|
||
let(:administrateur) { create(:administrateur) }
|
||
let(:procedure) do
|
||
create(:procedure, :with_service, :with_instructeur, :with_zone,
|
||
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 = [
|
||
"a[href=\"#{edit_admin_procedure_attestation_template_path(procedure)}\"]",
|
||
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
|
||
expect(page).to have_content('Désactivée')
|
||
find_attestation_card(with_nested_selector: ".fr-badge")
|
||
|
||
# now process to enable attestation
|
||
find_attestation_card.click
|
||
fill_in "Titre de l’attestation", with: 'BOOM'
|
||
fill_in "Contenu de l’attestation", with: 'BOOM'
|
||
find('.toggle-switch-control').click
|
||
click_on 'Enregistrer'
|
||
|
||
page.find(".alert-success", text: "Le modèle de l’attestation a bien été enregistré")
|
||
|
||
# check attestation
|
||
visit admin_procedure_path(procedure)
|
||
expect(page).to have_content('Activée')
|
||
find_attestation_card(with_nested_selector: ".fr-badge--success")
|
||
|
||
# publish procedure
|
||
# click CTA for publication screen
|
||
click_on("Publier")
|
||
# validate publication
|
||
within('form') { click_on 'Publier' }
|
||
click_on("Revenir à la page de la démarche")
|
||
|
||
# now process to disable attestation
|
||
find_attestation_card.click
|
||
find('.toggle-switch-control').click
|
||
click_on 'Enregistrer'
|
||
page.find(".alert-success", text: "Le modèle de l’attestation a bien été modifié")
|
||
|
||
# check attestation is now disabled
|
||
visit admin_procedure_path(procedure)
|
||
expect(page).to have_content('Désactivée')
|
||
find_attestation_card(with_nested_selector: ".fr-badge")
|
||
end
|
||
end
|
||
end
|