Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Restore old headless globally, and activate new headless locally

Christophe Bliarde086485b3b3c
diff --git a/modules/bim/spec/features/bcf/api_authorization_spec.rb b/modules/bim/spec/features/bcf/api_authorization_spec.rb
index 3d2650e6caf..5945f0ed4ba 100644
--- a/modules/bim/spec/features/bcf/api_authorization_spec.rb
+++ b/modules/bim/spec/features/bcf/api_authorization_spec.rb
@@ -128,10 +128,15 @@ RSpec.describe 'authorization for BCF api', :js, with_config: { edition: 'bim' }
logout
- # A basic auth alert is displayed asking to enter name and password
- # Register some basic auth credentials
- # A non-matching url is used so that capybara will issue a CancelAuth instead of trying to authenticate
- page.driver.browser.register(username: 'foo', password: 'bar', uri: /does_not_match/)
+ # A basic auth alert is displayed asking to enter name and password Register
+ # some basic auth credentials
+ # - A non-matching url is used so that capybara will issue a CancelAuth
+ # instead of trying to authenticate
+ # - The register method is not recognized by selenium-webdriver with Chrome
+ # 120 with old headless
+ if page.driver.browser.respond_to?(:register)
+ page.driver.browser.register(username: 'foo', password: 'bar', uri: /does_not_match/)
+ end
# While not being logged in and without a token, the api cannot be accessed
visit("/api/bcf/2.1/projects/#{project.id}")
# Cancel button of basic auth should have been chosen now
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 b91d6c29907..b814cec283a 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,7 @@ require 'spec_helper'
require_relative '../../support/pages/my/page'
-RSpec.describe 'My spent time widget with a negative time zone', :js,
+RSpec.describe 'My spent time widget with a negative time zone', :chrome_headless_new, :js,
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 2e69ac7336f..c1b15bd93da 100644
--- a/spec/support/browsers/chrome.rb
+++ b/spec/support/browsers/chrome.rb
@@ -12,7 +12,20 @@ def register_chrome(language, name: :"chrome_#{language}", override_time_zone: n
end
else
options.add_argument('--window-size=1920,1080')
- options.add_argument('--headless=new')
+ # 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
end
options.add_argument('--no-sandbox')