From 2343ee83efdc0852845ec4680c97803c7954d585 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 14 Nov 2023 09:23:00 +0100 Subject: [PATCH] test: fix flaky brouillon on repetition --- spec/support/system_helpers.rb | 6 +++++- spec/system/users/brouillon_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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'