Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ruby '3.2.4'
gem 'rails', '~> 7.2.2.1'
gem 'puma', '~> 6.6' # roar
gem 'sdoc', '~> 2.6.0', group: :doc
gem 'nokogiri', '>= 1.13.4'
gem 'nokogiri', '>= 1.18.4'
gem 'tzinfo-data', require: false
gem 'bootsnap', '>= 1.4.2', require: false
gem 'rexml' # not a ruby default in 3, but a requirement of bootsnap
Expand Down Expand Up @@ -104,6 +104,7 @@ group :test do
# Systemtest related tools
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'capybara-screenshot'
gem 'launchy' # open up capybara screenshots automatically with `save_and_open_screenshot`

Expand Down
11 changes: 8 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.3)
nokogiri (1.18.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.3-x86_64-linux-gnu)
nokogiri (1.18.6-x86_64-linux-gnu)
racc (~> 1.4)
oauth2 (2.0.9)
faraday (>= 0.17.3, < 3.0)
Expand Down Expand Up @@ -477,6 +477,10 @@ GEM
method_source (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
websocket (1.2.11)
websocket-driver (0.7.7)
base64
Expand Down Expand Up @@ -527,7 +531,7 @@ DEPENDENCIES
net-imap
net-pop
net-smtp
nokogiri (>= 1.13.4)
nokogiri (>= 1.18.4)
omniauth-google-oauth2 (~> 1.2.1)
omniauth-rails_csrf_protection (~> 1.0)
paper_trail (~> 16.0)
Expand Down Expand Up @@ -560,6 +564,7 @@ DEPENDENCIES
twilio-ruby
tzinfo-data
view_component (~> 3.21)
webdrivers
wicked

RUBY VERSION
Expand Down
43 changes: 35 additions & 8 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
require 'test_helper'
require 'integration_helper'
require 'capybara/rails'
require 'capybara/selenium/driver'
require 'webdrivers'

# Set systemtest behavior
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include IntegrationHelper
include OmniauthMocker

# Configure webdrivers to use the latest compatible version
Webdrivers::Chromedriver.update

# Explicitly register a selenium chrome headless driver
Capybara.register_driver :headless_chrome do |app|
chrome_options = Selenium::WebDriver::Chrome::Options.new(
args: [
'--headless=new',
'--disable-gpu',
'--no-sandbox',
'--disable-dev-shm-usage',
'--disable-site-isolation-trials',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-renderer-backgrounding'
]
)

Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: chrome_options
)
end

# Conditionally select driver based on environment
if ENV['GITHUB_WORKFLOW'] || ENV['DOCKER']
driven_by :selenium, using: :headless_chrome
else
driven_by :selenium, using: :chrome
end

before do
Capybara.reset_sessions!
PaperTrail.enabled = true
Expand All @@ -16,12 +51,4 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
PaperTrail.enabled = false
PaperTrail.request.enabled = false
end

# if in CI, run system tests headlessly.
browser = ENV['GITHUB_WORKFLOW'] ? :headless_chrome : :chrome

# if in docker, run headless firefox
browser = ENV['DOCKER'] ? :headless_firefox : browser

driven_by :selenium, using: browser
end
Loading