Merge pull request #7690 from mfo/US/novalidate-editor

feat(brouillon.edit.form): novalidate
This commit is contained in:
mfo 2022-08-24 15:24:50 +02:00 committed by GitHub
commit ac246c6775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View file

@ -6,7 +6,7 @@
- else
- form_options = { url: modifier_dossier_url(dossier), method: :patch }
= form_for dossier, form_options.merge({ html: { id: 'dossier-edit-form', class: 'form', multipart: true } }) do |f|
= form_for dossier, form_options.merge({ html: { id: 'dossier-edit-form', class: 'form', multipart: true, novalidate: 'novalidate' } }) do |f|
.prologue
%p.mandatory-explanation= t('utils.asterisk_html')

View file

@ -269,6 +269,35 @@ describe 'The user' do
context 'with condition' do
include Logic
context 'with a repetition' do
let(:procedure) do
procedure = create(:procedure, :published, :for_individual,
types_de_champ_public: [
{ type: :integer_number, libelle: 'age' },
{
type: :repetition, libelle: 'repetition', children: [
{ type: :text, libelle: 'nom', mandatory: true }
]
}
])
age = procedure.published_revision.types_de_champ.where(libelle: 'age').first
repetition = procedure.published_revision.types_de_champ.repetition.first
repetition.update(condition: greater_than_eq(champ_value(age.stable_id), constant(18)))
procedure
end
scenario 'submit a dossier with an hidden mandatory champ within a repetition', js: true do
log_in(user, procedure)
fill_individual
fill_in('age', with: 10)
click_on 'Déposer le dossier'
expect(page).to have_current_path(merci_dossier_path(user_dossier))
end
end
context 'with a required conditionnal champ' do
let(:procedure) do
procedure = create(:procedure, :published, :for_individual,
@ -278,7 +307,6 @@ describe 'The user' do
])
age, nom = procedure.draft_revision.types_de_champ.all
nom.update(condition: greater_than_eq(champ_value(age.stable_id), constant(18)))
procedure
@ -288,7 +316,6 @@ describe 'The user' do
log_in(user, procedure)
fill_individual
click_on 'Déposer le dossier'
expect(page).to have_current_path(merci_dossier_path(user_dossier))
end