tech(refactor): procedure::error_summary and dossier::ErrorsFullMessagesComponent use same behaviour to compact/expand errors

This commit is contained in:
mfo 2024-06-05 18:00:19 +02:00
parent c480bc00c3
commit e3a24d53ea
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
16 changed files with 115 additions and 78 deletions

View file

@ -11,27 +11,33 @@ describe Procedure::ErrorsSummary, type: :component do
context 'when :publication' do
let(:validation_context) { :publication }
it 'shows errors for public and private tdc' do
expect(page).to have_text("Le champ « public » doit comporter au moins un choix sélectionnable")
expect(page).to have_text("Lannotation privée « private » doit comporter au moins un choix sélectionnable")
it 'shows errors and links for public and private tdc' 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)
end
end
context 'when :types_de_champ_public_editor' do
let(:validation_context) { :types_de_champ_public_editor }
it 'shows errors for public only tdc' do
expect(page).to have_text("Le champ « public » doit comporter au moins un choix sélectionnable")
expect(page).not_to have_text("Lannotation privée « private » doit comporter au moins un choix sélectionnable")
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).not_to have_selector("a", text: "private")
end
end
context 'when :types_de_champ_private_editor' do
let(:validation_context) { :types_de_champ_private_editor }
it 'shows errors for private only tdc' do
expect(page).not_to have_text("Le champ « public » doit comporter au moins un choix sélectionnable")
expect(page).to have_text("Lannotation privée « private » doit comporter au moins un choix sélectionnable")
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).not_to have_selector("a", text: "public")
end
end
end
@ -52,12 +58,18 @@ describe Procedure::ErrorsSummary, type: :component do
before { subject }
it 'renders all errors on champ' do
expect(page).to have_text("Le champ « drop down list requires options » doit comporter au moins un choix sélectionnable")
expect(page).to have_text("Le champ « repetition requires children » doit comporter au moins un champ répétable")
expect(page).to have_text("Le champ « invalid condition » a une logique conditionnelle invalide")
expect(page).to have_text("Le champ « header sections must have consistent order » devrait être précédé d'un titre de niveau 1")
# TODO, test attestation_template, initiated_mail, :received_mail, :closed_mail, :refused_mail, :without_continuation_mail, :re_instructed_mail
it 'renders all errors and links on champ' do
expect(page).to have_selector("a", text: "drop down list requires options")
expect(page).to have_content("doit comporter au moins un choix sélectionnable")
expect(page).to have_selector("a", text: "repetition requires children")
expect(page).to have_content("doit comporter au moins un champ répétable")
expect(page).to have_selector("a", text: "invalid condition")
expect(page).to have_content("a une logique conditionnelle invalide")
expect(page).to have_selector("a", text: "header sections must have consistent order")
expect(page).to have_content("devrait être précédé d'un titre de niveau 1")
end
end
@ -73,8 +85,9 @@ describe Procedure::ErrorsSummary, type: :component do
end
it 'render error nicely' do
expect(page).to have_text("Le modèle dattestation n'est pas valide")
expect(page).to have_text("Lemail de notification de passage de dossier en instruction n'est pas valide")
expect(page).to have_selector("a", text: "Le modèle dattestation")
expect(page).to have_selector("a", text: "Lemail de notification de passage de dossier en instruction")
expect(page).to have_text("n'est pas valide", count: 2)
end
end
end