From 5e95339e518364586322f5044b030445bb92b5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 17 Oct 2018 14:06:26 +0200 Subject: [PATCH] Fix flaky legislation question spec The test was failing sometimes because of the sequence: within('#side_menu') do click_link "Collaborative Legislation" end click_link "All" expect(page).to have_content 'An example legislation process' click_link 'An example legislation process' Right after clicking the "Collaborative Legislation" link, the link 'An example legislation process' is already available. So sometimes Capybara might click the links "All" and 'An example legislation process' at more or less the same time, causing the second link not to be correctly clicked. Making sure the "All" link doesn't exist anymore we guarantee Capybara will wait for the previous AJAX request to finish before clicking the next link. Note the test to "Create Valid legislation question" is almost identical but it doesn't fail because it doesn't use Capybara's JavaScript driver. --- spec/features/admin/legislation/questions_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/legislation/questions_spec.rb b/spec/features/admin/legislation/questions_spec.rb index b176ecaac..1ae23a566 100644 --- a/spec/features/admin/legislation/questions_spec.rb +++ b/spec/features/admin/legislation/questions_spec.rb @@ -85,7 +85,7 @@ feature 'Admin legislation questions' do click_link "All" - expect(page).to have_content 'An example legislation process' + expect(page).not_to have_link "All" click_link 'An example legislation process' click_link 'Debate'