0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-08 17:53:55 +08:00
discourse/app/helpers/qunit_helper.rb
David Taylor 52cc4c6071
DEV: Label plugin/theme qunit test output with target name (#39410)
Previously, plugin/theme qunit test output only showed `Chrome 147.0` with no
indication of which theme/plugin a test belonged to.

This commit registers a `Testem.on("test-result")` hook that prepends
the plugin/theme name to each test name, mirroring how `ember-exam` patches testem output.
2026-04-21 16:52:52 +01:00

16 lines
598 B
Ruby
Vendored

# frozen_string_literal: true
module QunitHelper
def theme_tests
theme = Theme.find_by(id: request.env[:resolved_theme_id])
return "" if theme.blank?
_, digest = theme.baked_js_tests_with_digest
src =
"#{GlobalSetting.cdn_url}" \
"#{Discourse.base_path}" \
"/theme-javascripts/tests/#{theme.id}-#{digest}.js" \
"?__ws=#{Discourse.current_hostname}"
"<link rel='modulepreload' href='#{src}' data-theme-id='#{theme.id}' data-theme-name='#{Rack::Utils.escape_html(theme.name)}' nonce='#{ThemeField::CSP_NONCE_PLACEHOLDER}' />".html_safe
end
end