mastodon/spec/support/browser_errors.rb
Matt Jankowski 629bb74451
Some checks failed
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
Haml Linting / lint (push) Has been cancelled
Replace selenium-webdriver with playwright (#34867)
2025-06-10 16:33:46 +00:00

47 lines
1.4 KiB
Ruby

# frozen_string_literal: true
module BrowserErrorsHelpers
def ignore_js_error(error)
@ignored_js_errors_for_spec << error
end
end
RSpec.configure do |config|
config.include BrowserErrorsHelpers, :js, type: :system
config.before(:each, :js, type: :system) do |example|
@ignored_js_errors_for_spec = []
example.metadata[:js_console_messages] ||= []
Capybara.current_session.driver.with_playwright_page do |page|
page.on('console', lambda { |msg|
example.metadata[:js_console_messages] << { type: msg.type, text: msg.text, location: msg.location }
})
end
end
config.after(:each, :js, type: :system) do |example|
# 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
/Manifest: Line: 1, column: 1, Syntax error/, # Similar parsing/interruption issue as above
].concat(@ignored_js_errors_for_spec)
errors = example.metadata[:js_console_messages].reject do |msg|
ignored_errors.any? { |pattern| pattern.match(msg[:text]) }
end
if errors.present?
aggregate_failures 'browser errrors' do
errors.each do |error|
expect(error[:type]).to_not eq('error'), error[:text]
next unless error[:type] == 'warning'
warn 'WARN: browser warning'
warn error[:text]
end
end
end
end
end