diff --git a/modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb b/modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb index b814cec283a5..cae201f0f76b 100644 --- a/modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb +++ b/modules/my_page/spec/features/my/my_spent_time_widget_with_a_negative_time_zone_spec.rb @@ -30,7 +30,8 @@ require_relative '../../support/pages/my/page' -RSpec.describe 'My spent time widget with a negative time zone', :chrome_headless_new, :js, +RSpec.describe 'My spent time widget with a negative time zone', :js, + driver: :chrome_headless_new, with_settings: { start_of_week: 1 } do let(:beginning_of_week) { monday } let(:end_of_week) { sunday } diff --git a/spec/support/browsers/chrome.rb b/spec/support/browsers/chrome.rb index c1b15bd93dac..0aff91f896a1 100644 --- a/spec/support/browsers/chrome.rb +++ b/spec/support/browsers/chrome.rb @@ -1,5 +1,5 @@ # rubocop:disable Metrics/PerceivedComplexity -def register_chrome(language, name: :"chrome_#{language}", override_time_zone: nil) +def register_chrome(language, name: :"chrome_#{language}", headless: 'old', override_time_zone: nil) Capybara.register_driver name do |app| options = Selenium::WebDriver::Chrome::Options.new @@ -12,20 +12,7 @@ def register_chrome(language, name: :"chrome_#{language}", override_time_zone: n end else options.add_argument('--window-size=1920,1080') - # Our tests are not that stable with the new headless mode, but since - # Chrome 120 the old headless mode has browser name - # "chrome-headless-shell". This name is not recognized by the current - # selenium-webdriver and so some extensions like `execute_cdp` are - # missing. This wil be fixed in next selenium-webdriver version. See - # https://github.com/SeleniumHQ/selenium/pull/13271 for more information. - # - # In the meantime, the :chrome_headless_new metadata allows activating the - # new headless for tests that need it. - if RSpec.current_example.metadata[:chrome_headless_new] - options.add_argument('--headless=new') - else - options.add_argument('--headless=old') - end + options.add_argument("--headless=#{headless}") end options.add_argument('--no-sandbox') @@ -109,6 +96,19 @@ def register_chrome(language, name: :"chrome_#{language}", override_time_zone: n end end +# Register Chrome with new headless implementation +# +# Our tests are not that stable with the new headless mode, but since +# Chrome 120 the old headless mode has browser name +# "chrome-headless-shell". This name is not recognized by the current +# selenium-webdriver and so some extensions like `execute_cdp` are +# missing. This wil be fixed in next selenium-webdriver version. See +# https://github.com/SeleniumHQ/selenium/pull/13271 for more information. +# +# In the meantime, registering a :chrome_headless_new driver which uses the +# `headless=new` flag for tests that need it. +register_chrome 'en', name: :chrome_headless_new, headless: 'new' + # Register mocking proxy driver register_chrome 'en', name: :chrome_billy do |options| options.add_argument("proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}")