demarches-normaliennes/spec/system/administrateurs/procedure_ineligibilite_spec.rb

45 lines
2.1 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.

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("Champs à configurer")
# 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 critères dinéligibilité. Il vous faut donc ajouter au moins un des champs suivant à votre formulaire : ")
click_on "Ajouter un champ supportant les critères 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: 'Inéligibilité des dossiers').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