From bef1b47f0416dbf314e3849d6071e8a4c53deb99 Mon Sep 17 00:00:00 2001 From: Antti Hukkanen Date: Wed, 14 Feb 2024 14:23:48 +0200 Subject: [PATCH] Fix tests with newer version of chromedriver --- .../privacy/test/rspec_support/capybara.rb | 26 +++++++++++++++++++ spec/spec_helper.rb | 5 ++++ 2 files changed, 31 insertions(+) create mode 100644 lib/decidim/privacy/test/rspec_support/capybara.rb diff --git a/lib/decidim/privacy/test/rspec_support/capybara.rb b/lib/decidim/privacy/test/rspec_support/capybara.rb new file mode 100644 index 0000000..c05b878 --- /dev/null +++ b/lib/decidim/privacy/test/rspec_support/capybara.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +# This re-registration is made because of problems with chromedriver v120. +# Selenium methods are undefined without this change. +# See: https://github.com/decidim/decidim/pull/12160 + +require "selenium-webdriver" + +module Decidim + Capybara.register_driver :headless_chrome do |app| + options = ::Selenium::WebDriver::Chrome::Options.new + options.args << "--headless=new" + options.args << "--no-sandbox" + options.args << if ENV["BIG_SCREEN_SIZE"].present? + "--window-size=1920,3000" + else + "--window-size=1920,1080" + end + options.args << "--ignore-certificate-errors" if ENV["TEST_SSL"] + Capybara::Selenium::Driver.new( + app, + browser: :chrome, + capabilities: [options] + ) + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3fa77c0..2b08b78 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,3 +8,8 @@ Decidim::Dev.dummy_app_path = File.expand_path(File.join("spec", "decidim_dummy_app")) require "decidim/dev/test/base_spec_helper" + +# This re-registration is made because of problems with chromedriver v120. +# Selenium methods are undefined without this change. +# See: https://github.com/decidim/decidim/pull/12160 +require "#{ENV.fetch("ENGINE_ROOT")}/lib/decidim/privacy/test/rspec_support/capybara"