Extract capybara config and improve headless_chrome driver config (#28681)

main
Matt Jankowski 2024-01-10 09:54:11 -05:00 committed by GitHub
parent 543d7890fd
commit 8422b8ded0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -108,8 +108,6 @@ RSpec.configure do |config|
end
config.around :each, type: :system do |example|
driven_by :selenium, using: :headless_chrome, screen_size: [1600, 1200]
# The streaming server needs access to the database
# but with use_transactional_tests every transaction
# is rolled-back, so the streaming server never sees the data

31
spec/support/capybara.rb Normal file
View File

@ -0,0 +1,31 @@
# frozen_string_literal: true
Capybara.server_host = 'localhost'
Capybara.server_port = 3000
Capybara.app_host = "http://#{Capybara.server_host}:#{Capybara.server_port}"
require 'selenium/webdriver'
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument '--headless=new'
options.add_argument '--window-size=1680,1050'
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options
)
end
Capybara.javascript_driver = :headless_chrome
RSpec.configure do |config|
config.before(:each, type: :system) do
driven_by Capybara.javascript_driver
end
end