From 03ffb0bf27d76a47ef5a3049ea76a4240b5dc3b8 Mon Sep 17 00:00:00 2001 From: Joe <33972521+hnb-ku@users.noreply.github.com> Date: Tue, 21 Jun 2022 12:44:31 +0800 Subject: [PATCH] FIX: Defer scripts on theme-tests route (#17171) Small follow-up to #17063. That PR broke the theme tests route locally. This PR fixes that. --- .../public/assets/scripts/discourse-test-listen-boot.js | 9 +++++++-- app/helpers/qunit_helper.rb | 2 +- app/views/qunit/theme.html.erb | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/public/assets/scripts/discourse-test-listen-boot.js b/app/assets/javascripts/discourse/public/assets/scripts/discourse-test-listen-boot.js index 8f46890eb42..21f78628fd3 100644 --- a/app/assets/javascripts/discourse/public/assets/scripts/discourse-test-listen-boot.js +++ b/app/assets/javascripts/discourse/public/assets/scripts/discourse-test-listen-boot.js @@ -1,4 +1,9 @@ -document.write( - "" +document.body.insertAdjacentHTML( + "afterbegin", + ` + + ` ); + + require('discourse/tests/test-boot-ember-cli'); diff --git a/app/helpers/qunit_helper.rb b/app/helpers/qunit_helper.rb index e0376a1ad26..3ca1b419bfc 100644 --- a/app/helpers/qunit_helper.rb +++ b/app/helpers/qunit_helper.rb @@ -10,6 +10,6 @@ module QunitHelper "#{Discourse.base_path}" \ "/theme-javascripts/tests/#{theme.id}-#{digest}.js" \ "?__ws=#{Discourse.current_hostname}" - "".html_safe + "".html_safe end end diff --git a/app/views/qunit/theme.html.erb b/app/views/qunit/theme.html.erb index 5b2b4c1cdee..bee0041d9e0 100644 --- a/app/views/qunit/theme.html.erb +++ b/app/views/qunit/theme.html.erb @@ -30,7 +30,7 @@ <%- end %> <%- if params['testem'] %> - + <%- end %>