Skip to content

Commit

Permalink
Install cuprite
Browse files Browse the repository at this point in the history
Execute System Tests through the CDP Protocol via [cuprite][].

This commit installs a dependency on [cuprite@~>0.9][] so that the
`js_errors:` option is available. It was removed in subsequent releases,
but its presence suits Turbo Rails well, since any JavaScript errors
introduced by `turbo-rails.js` should fail the suite.

[cuprite]: https://github.com/rubycdp/cuprite
[cuprite@~>0.9]: https://github.com/rubycdp/cuprite/tree/v0.9#customization
  • Loading branch information
seanpdoyle committed May 14, 2023
1 parent ea00f37 commit c71bfac
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ end
group :test do
gem 'capybara'
gem 'rexml'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'cuprite', '~> 0.9', require: 'capybara/cuprite'
gem 'sqlite3'
end
14 changes: 1 addition & 13 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]

def assert_no_javascript_errors
before = page.driver.browser.logs.get(:browser)

yield

logs = page.driver.browser.logs.get(:browser) - before
errors = logs.select { |log| /severe/i.match?(log.level) }
error_messages = errors.map(&:message)

assert_equal [], error_messages
end
driven_by :cuprite, using: :chrome, screen_size: [1400, 1400], options: { js_errors: true }
end

Capybara.configure do |config|
Expand Down
4 changes: 1 addition & 3 deletions test/system/form_submissions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ class FormSubmissionsTest < ApplicationSystemTestCase

visit edit_article_path(article.id)

assert_no_javascript_errors do
click_on "articles#index"
end
click_on "articles#index"
end

test "form submission method is encoded as _method" do
Expand Down

0 comments on commit c71bfac

Please sign in to comment.