fix(explication): render collapsible text into collapse element

This commit is contained in:
Colin Darie 2023-03-30 12:44:43 +02:00
parent 9e7e452c02
commit e36dc19cc4
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?
%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
%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)

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