Merge pull request #8826 from colinux/fix-explanation-collapse

Fix champ explication: cache le texte qui doit être caché
This commit is contained in:
Colin Darie 2023-03-30 11:22:14 +00:00 committed by GitHub
commit 294725ae67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -6,5 +6,5 @@
- if @champ.collapsible_explanation_enabled? && @champ.collapsible_explanation_text.present? - if @champ.collapsible_explanation_enabled? && @champ.collapsible_explanation_text.present?
%p.fr-my-2w %p.fr-my-2w
%button{ type: "button", "aria-controls": dom_id(@champ, :explanation), "aria-expanded": "false", href: dom_id(@champ, :explanation), class: "fr-btn ft-btn--sm fr-btn--secondary" } Lire plus %button{ type: "button", "aria-controls": dom_id(@champ, :explanation), "aria-expanded": "false", href: dom_id(@champ, :explanation), class: "fr-btn ft-btn--sm fr-btn--secondary" } Lire plus
%p.fr-collapse{ id: dom_id(@champ, :explanation) } .fr-collapse{ id: dom_id(@champ, :explanation) }
= render SimpleFormatComponent.new(@champ.collapsible_explanation_text, allow_a: true) = render SimpleFormatComponent.new(@champ.collapsible_explanation_text, allow_a: true)

View file

@ -0,0 +1,24 @@
describe EditableChamp::ExplicationComponent, type: :component do
let(:component) {
described_class.new(form: instance_double(ActionView::Helpers::FormBuilder, object_name: "dossier[champs_public_attributes]"), champ:)
}
let(:champ) { create(:champ_explication) }
describe 'no description' do
subject { render_inline(component).to_html }
it { is_expected.not_to have_button("Lire plus") }
end
describe 'collapsed text is collapsed' do
subject { render_inline(component).to_html }
before do
champ.type_de_champ.update!(collapsible_explanation_enabled: "1", collapsible_explanation_text: "hide me")
end
it { is_expected.to have_button("Lire plus") }
it { is_expected.to have_selector(".fr-collapse", text: "hide me") }
end
end