feat(Champ.repetition): hide destroy button of first repetition row when the repetition is mandatory

This commit is contained in:
mfo 2024-04-12 08:34:34 +02:00
parent 4d90b1f662
commit 4773d9ebad
No known key found for this signature in database
GPG key ID: 7CE3E1F5B794A8EC
4 changed files with 18 additions and 5 deletions

View file

@ -131,8 +131,15 @@ describe 'The user' do
fill_in('sub type de champ', with: 'super texte')
expect(page).to have_field('sub type de champ', with: 'super texte')
# first repetition have a destroy hidden
expect(page).to have_selector(".repetition .row .utils-repetition-required-destroy-button", count: 1, visible: false)
expect(page).to have_selector(".repetition .row", count: 1)
# adding an element means we can ddestroy last item
click_on 'Ajouter un élément pour'
expect(page).to have_content('Supprimer', count: 2)
expect(page).to have_selector(".repetition .row:first-child .utils-repetition-required-destroy-button", count: 1, visible: false)
expect(page).to have_selector(".repetition .row", count: 2)
expect(page).to have_selector(".repetition .row:last-child .utils-repetition-required-destroy-button", count: 1, visible: true)
within '.repetition .row:first-child' do
fill_in('sub type de champ', with: 'un autre texte')
@ -140,10 +147,12 @@ describe 'The user' do
end
expect do
within '.repetition .row:first-child' do
within '.repetition .row:last-child' do
click_on 'Supprimer lélément'
end
expect(page).to have_content('Supprimer', count: 1)
wait_until { page.all(".row").size == 1 }
# removing a repetition means one child only, thus its button destroy is not visible
expect(page).to have_selector(".repetition .row:first-child .utils-repetition-required-destroy-button", count: 1, visible: false)
end.to change { Champ.count }
end