From 4dda7ee3ba38a2dc3e2465496380141e0df348a6 Mon Sep 17 00:00:00 2001 From: Zhihe Li Date: Wed, 12 Oct 2022 11:44:10 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Update=20how=20we=20?= =?UTF-8?q?use=20ENABLE=5FMIRAGE=20to=20be=20consistent=20(#1362)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: ICU-6038 --- addons/api/mirage/config.js | 5 ----- addons/api/mirage/scenarios/ipc.js | 4 ++-- ui/admin/config/environment.js | 4 ++++ ui/desktop/config/environment.js | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index 24818894c..d8b1cd2b9 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -18,11 +18,6 @@ export default function () { // delay for each request, automatically set to 0 during testing this.timing = 1; - // Allow any configured API host to passthrough, which is useful in - // development for testing against a locally running backend. - if (config.api.host) this.passthrough(`${config.api.host}/**`); - this.passthrough(); - // Scope resources this.get( diff --git a/addons/api/mirage/scenarios/ipc.js b/addons/api/mirage/scenarios/ipc.js index 929e4ec0f..7cbe8604a 100644 --- a/addons/api/mirage/scenarios/ipc.js +++ b/addons/api/mirage/scenarios/ipc.js @@ -147,9 +147,9 @@ export default function initializeMockIPC(server, config) { * main process, and routes messages to it in a way similar to our * preload.js script. * - * Initializes mock IPC only in a non-Electron non-testing context. + * Initializes mock IPC only in a non-testing context and when mirage is turned on. */ - if (!config.isElectron && !isTesting) { + if (config['ember-cli-mirage'].enabled && !isTesting) { const mockIPC = new MockIPC(); window.addEventListener('message', async function (event) { if (event.origin !== window.location.origin) return; diff --git a/ui/admin/config/environment.js b/ui/admin/config/environment.js index 9d0ee271e..e61a5a9e1 100644 --- a/ui/admin/config/environment.js +++ b/ui/admin/config/environment.js @@ -123,6 +123,10 @@ module.exports = function (environment) { // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; // ENV.APP.LOG_VIEW_LOOKUPS = true; + ENV['ember-cli-mirage'].enabled = process.env.ENABLE_MIRAGE + ? JSON.parse(process.env.ENABLE_MIRAGE) + : true; + ENV['ember-a11y-testing'] = { componentOptions: { axeOptions: { diff --git a/ui/desktop/config/environment.js b/ui/desktop/config/environment.js index 5c5efaa8a..c66514bd1 100644 --- a/ui/desktop/config/environment.js +++ b/ui/desktop/config/environment.js @@ -63,10 +63,6 @@ module.exports = function (environment) { }, }; - if (process.env.ENABLE_MIRAGE) { - ENV['ember-cli-mirage'].enabled = JSON.parse(process.env.ENABLE_MIRAGE); - } - if (environment === 'development') { // ENV.APP.LOG_RESOLVER = true; // ENV.APP.LOG_ACTIVE_GENERATION = true; @@ -79,6 +75,10 @@ module.exports = function (environment) { // usually the same as the application origin. ENV.autoOrigin = true; + ENV['ember-cli-mirage'].enabled = process.env.ENABLE_MIRAGE + ? JSON.parse(process.env.ENABLE_MIRAGE) + : true; + // Enable features in development }