fix(repetition): useless fieldset

This commit is contained in:
mfo 2024-04-11 11:56:42 +02:00
parent fe3dc57fc2
commit 64dcd2b0d2
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
2 changed files with 11 additions and 9 deletions

View file

@ -10,9 +10,9 @@
= fields_for champ.input_name, champ do |form|
= render EditableChamp::EditableChampComponent.new form:, champ:
- else
%fieldset.fr-fieldset.fr-my-0
.fr-fieldset__element.fr-my-0
- if header_section
%legend.fr-fieldset__legend.fr-my-0{ class: "reset-#{tag_for_depth}" }
.fr-fieldset__legend.fr-my-0{ class: "reset-#{tag_for_depth}" }
= render EditableChamp::HeaderSectionComponent.new(champ: header_section)
- splitted_tail.each do |section, champ|
- if section.present?

View file

@ -10,8 +10,8 @@ describe EditableChamp::SectionComponent, type: :component do
context 'list of champs without an header_section' do
let(:types_de_champ_public) { [{ type: :text }, { type: :textarea }] }
it 'render in a fieldset' do
expect(page).to have_selector("fieldset", count: 1)
it 'does not renders within a fieldset' do
expect(page).to have_selector("fieldset", count: 0)
end
it 'renders champs' do
@ -37,14 +37,16 @@ describe EditableChamp::SectionComponent, type: :component do
context 'list of champs without section and an header_section having champs' do
let(:types_de_champ_public) { [{ type: :text }, { type: :header_section, level: 1 }, { type: :text }] }
it 'renders fieldset' do
expect(page).to have_selector("fieldset", count: 2)
expect(page).to have_selector("legend h2")
it 'renders nested champs (after an header section) within a fieldset' do
expect(page).to have_selector("fieldset", count: 1)
expect(page).to have_selector("fieldset legend h2")
expect(page).to have_selector("input[type=text]", count: 2)
expect(page).to have_selector("fieldset input[type=text]", count: 1)
end
it 'renders all champs, each in its fieldset' do
it 'renders nested within its fieldset' do
expect(page).to have_selector("input[type=text]", count: 2)
expect(page).to have_selector("fieldset > .fr-fieldset__element input[type=text]", count: 2)
expect(page).to have_selector("fieldset > .fr-fieldset__element input[type=text]", count: 1)
end
end