Skip to content

Commit

Permalink
Restore old headless globally, and activate new headless locally
Browse files Browse the repository at this point in the history
It's hard to stabilize all tests with new headless
  • Loading branch information
cbliard committed Dec 18, 2023
1 parent cd56517 commit e086485
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 9 additions & 4 deletions modules/bim/spec/features/bcf/api_authorization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ def oauth_path(client_id)

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

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 }
Expand Down
15 changes: 14 additions & 1 deletion spec/support/browsers/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit e086485

Please sign in to comment.