2024-01-12 09:12:31 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-08-15 06:44:13 +00:00
|
|
|
module BrowserErrorsHelpers
|
|
|
|
def ignore_js_error(error)
|
|
|
|
@ignored_js_errors_for_spec << error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-12 09:12:31 +00:00
|
|
|
RSpec.configure do |config|
|
2024-08-15 06:44:13 +00:00
|
|
|
config.include BrowserErrorsHelpers, :js, type: :system
|
|
|
|
|
|
|
|
config.before(:each, :js, type: :system) do
|
|
|
|
@ignored_js_errors_for_spec = []
|
|
|
|
end
|
|
|
|
|
2024-05-10 12:36:09 +00:00
|
|
|
config.after(:each, :js, type: :system) do
|
2024-06-25 13:57:40 +00:00
|
|
|
# Classes of intermittent ignorable errors
|
|
|
|
ignored_errors = [
|
|
|
|
/Error while trying to use the following icon from the Manifest/, # https://github.com/mastodon/mastodon/pull/30793
|
2024-07-22 07:46:41 +00:00
|
|
|
/Manifest: Line: 1, column: 1, Syntax error/, # Similar parsing/interruption issue as above
|
2024-08-15 06:44:13 +00:00
|
|
|
].concat(@ignored_js_errors_for_spec)
|
|
|
|
|
2024-06-25 13:57:40 +00:00
|
|
|
errors = page.driver.browser.logs.get(:browser).reject do |error|
|
|
|
|
ignored_errors.any? { |pattern| pattern.match(error.message) }
|
|
|
|
end
|
|
|
|
|
2024-01-12 09:12:31 +00:00
|
|
|
if errors.present?
|
2024-08-15 06:44:13 +00:00
|
|
|
aggregate_failures 'browser errrors' do
|
2024-01-12 09:12:31 +00:00
|
|
|
errors.each do |error|
|
|
|
|
expect(error.level).to_not eq('SEVERE'), error.message
|
|
|
|
next unless error.level == 'WARNING'
|
|
|
|
|
2024-08-15 06:44:13 +00:00
|
|
|
warn 'WARN: browser warning'
|
2024-01-15 21:26:11 +00:00
|
|
|
warn error.message
|
2024-01-12 09:12:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|