From e79ad80504dda2bba57d28f7cfd2faecd8376102 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Fri, 23 Jun 2023 13:21:33 -0400 Subject: [PATCH] Change test to be less specific We were checking for the actual value of the countdown timer; now we're just checking that it's here and numeric. Flaky test failure where the generated regex was covering 49-58 seconds, and the displayed seconds value was 59. [skip changelog] --- spec/features/users/sign_in_spec.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spec/features/users/sign_in_spec.rb b/spec/features/users/sign_in_spec.rb index 84d902ce34a..271a51ce5b2 100644 --- a/spec/features/users/sign_in_spec.rb +++ b/spec/features/users/sign_in_spec.rb @@ -258,17 +258,15 @@ t('datetime.dotiw.two_words_connector'), ].join('') - pattern1 = Regexp.new(minutes_and + t('datetime.dotiw.seconds.other', count: '\d+')) - expect(page).to have_content(pattern1, wait: 5) - time = page.text[pattern1] - seconds = time.split(t('datetime.dotiw.two_words_connector')).last[/\d+/].to_i - pattern2 = Regexp.new( + minutes_pattern = Regexp.new(minutes_and + t('datetime.dotiw.seconds.other', count: '\d+')) + expect(page).to have_content(minutes_pattern, wait: 5) + seconds_pattern = Regexp.new( minutes_and + t( 'datetime.dotiw.seconds.other', - count: (seconds - 10...seconds).to_a.join('|'), + count: '\d+', ), ) - expect(page).to have_content(pattern2, wait: 5) + expect(page).to have_content(seconds_pattern, wait: 5) end scenario 'user can continue browsing with refreshed CSRF token' do