DEV: handle ember-cli test proxying for relative roots

Allow tests to be able to be found and run
when DISCOURSE_RELATIVE_ROOT is set.
This commit is contained in:
Jeff Wong 2022-12-01 16:33:56 -08:00
parent 8437081d94
commit f0c8bc9e4d

View File

@ -465,7 +465,7 @@ to serve API requests. For example:
app.use(rawMiddleware, async (req, res, next) => { app.use(rawMiddleware, async (req, res, next) => {
try { try {
if (this.shouldForwardRequest(req)) { if (this.shouldForwardRequest(req, baseURL)) {
await handleRequest(proxy, baseURL, req, res); await handleRequest(proxy, baseURL, req, res);
} else { } else {
// Fixes issues when using e.g. "localhost" instead of loopback IP address // Fixes issues when using e.g. "localhost" instead of loopback IP address
@ -486,13 +486,13 @@ to serve API requests. For example:
}); });
}, },
shouldForwardRequest(request) { shouldForwardRequest(request, baseURL) {
if ( if (
[ [
"/tests/index.html", `${baseURL}tests/index.html`,
"/ember-cli-live-reload.js", `${baseURL}ember-cli-live-reload.js`,
"/testem.js", `${baseURL}testem.js`,
"/assets/test-i18n.js", `${baseURL}assets/test-i18n.js`,
].includes(request.path) ].includes(request.path)
) { ) {
return false; return false;