demarches-normaliennes/spec/system/administrateurs/procedure_ineligibilite_spec.rb
2024-11-07 09:12:13 +01:00

47 lines
2.2 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
describe 'Administrateurs can edit procedures', js: true do
include Logic
let(:procedure) { create(:procedure, administrateurs: [create(:administrateur)]) }
before do
login_as procedure.administrateurs.first.user, scope: :user
end
scenario 'setup eligibilite' do
# explain no champ compatible
visit admin_procedure_path(procedure)
expect(page).to have_content("Désactivé")
# explain which champs are compatible
visit edit_admin_procedure_ineligibilite_rules_path(procedure)
expect(page).to have_content("Inéligibilité des dossiers")
expect(page).to have_content("Pour configurer linéligibilité des dossiers, votre formulaire doit comporter au moins un champ supportant les conditions dinéligibilité. Il vous faut donc ajouter au moins un des champs suivant à votre formulaire : ")
click_on "Ajouter un champ supportant les conditions dinéligibilité"
# setup a compatible champ
expect(page).to have_content('Champs du formulaire')
click_on 'Ajouter un champ'
select "Oui/Non"
fill_in "Libellé du champ", with: "Un champ oui non"
click_on "Revenir à lécran de gestion"
procedure.reload
first_tdc = procedure.draft_revision.types_de_champ.first
# back to procedure dashboard, explain you can set it up now
expect(page).to have_content('À configurer')
visit edit_admin_procedure_ineligibilite_rules_path(procedure)
# setup rules and stuffs
expect(page).to have_content("Inéligibilité des dossiers")
fill_in "Message dinéligibilité", with: "vous n'etes pas eligible"
find('label', text: 'Bloquer le dépôt des dossiers répondant à des conditions dinéligibilité').click
click_on "Ajouter une règle dinéligibilité"
all('select').first.select 'Un champ oui non'
click_on 'Enregistrer'
# rules are setup
wait_until { procedure.reload.draft_revision.ineligibilite_enabled == true }
expect(procedure.draft_revision.ineligibilite_message).to eq("vous n'etes pas eligible")
expect(procedure.draft_revision.ineligibilite_rules).to eq(ds_eq(champ_value(first_tdc.stable_id), constant(true)))
end
end