Skip to content

A platform for community discussion. Free, open, simple.

DEV: Label plugin/theme qunit test output with target name (#39410)

David Taylor52cc4c6071f0
diff --git a/app/helpers/qunit_helper.rb b/app/helpers/qunit_helper.rb
index 445a6417731..c1025e06814 100644
--- a/app/helpers/qunit_helper.rb
+++ b/app/helpers/qunit_helper.rb
@@ -11,6 +11,6 @@ module QunitHelper
"#{Discourse.base_path}" \
"/theme-javascripts/tests/#{theme.id}-#{digest}.js" \
"?__ws=#{Discourse.current_hostname}"
- "<link rel='modulepreload' href='#{src}' data-theme-id='#{theme.id}' nonce='#{ThemeField::CSP_NONCE_PLACEHOLDER}' />".html_safe
+ "<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
diff --git a/frontend/discourse/tests/test-boot-ember-cli.js b/frontend/discourse/tests/test-boot-ember-cli.js
index 5b745f150d9..567b1306277 100644
--- a/frontend/discourse/tests/test-boot-ember-cli.js
+++ b/frontend/discourse/tests/test-boot-ember-cli.js
@@ -26,9 +26,10 @@ document.addEventListener("discourse-init", async () => {
const params = new URLSearchParams(window.location.search);
const target = params.get("target") || "core";
const disableAutoStart = params.get("qunit_disable_auto_start") === "1";
- const hasThemeJs = !!document.querySelector(
- "link[rel=modulepreload][data-theme-id]"
- );
+ const themeName = document.querySelector(
+ "link[rel=modulepreload][data-theme-name]"
+ )?.dataset.themeName;
+ const hasThemeJs = !!themeName;
document.body.insertAdjacentHTML(
"afterbegin",
@@ -50,6 +51,12 @@ document.addEventListener("discourse-init", async () => {
setupTests(config.APP);
let loader = loadEmberExam();
+ if (window.Testem && (hasThemeJs || target !== "core")) {
+ window.Testem.on("test-result", (t) => {
+ t.name = `${themeName || target} - ${t.name}`;
+ });
+ }
+
if (QUnit.config.seed === undefined) {
// If we're running in browser, default to random order. Otherwise, let Ember Exam
// handle randomization.