diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index c8035ab72..c66622c2c 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -81,7 +81,11 @@ module SystemHelpers end def blur - page.find('body').click + if page.has_css?('body', wait: 0) + page.find('body').click + else # page after/inside a `within` block does not match body + page.first('div').click + end end def pause diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index 13ad2760b..82891203d 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -128,13 +128,13 @@ describe 'The user' do expect(page).to have_field('sub type de champ', with: 'super texte') click_on 'Ajouter un élément pour' + expect(page).to have_content('Supprimer', count: 2) within '.repetition .row:first-child' do fill_in('sub type de champ', with: 'un autre texte') + blur end - expect(page).to have_content('Supprimer', count: 2) - expect do within '.repetition .row:first-child' do click_on 'Supprimer l’élément'