From de9c261c0ebd6f16e0b18d064775dcbbede5b1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 23 Mar 2021 16:41:39 +0100 Subject: [PATCH] Clear fields in tests before filling them in There seems to be an issue with capybara or chromedriver which results in `fill_in` sometimes appending to an input rather than overwriting [1], causing some tests to fail under certain circumstances. Clearing fields before filling them in solves the issue. Note we're now getting warnings on all tests using the rack driver. I haven't found a way to avoid the `clear: :backspace` option in non-JavaScript tests, so to avoid the annoying warnings we should reduce the number of tests using the rack driver even more. [1] See issue 2419 in https://github.com/teamcapybara/capybara/issues --- spec/rails_helper.rb | 1 + spec/system/budgets/ballots_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a3ecc187d..06d22b895 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -47,6 +47,7 @@ end Capybara.exact = true Capybara.enable_aria_label = true +Capybara.default_set_options = { clear: :backspace } Capybara.disable_animation = true OmniAuth.config.test_mode = true diff --git a/spec/system/budgets/ballots_spec.rb b/spec/system/budgets/ballots_spec.rb index 3306425e5..6876b4a79 100644 --- a/spec/system/budgets/ballots_spec.rb +++ b/spec/system/budgets/ballots_spec.rb @@ -645,6 +645,10 @@ describe "Ballots" do click_button "Save heading" expect(page).to have_content "Heading updated successfully" + + within "tr", text: "New York" do + expect(page).to have_css "td", exact_text: "€10" + end end in_browser(:user) do