diff --git a/.gitlab/ci/version.yml b/.gitlab/ci/version.yml index 3d7ac30ab2d579de2ff48a31e7c4c6daa57e80ba..aab3b3de2c6b5616cc4871066d3f770a542f490a 100644 --- a/.gitlab/ci/version.yml +++ b/.gitlab/ci/version.yml @@ -1,6 +1,6 @@ variables: BUILD_OS: "debian" - CHROME_VERSION: "123" + CHROME_VERSION: "138" DOCKER_VERSION: "27.4.1" EXIFTOOL_VERSION: "12.60" GCLOUD_VERSION: "413" diff --git a/qa/Dockerfile b/qa/Dockerfile index a10db24c2f0566b468584e9b6a7a173bb120e86c..4a66992bddabfa5a1654885a6a6a71b75b5538bc 100644 --- a/qa/Dockerfile +++ b/qa/Dockerfile @@ -1,5 +1,5 @@ ARG BUILD_OS=debian -ARG CHROME_VERSION=123 +ARG CHROME_VERSION=138 ARG DOCKER_VERSION=24.0.5 ARG GCLOUD_VERSION=413 ARG GIT_VERSION=2.51 diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index e49b4707e2ed865c2dddc8682120118d19d8813e..4245839cfd93b4f6ef5d9b6e280fdb78fac0ee30 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -146,9 +146,7 @@ def fill_form # not anymore as requests when they come straight from memory cache. # accept_confirm is needed because of https://gitlab.com/gitlab-org/gitlab/-/issues/262102 reqs = inspect_requests do - visit("#{link}?ran=#{SecureRandom.base64(20)}") do - page.driver.browser.switch_to.alert.accept - end + visit("#{link}?ran=#{SecureRandom.base64(20)}") end expect(reqs.first.status_code).to eq(200) end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 7d58a81ede157753a7213b495b07f681a309e2eb..e73363468e13ca554dffd64fff2bcfce3c1dcefc 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -37,19 +37,20 @@ # Force the browser's scale factor to prevent inconsistencies on high-res devices options.add_argument('--force-device-scale-factor=1') - options.add_argument("window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}") + options.add_argument("--window-size=#{CAPYBARA_WINDOW_SIZE.join(',')}") # Chrome won't work properly in a Docker container in sandbox mode - options.add_argument("no-sandbox") + options.add_argument("--no-sandbox") - options.add_argument("disable-search-engine-choice-screen") + options.add_argument("--disable-search-engine-choice-screen") # Ensure the Chrome locale is `en` so all dates are deterministic regardless of local settings options.add_preference('intl.accept_languages', 'en') unless ENV['WEBDRIVER_HEADLESS'] =~ /^(false|no|0)$/i || ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i # Run headless by default unless WEBDRIVER_HEADLESS specified - options.add_argument("headless") + options.add_argument('--headless=new') + options.add_argument('--disable-gpu') # Chrome may not run `requestAnimationFrame` callbacks when running multiple test cases in headless # mode due to background tab optimizations. We can disable some troublesome optimizations below. @@ -61,7 +62,7 @@ end # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab/issues/4252 - options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER'] + options.add_argument("--disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER'] # Set chrome default download path if ENV['DEFAULT_CHROME_DOWNLOAD_PATH'] @@ -148,6 +149,21 @@ webmock_enable! end + # Restart Chrome after each test file to clear file descriptors + config.after(:context, :js) do + # Clear the Capybara session pool to force new Chrome instance + Capybara.send(:session_pool).clear + + # Kill any remaining Chrome processes to release file descriptors + system("pkill -9 -f '/opt/google/chrome/chrome' 2>/dev/null || true") + system("pkill -9 -f 'Google Chrome.*--test-type=webdriver' 2>/dev/null || true") + + # Small delay to ensure cleanup + sleep 0.5 + + puts "Chrome restarted after test file: #{self.class.metadata[:file_path]}" + end + config.before(:example, :js) do clear_browser_logs