From 27a4dc14718be14f31a0e30a03a1e8eb830ad60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 15 Oct 2024 12:13:53 +0200 Subject: [PATCH] Check page content in ballots specs Even after disabling the turbolinks previews in the previous commit (which is still necessary, even with the changes in this commit), these tests were still finishing before the "Go back" requests did. To reproduce an issue caused by this behavior, run: ``` rspec spec/system/budgets/ballots_spec.rb:425 spec/system/users_auth_spec.rb:701 --seed 40358 ``` Apparently, a `have_current_path` expectation isn't enough to check that the request has finished and it only checks that the request to that path has started or it's being processed. Adding an additional expectation to check that the content of the page has changed solves the issue. --- spec/system/budgets/ballots_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/system/budgets/ballots_spec.rb b/spec/system/budgets/ballots_spec.rb index 981d26c12..2d35fc40b 100644 --- a/spec/system/budgets/ballots_spec.rb +++ b/spec/system/budgets/ballots_spec.rb @@ -444,6 +444,7 @@ describe "Ballots" do click_link "Go back" expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id)) + expect(page).to have_link "Check my votes" end scenario "before adding any investments" do @@ -459,6 +460,7 @@ describe "Ballots" do click_link "Go back" expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id)) + expect(page).to have_link "Check my votes" end end