Skip to content

Commit

Permalink
Switch to Cuprite to run tests
Browse files Browse the repository at this point in the history
[finishes #182981751]
  • Loading branch information
ohrite committed Aug 13, 2022
1 parent d24edcb commit f5158dd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 43 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ end

group :test do
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
gem 'cuprite'
gem 'shoulda-matchers', '~> 5.0'
gem 'webdrivers'
end
24 changes: 10 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
childprocess (4.1.0)
cliver (0.3.2)
concurrent-ruby (1.1.10)
crass (1.0.6)
cuprite (0.13)
capybara (>= 2.1, < 4)
ferrum (~> 0.11.0)
debug (1.6.2)
irb (>= 1.3.6)
reline (>= 0.3.1)
Expand Down Expand Up @@ -152,6 +155,11 @@ GEM
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.0)
ferrum (0.11)
addressable (~> 2.5)
cliver (~> 0.3)
concurrent-ruby (~> 1.1)
websocket-driver (>= 0.6, < 0.8)
ffi (1.15.5)
geared_pagination (1.1.2)
activesupport (>= 5.0)
Expand Down Expand Up @@ -374,16 +382,10 @@ GEM
ruby-vips (2.1.4)
ffi (~> 1.12)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rugged (1.0.1)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
selenium-webdriver (4.4.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
shoulda-matchers (5.1.0)
activesupport (>= 5.2.0)
smart_properties (1.17.0)
Expand Down Expand Up @@ -421,11 +423,6 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.0.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -443,6 +440,7 @@ DEPENDENCIES
annotate
bootsnap
capybara (>= 3.26)
cuprite
debug
devise
devise-guests
Expand Down Expand Up @@ -477,7 +475,6 @@ DEPENDENCIES
rubocop-performance
rubocop-rails
rubocop-rspec
selenium-webdriver
shoulda-matchers (~> 5.0)
standard
stimulus-rails
Expand All @@ -486,7 +483,6 @@ DEPENDENCIES
tzinfo-data
view_component
web-console
webdrivers

RUBY VERSION
ruby 3.1.2p20
Expand Down
22 changes: 9 additions & 13 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
require 'capybara/cuprite'
require 'capybara/rspec'
require 'view_component/test_helpers'

Capybara.default_driver = :rack_test
Capybara.javascript_driver = :selenium_chrome_headless
Capybara.javascript_driver = :cuprite
Capybara.server = :puma, {Silent: true}

Capybara.register_driver :selenium_chrome_headless do |app|
Capybara::Selenium::Driver.load_selenium
browser_options = ::Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.args << '--window-size=1920,1080'
opts.args << '--force-device-scale-factor=0.95'
opts.args << '--headless'
opts.args << '--disable-gpu'
opts.args << '--disable-site-isolation-trials'
opts.args << '--no-sandbox'
end
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
Capybara.register_driver(:cuprite) do |app|
Capybara::Cuprite::Driver.new(
app,
window_size: [1920, 1080],
headless: false
)
end

module FakeCapybaraPage
Expand All @@ -31,5 +27,5 @@ def page
config.include Capybara::RSpecMatchers, type: :component
config.include ViewComponent::TestHelpers, type: :component
config.before(:each, type: :system) { driven_by(:rack_test) }
config.before(:each, type: :system, js: true) { driven_by(:selenium_chrome_headless) }
config.before(:each, type: :system, js: true) { driven_by(:cuprite) }
end
16 changes: 2 additions & 14 deletions spec/system/creating_a_retrospective_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
require 'rails_helper'

RSpec.describe 'Creating a retrospective', js: true do
RSpec.describe 'Creating a retrospective', :js, type: :system do
before do
OmniAuth.config.mock_auth[:google_oauth2] = OmniAuth::AuthHash.new(uid: '123545', info: {email: '[email protected]', name: 'Minifast User', image: 'https://placekitten.com/80/80'})
Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:google_oauth2]
page.driver.browser.execute_cdp(
'Browser.setPermission',
origin: page.server_url,
permission: {name: 'clipboard-read'},
setting: 'granted'
)
page.driver.browser.execute_cdp(
'Browser.setPermission',
origin: page.server_url,
permission: {name: 'clipboard-write'},
setting: 'granted'
)
end

it 'adds a board' do
Expand Down Expand Up @@ -60,7 +48,7 @@

click_on 'Copy Invite Link'

invite_url = page.evaluate_async_script('navigator.clipboard.readText().then(arguments[0])')
invite_url = find('input[data-clipboard-target]', visible: false).value
expect(invite_url).to end_with(board_share_path(Board.most_recent.first, Board.most_recent.first.share_token))

using_session(:guest) do
Expand Down

0 comments on commit f5158dd

Please sign in to comment.