A platform for community discussion. Free, open, simple.
DEV: Allow running theme-qunit tests via testem (#16540)
David Taylor127ba698a71e
diff --git a/app/assets/javascripts/discourse/testem.js b/app/assets/javascripts/discourse/testem.jsindex cc8f2a3588c..4b45af6d18d 100644--- a/app/assets/javascripts/discourse/testem.js+++ b/app/assets/javascripts/discourse/testem.js@@ -68,8 +68,20 @@ module.exports = {reporter: Reporter,};-if (shouldLoadPluginTestJs()) {- const target = `http://localhost:${process.env.UNICORN_PORT || "3000"}`;+const target = `http://localhost:${process.env.UNICORN_PORT || "3000"}`;++if (process.argv.includes("-t")) {+ // Running testem without ember cli. Probably for theme-qunit+ const testPage = process.argv[process.argv.indexOf("-t") + 1];++ module.exports.proxies = {};+ module.exports.proxies[`/*/theme-qunit`] = {+ target: `${target}${testPage}`,+ ignorePath: true,+ };+ module.exports.proxies["/*/*"] = { target };+} else if (shouldLoadPluginTestJs()) {+ // Running with ember cli, but we want to pass through plugin request to Railsmodule.exports.proxies = {"/assets/discourse/tests/active-plugins.js": {target,diff --git a/app/views/qunit/theme.html.erb b/app/views/qunit/theme.html.erbindex 21595e84fcb..05b281ac7e6 100644--- a/app/views/qunit/theme.html.erb+++ b/app/views/qunit/theme.html.erb@@ -28,6 +28,9 @@}</style><%- end %>+ <%- if params['testem'] %>+ <script src="/testem.js"></script>+ <%- end %></head><body><%- if !@suggested_themes %>diff --git a/lib/tasks/qunit.rake b/lib/tasks/qunit.rakeindex be5f6654b53..35da5e3590a 100644--- a/lib/tasks/qunit.rake+++ b/lib/tasks/qunit.rake@@ -106,8 +106,16 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|puts "Rails server is warmed up"if ember_cli- cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]- cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path+ cmd = ["env", "UNICORN_PORT=#{unicorn_port}"]+ if qunit_path+ # Bypass `ember test` - it only works properly for the `/tests` path.+ # We have to trigger a `build` manually so that JS is available for rails to serve.+ system("yarn", "ember", "build", chdir: "#{Rails.root}/app/assets/javascripts/discourse")+ test_page = "#{qunit_path}?#{query}&testem=1"+ cmd += ["yarn", "testem", "ci", "-f", "testem.js", "-t", test_page]+ else+ cmd += ["yarn", "ember", "test", "--query", query]+ endsystem(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")elsecmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"