Merge pull request #10713 from demarches-simplifiees/etq-admin-bug-message-info-character-limit
Tech : amélioration de la gestion des types_de_champ.options
This commit is contained in:
commit
c8f69283cc
13 changed files with 230 additions and 42 deletions
|
@ -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')
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -3,26 +3,28 @@
|
|||
describe TypesDeChampEditor::EditorComponent, type: :component do
|
||||
let(:revision) { procedure.draft_revision }
|
||||
let(:procedure) { create(:procedure, id: 1, 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' }] }
|
||||
|
||||
describe 'render' do
|
||||
subject { render_inline(described_class.new(revision:, is_annotation:)) }
|
||||
|
||||
context 'types_de_champ_public' do
|
||||
let(:is_annotation) { false }
|
||||
|
||||
it 'does not render private champs errors' do
|
||||
expect(subject).not_to have_text("private")
|
||||
expect(subject).to have_selector("a", text: "public")
|
||||
expect(subject).to have_text("doit comporter au moins un choix sélectionnable")
|
||||
expect(subject).to have_text("doit comporter au moins un champ répétable")
|
||||
end
|
||||
end
|
||||
|
||||
context 'types_de_champ_private' do
|
||||
let(:is_annotation) { true }
|
||||
|
||||
it 'does not render public champs errors' do
|
||||
expect(subject).to have_selector("a", text: "private")
|
||||
expect(subject).to have_text("doit comporter au moins un choix sélectionnable")
|
||||
expect(subject).to have_text("doit comporter au moins un champ répétable")
|
||||
expect(subject).not_to have_text("public")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue