DEV: Summarize JS deprecations at end of system spec run (#24824)

This commit is contained in:
David Taylor 2023-12-13 16:04:25 +00:00 committed by GitHub
parent c9cf3f5a52
commit 6731eec42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 4 deletions

View File

@ -17,6 +17,35 @@ module TurboTests
end
end
js_deprecation_totals = {}
notification.examples.each do |example|
example.metadata[:js_deprecations]&.each do |id, count|
js_deprecation_totals[id] ||= 0
js_deprecation_totals[id] += count
end
end
if js_deprecation_totals.present?
max_id_length = js_deprecation_totals.keys.map(&:length).max
output.puts "\n[Deprecation Counter] Test run completed with deprecations:\n\n"
table = ""
table += "| #{"id".ljust(max_id_length)} | count |\n"
table += "| #{"-" * max_id_length} | ----- |\n"
js_deprecation_totals.each do |id, count|
table += "| #{id.ljust(max_id_length)} | #{count.to_s.ljust(5)} |\n"
end
output.puts table
if ENV["GITHUB_ACTIONS"] && ENV["GITHUB_STEP_SUMMARY"]
job_summary = "### ⚠️ JS Deprecations\n\nTest run completed with deprecations:\n\n"
job_summary += table
job_summary += "\n\n"
File.write(ENV["GITHUB_STEP_SUMMARY"], job_summary)
end
end
super(notification)
end
end

View File

@ -19,6 +19,7 @@ module TurboTests
extra_failure_lines: @rspec_example.metadata[:extra_failure_lines],
run_duration_ms: @rspec_example.metadata[:run_duration_ms],
process_pid: Process.pid,
js_deprecations: @rspec_example.metadata[:js_deprecations],
},
location_rerun_argument: @rspec_example.location_rerun_argument,
}

View File

@ -377,7 +377,7 @@ RSpec.configure do |config|
end
# possible values: OFF, SEVERE, WARNING, INFO, DEBUG, ALL
browser_log_level = ENV["SELENIUM_BROWSER_LOG_LEVEL"] || "SEVERE"
browser_log_level = ENV["SELENIUM_BROWSER_LOG_LEVEL"] || "WARNING"
chrome_browser_options =
Selenium::WebDriver::Chrome::Options
@ -531,6 +531,8 @@ RSpec.configure do |config|
lines << "~~~~~ END DRIVER LOGS ~~~~~"
end
js_logs = page.driver.browser.logs.get(:browser)
# Recommended that this is not disabled, since it makes debugging
# failed system tests a lot trickier.
if ENV["SELENIUM_DISABLE_VERBOSE_JS_LOGS"].blank?
@ -547,11 +549,10 @@ RSpec.configure do |config|
if !skip_js_errors
lines << "~~~~~~~ JS LOGS ~~~~~~~"
logs = page.driver.browser.logs.get(:browser)
if logs.empty?
if js_logs.empty?
lines << "(no logs)"
else
logs.each do |log|
js_logs.each do |log|
# System specs are full of image load errors that are just noise, no need
# to log this.
if (
@ -569,6 +570,16 @@ RSpec.configure do |config|
end
end
js_logs.each do |log|
next if log.level != "WARNING"
deprecation_id = log.message[/\[deprecation id: ([^\]]+)\]/, 1]
next if deprecation_id.nil?
deprecations = RSpec.current_example.metadata[:js_deprecations] ||= {}
deprecations[deprecation_id] ||= 0
deprecations[deprecation_id] += 1
end
page.execute_script("if (typeof MessageBus !== 'undefined') { MessageBus.stop(); }")
MessageBus.backend_instance.reset! # Clears all existing backlog from memory backend
Scheduler::Defer.do_all_work # Process everything that was added to the defer queue when running the test