From f6eb34192fab53d8beabb0f8e217a50df389fb3f Mon Sep 17 00:00:00 2001 From: Sina Eftekhar Date: Tue, 2 Jan 2024 10:21:40 +0200 Subject: [PATCH] Fix the issue with chromedriver update to v.120 --- .../test/rspec_support/capybara.rb | 25 +++++++++++++++++++ spec/spec_helper.rb | 4 +++ 2 files changed, 29 insertions(+) create mode 100644 lib/decidim/term_customizer/test/rspec_support/capybara.rb diff --git a/lib/decidim/term_customizer/test/rspec_support/capybara.rb b/lib/decidim/term_customizer/test/rspec_support/capybara.rb new file mode 100644 index 0000000..ba81607 --- /dev/null +++ b/lib/decidim/term_customizer/test/rspec_support/capybara.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require "selenium-webdriver" + +module Decidim + # This is being added because of the issues with the chrome-driver + # in version 120 or later, and this can be removed after this pr#12160 + # being merged(more info https://github.com/decidim/decidim/pull/12159). + 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 0b80de0..6e46fd4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,6 +8,10 @@ File.expand_path(File.join(__dir__, "decidim_dummy_app")) require "decidim/dev/test/base_spec_helper" +# This is being added because of the issues with the chrome-driver +# in version 120 or later, and this can be removed after this pr#12160 +# being merged(more info https://github.com/decidim/decidim/pull/12159). +require "#{Dir.pwd}/lib/decidim/term_customizer/test/rspec_support/capybara.rb" RSpec.configure do |config| # Add extra traslation load path for the tests