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.
This commit is contained in:
Javi Martín
2018-10-17 14:06:26 +02:00
committed by decabeza
parent c80e436614
commit 5e95339e51

View File

@@ -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'