From 74927f4ed60a2d564b810e2e6c2cc0283aa8b213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 8 Aug 2018 12:33:09 +0200 Subject: [PATCH] Make Capybara check the page between comment votes As pointed out in PR consul#2734: "After clicking the first link, there's an AJAX request which replaces the existing `.in-favor a` and `.against a` links with new elements. So if Capybara tries to click the existing `.against a` link at the same moment it's being replaced, clicking the link won't generate a new request". Making Capybara check the page for new content before clicking the second link solves the problem. This commit solves issues afecting both Madrid's fork and the original CONSUL repo. --- spec/features/comments/legislation_questions_spec.rb | 5 +++++ spec/features/comments/proposals_spec.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index bc75ecbb74f..f9de250235a 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -499,6 +499,11 @@ within("#comment_#{@comment.id}_votes") do find('.in_favor a').click + + within('.in_favor') do + expect(page).to have_content "1" + end + find('.against a').click within('.in_favor') do diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index e7156019f0d..2b067f55609 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -464,6 +464,11 @@ within("#comment_#{@comment.id}_votes") do find('.in_favor a').click + + within('.in_favor') do + expect(page).to have_content "1" + end + find('.against a').click within('.in_favor') do