A platform for community discussion. Free, open, simple.
DEV: Ensure ember-cli `rake theme:qunit` works with CSP enabled (#16541)
David Taylor794d2dabf6b2
diff --git a/app/assets/javascripts/discourse/testem.js b/app/assets/javascripts/discourse/testem.jsindex 4b45af6d18d..67261a0fb6d 100644--- a/app/assets/javascripts/discourse/testem.js+++ b/app/assets/javascripts/discourse/testem.js@@ -78,8 +78,20 @@ if (process.argv.includes("-t")) {module.exports.proxies[`/*/theme-qunit`] = {target: `${target}${testPage}`,ignorePath: true,+ xfwd: true,};- module.exports.proxies["/*/*"] = { target };+ module.exports.proxies["/*/*"] = { target, xfwd: true };++ module.exports.middleware = [+ function (app) {+ // Make the testem.js file available under /assets+ // so it's within the app's CSP+ app.get("/assets/testem.js", function (req, res, next) {+ req.url = "/testem.js";+ next();+ });+ },+ ];} else if (shouldLoadPluginTestJs()) {// Running with ember cli, but we want to pass through plugin request to Railsmodule.exports.proxies = {diff --git a/app/views/qunit/theme.html.erb b/app/views/qunit/theme.html.erbindex 05b281ac7e6..25ab0eff67a 100644--- a/app/views/qunit/theme.html.erb+++ b/app/views/qunit/theme.html.erb@@ -29,7 +29,7 @@</style><%- end %><%- if params['testem'] %>- <script src="/testem.js"></script>+ <script src="/assets/testem.js"></script><%- end %></head><body>