From 781188758ad484d53c1574643c36ea8ecd913204 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2019 10:46:58 +0000 Subject: [PATCH 1/4] Bump capybara from 2.17.0 to 3.29.0 Bumps [capybara](https://github.com/teamcapybara/capybara) from 2.17.0 to 3.29.0. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/2.17.0...3.29.0) Signed-off-by: dependabot-preview[bot] --- Gemfile | 2 +- Gemfile.lock | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index a5f83ab75..9fcadcea9 100644 --- a/Gemfile +++ b/Gemfile @@ -79,7 +79,7 @@ group :development, :test do end group :test do - gem "capybara", "~> 2.17.0" + gem "capybara", "~> 3.29.0" gem "capybara-webmock", "~> 0.5.3" gem "coveralls", "~> 0.8.22", require: false gem "database_cleaner", "~> 1.7.0" diff --git a/Gemfile.lock b/Gemfile.lock index d72182a62..6e9a5b2eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,13 +114,14 @@ GEM capistrano (~> 3.7) capistrano-bundler puma (~> 4.0) - capybara (2.17.0) + capybara (3.29.0) addressable mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) capybara-webmock (0.5.3) capybara (>= 2.4, < 4) rack (>= 1.4) @@ -447,6 +448,7 @@ GEM mail redcarpet (3.4.0) referer-parser (0.3.0) + regexp_parser (1.6.0) request_store (1.4.0) rack (>= 1.4) responders (2.4.1) @@ -594,7 +596,7 @@ GEM chronic (>= 0.6.3) wicked_pdf (1.1.0) wkhtmltopdf-binary (0.12.4) - xpath (3.0.0) + xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS @@ -615,7 +617,7 @@ DEPENDENCIES capistrano-rails (~> 1.4.0) capistrano3-delayed-job (~> 1.7.3) capistrano3-puma (~> 4.0.0) - capybara (~> 2.17.0) + capybara (~> 3.29.0) capybara-webmock (~> 0.5.3) ckeditor (~> 4.3.0) cocoon (~> 1.2.9) From 3a15bed471847503f3d5d3e211ee49c3254df9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 18 Nov 2019 15:02:51 +0100 Subject: [PATCH 2/4] Use JavaScript driver in ballot sheet spec With the rack driver, the `ballot_sheet.data` text was being converted from newline characters to whitespace, while with the JavaScript driver we get newline characters for `
` tags, as we expect. --- spec/features/budget_polls/ballot_sheets_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/budget_polls/ballot_sheets_spec.rb b/spec/features/budget_polls/ballot_sheets_spec.rb index 8745d18a1..e37a3b181 100644 --- a/spec/features/budget_polls/ballot_sheets_spec.rb +++ b/spec/features/budget_polls/ballot_sheets_spec.rb @@ -142,7 +142,7 @@ describe "Poll budget ballot sheets" do set_officing_booth(booth) end - scenario "Ballot sheet information is displayed" do + scenario "Ballot sheet information is displayed", :js do officer_assignment = create(:poll_officer_assignment, officer: poll_officer) ballot_sheet = create(:poll_ballot_sheet, poll: poll, officer_assignment: officer_assignment) From 971571b54b502bb0ec1a7180ddcaa225f533f94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 18 Nov 2019 15:47:47 +0100 Subject: [PATCH 3/4] Simplify testing followables flash messages Checking the whole text is tricky because the text has a `
` tag, and now Capybara doesn't normalize whitespace by default anymore. Here are a couple more options we could use: ``` expect(page).to have_content strip_tags(message.gsub(/\s*
\s*/,"\n")) expect(page).to have_content strip_tags(message), normalize_ws: true ``` But then developers would wonder why we're doing all this, and would need an extra effort to fully understand the test. Since the tests are only checking the presence of the flash message, checking a relevant part of the test is enough, works with any version of Capybara, and makes the test easy to follow. --- spec/shared/features/followable.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/shared/features/followable.rb b/spec/shared/features/followable.rb index 6fd24d236..8bfbca12b 100644 --- a/spec/shared/features/followable.rb +++ b/spec/shared/features/followable.rb @@ -55,14 +55,13 @@ shared_examples "followable" do |followable_class_name, followable_path, followa scenario "Should display new follower notice after user clicks on follow button", :js do user = create(:user) login_as(user) - create_notice_message = t("shared.followable.#{followable_class_name}.create.notice") visit send(followable_path, arguments) within "##{dom_id(followable)}" do click_link("Follow #{followable.model_name.human.downcase}") end - expect(page).to have_content strip_tags(create_notice_message) + expect(page).to have_content "We will notify you of changes as they occur" end scenario "Display unfollow button when user already following" do @@ -90,14 +89,13 @@ shared_examples "followable" do |followable_class_name, followable_path, followa scenario "Should display destroy follower notice after user clicks on unfollow button", :js do user = create(:user, followables: [followable]) login_as(user) - destroy_notice_message = t("shared.followable.#{followable_class_name}.destroy.notice") visit send(followable_path, arguments) within "##{dom_id(followable)}" do click_link("Unfollow #{followable.model_name.human.downcase}") end - expect(page).to have_content strip_tags(destroy_notice_message) + expect(page).to have_content "You will no longer receive notifications" end end end From fe20688d47f1d28bcdba1032493f8a56acefd156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 18 Nov 2019 16:14:47 +0100 Subject: [PATCH 4/4] Update test of text with `position:absolute` The following code: ``` You're on page 1 ``` Will generate an element with `position: absolute`. When reading the contents, it's not clear whether this element is supposed to be in the same paragraph or in a different one. Currently Capybara treats it as if it were part of a different paragraph. Since this could be the way screen readers read the text, I'm changing the test to reflect this fact. We might change our minds in the future. --- spec/features/legislation/proposals_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/legislation/proposals_spec.rb b/spec/features/legislation/proposals_spec.rb index f1e27dedf..130d41d91 100644 --- a/spec/features/legislation/proposals_spec.rb +++ b/spec/features/legislation/proposals_spec.rb @@ -72,12 +72,12 @@ describe "Legislation Proposals" do click_link "Next" - expect(page).to have_content "You're on page 2" + expect(page).to have_content "You're on page\n2" expect(first_page_proposals_order & legislation_proposals_order).to eq([]) click_link "Previous" - expect(page).to have_content "You're on page 1" + expect(page).to have_content "You're on page\n1" expect(legislation_proposals_order).to eq(first_page_proposals_order) end