TypeDeChamp: amélioration de la gestion des drop_down_options

This commit is contained in:
simon lehericey 2024-10-07 14:35:23 +02:00 committed by benoitqueyron
parent e374143422
commit b588b77571
No known key found for this signature in database
GPG key ID: AD3C38C9ACA84135
9 changed files with 51 additions and 33 deletions

View file

@ -15,14 +15,15 @@ describe Procedure::Card::AnnotationsComponent, type: :component do
end
context 'when errors on types_de_champs_public' do
let(:types_de_champ_public) { [{ type: :drop_down_list, options: [] }] }
let(:types_de_champ_public) { [{ type: :repetition, children: [] }] }
it 'does not render' do
expect(subject).to have_selector('.fr-badge--info', text: 'À configurer')
end
end
context 'when errors on types_de_champs_private' do
let(:types_de_champ_private) { [{ type: :drop_down_list, options: [] }] }
let(:types_de_champ_private) { [{ type: :repetition, children: [] }] }
it 'render the template' do
expect(subject).to have_selector('.fr-badge--error', text: 'À modifier')

View file

@ -15,14 +15,14 @@ describe Procedure::Card::ChampsComponent, type: :component do
end
context 'when errors on types_de_champs_public' do
let(:types_de_champ_public) { [{ type: :drop_down_list, options: [] }] }
let(:types_de_champ_public) { [{ type: :repetition, children: [] }] }
it 'does not render' do
expect(subject).to have_selector('.fr-badge--error', text: 'À modifier')
end
end
context 'when errors on types_de_champs_private' do
let(:types_de_champ_private) { [{ type: :drop_down_list, options: [] }] }
let(:types_de_champ_private) { [{ type: :repetition, children: [] }] }
it 'render the template' do
expect(subject).to have_selector('.fr-badge--warning', text: 'À faire')

View file

@ -5,8 +5,8 @@ describe Procedure::ErrorsSummary, type: :component do
describe 'validations context' do
let(:procedure) { create(:procedure, types_de_champ_private:, types_de_champ_public:) }
let(:types_de_champ_private) { [{ type: :drop_down_list, options: [], libelle: 'private' }] }
let(:types_de_champ_public) { [{ type: :drop_down_list, options: [], libelle: 'public' }] }
let(:types_de_champ_private) { [{ type: :repetition, children: [], libelle: 'private' }] }
let(:types_de_champ_public) { [{ type: :repetition, children: [], libelle: 'public' }] }
before { subject }
@ -17,7 +17,7 @@ describe Procedure::ErrorsSummary, type: :component do
expect(page).to have_content("Erreur : Des problèmes empêchent la publication de la démarche")
expect(page).to have_selector("a", text: "public")
expect(page).to have_selector("a", text: "private")
expect(page).to have_text("doit comporter au moins un choix sélectionnable", count: 2)
expect(page).to have_text("doit comporter au moins un champ répétable", count: 2)
end
end
@ -27,7 +27,7 @@ describe Procedure::ErrorsSummary, type: :component do
it 'shows errors and links for public only tdc' do
expect(page).to have_text("Erreur : Les champs formulaire contiennent des erreurs")
expect(page).to have_selector("a", text: "public")
expect(page).to have_text("doit comporter au moins un choix sélectionnable", count: 1)
expect(page).to have_text("doit comporter au moins un champ répétable", count: 1)
expect(page).not_to have_selector("a", text: "private")
end
end
@ -38,7 +38,7 @@ describe Procedure::ErrorsSummary, type: :component do
it 'shows errors and links for private only tdc' do
expect(page).to have_text("Erreur : Les annotations privées contiennent des erreurs")
expect(page).to have_selector("a", text: "private")
expect(page).to have_text("doit comporter au moins un choix sélectionnable")
expect(page).to have_text("doit comporter au moins un champ répétable")
expect(page).not_to have_selector("a", text: "public")
end
end
@ -59,7 +59,11 @@ describe Procedure::ErrorsSummary, type: :component do
let(:validation_context) { :types_de_champ_public_editor }
before { subject }
before do
drop_down_public = procedure.draft_revision.types_de_champ_public.find(&:drop_down_list?)
drop_down_public.update!(drop_down_options: [])
subject
end
it 'renders all errors and links on champ' do
expect(page).to have_selector("a", text: "drop down list requires options")