Skip to content

Modular logistics and supply chain operating system (LSOS)

refactor(console): use ember-window-mock instead of reload wrappers

Ronald A. Richardsone2a5afbdf904
diff --git a/console/app/components/impersonator-tray.js b/console/app/components/impersonator-tray.js
index 92e61138..bf39a9c7 100644
--- a/console/app/components/impersonator-tray.js
+++ b/console/app/components/impersonator-tray.js
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
+import window from 'ember-window-mock';
export default class ImpersonatorTrayComponent extends Component {
@service session;
@@ -27,19 +28,9 @@ export default class ImpersonatorTrayComponent extends Component {
// Handed back so the caller can cancel the pending reload. Without this the
// timer is unreachable once scheduled and always reloads the window.
- return later(this, this.reloadWindow, 600);
+ return later(() => window.location.reload(), 600);
} catch (error) {
this.notifications.serverError(error);
}
}
-
- /**
- * window.location.reload() cannot be stubbed — Location members are non-configurable
- * per spec — so it is isolated here and callers are tested by replacing this method.
- * Matches InstallationService, ConsoleController and the organizations controllers.
- */
- /* istanbul ignore next -- window.location.reload() cannot be stubbed */
- reloadWindow() {
- window.location.reload();
- }
}
diff --git a/console/app/controllers/console.js b/console/app/controllers/console.js
index 92504692..3c14a900 100644
--- a/console/app/controllers/console.js
+++ b/console/app/controllers/console.js
@@ -6,6 +6,7 @@ import { action } from '@ember/object';
import { isArray } from '@ember/array';
import { dasherize } from '@ember/string';
import first from '@fleetbase/ember-core/utils/first';
+import window from 'ember-window-mock';
export default class ConsoleController extends Controller {
@service currentUser;
@@ -86,7 +87,7 @@ export default class ConsoleController extends Controller {
return later(
this,
() => {
- this.reloadWindow();
+ window.location.reload();
},
900
);
@@ -110,7 +111,7 @@ export default class ConsoleController extends Controller {
return later(
this,
() => {
- this.reloadWindow();
+ window.location.reload();
},
900
);
@@ -147,7 +148,7 @@ export default class ConsoleController extends Controller {
return later(
this,
() => {
- this.reloadWindow();
+ window.location.reload();
},
900
);
@@ -159,15 +160,6 @@ export default class ConsoleController extends Controller {
});
}
- /* istanbul ignore next -- window.location.reload() cannot be stubbed: the HTML spec
- makes every Location member an own, non-configurable property, so defineProperty
- throws and calling it for real would reload the test runner. Extracted so the reload
- timers above can be tested by replacing this on the instance, mirroring
- InstallationService.reloadConsole(). */
- reloadWindow() {
- window.location.reload();
- }
-
@action viewChangelog() {
this.modalsManager.show('modals/changelog', {
title: this.intl.t('common.changelog'),
diff --git a/console/app/controllers/console/account/organizations.js b/console/app/controllers/console/account/organizations.js
index 4f3b2c30..da764bb8 100644
--- a/console/app/controllers/console/account/organizations.js
+++ b/console/app/controllers/console/account/organizations.js
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
import { htmlSafe } from '@ember/template';
+import window from 'ember-window-mock';
export default class ConsoleAccountOrganizationsController extends Controller {
@service currentUser;
@@ -91,7 +92,7 @@ export default class ConsoleAccountOrganizationsController extends Controller {
await this.fetch.post('auth/switch-organization', { next: organization.uuid });
this.fetch.flushRequestCache('auth/organizations');
this.notifications.success(this.intl.t('console.switch-organization.success-notification'));
- return later(this, this.reloadWindow, 900);
+ return later(() => window.location.reload(), 900);
} catch (error) {
modal.stopLoading();
return this.notifications.serverError(error);
@@ -194,14 +195,4 @@ export default class ConsoleAccountOrganizationsController extends Controller {
},
});
}
-
- /**
- * window.location.reload() cannot be stubbed — Location members are non-configurable
- * per spec — so it is isolated here and callers are tested by replacing this method.
- * Matches InstallationService, ConsoleController and the organizations controllers.
- */
- /* istanbul ignore next -- window.location.reload() cannot be stubbed */
- reloadWindow() {
- window.location.reload();
- }
}
diff --git a/console/app/controllers/console/admin/organizations/details.js b/console/app/controllers/console/admin/organizations/details.js
index ee03d73c..ea7f32d5 100644
--- a/console/app/controllers/console/admin/organizations/details.js
+++ b/console/app/controllers/console/admin/organizations/details.js
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
import { later } from '@ember/runloop';
import { isArray } from '@ember/array';
import { task } from 'ember-concurrency';
+import window from 'ember-window-mock';
export default class ConsoleAdminOrganizationsDetailsController extends Controller {
@service router;
@@ -234,20 +235,9 @@ export default class ConsoleAdminOrganizationsDetailsController extends Controll
yield this.router.transitionTo('console');
this.session.manuallyAuthenticate(token);
this.notifications.info(`Now impersonating ${this.ownerEmail || 'organization owner'}...`);
- later(this, this.reloadWindow, 600);
+ later(() => window.location.reload(), 600);
} catch (error) {
this.notifications.serverError(error);
}
}
-
- /**
- * Reloading the window is the last step of impersonation. Location members are
- * non-configurable per spec, so this cannot be stubbed — it is isolated here so callers
- * can be tested by replacing the method, matching InstallationService,
- * ConsoleAdminOrganizationsController and ConsoleController.
- */
- /* istanbul ignore next -- window.location.reload() cannot be stubbed */
- reloadWindow() {
- window.location.reload();
- }
}
diff --git a/console/app/controllers/console/admin/organizations/details/users.js b/console/app/controllers/console/admin/organizations/details/users.js
index 6cc7af8f..a22bf9e1 100644
--- a/console/app/controllers/console/admin/organizations/details/users.js
+++ b/console/app/controllers/console/admin/organizations/details/users.js
@@ -3,6 +3,7 @@ import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
+import window from 'ember-window-mock';
export default class ConsoleAdminOrganizationsDetailsUsersController extends Controller {
@service intl;
@@ -134,7 +135,7 @@ export default class ConsoleAdminOrganizationsDetailsUsersController extends Con
await this.router.transitionTo('console');
this.session.manuallyAuthenticate(token);
this.notifications.info(`Now impersonating ${user.email}...`);
- later(this, this.reloadWindow, 600);
+ later(() => window.location.reload(), 600);
} catch (error) {
this.notifications.serverError(error);
}
@@ -230,14 +231,4 @@ export default class ConsoleAdminOrganizationsDetailsUsersController extends Con
userIdentifier(user) {
return user?.uuid || user?.id;
}
-
- /**
- * window.location.reload() cannot be stubbed — Location members are non-configurable
- * per spec — so it is isolated here and callers are tested by replacing this method.
- * Matches InstallationService, ConsoleController and the organizations controllers.
- */
- /* istanbul ignore next -- window.location.reload() cannot be stubbed */
- reloadWindow() {
- window.location.reload();
- }
}
diff --git a/console/app/controllers/console/admin/organizations/index.js b/console/app/controllers/console/admin/organizations/index.js
index ca9a769a..913e274c 100644
--- a/console/app/controllers/console/admin/organizations/index.js
+++ b/console/app/controllers/console/admin/organizations/index.js
@@ -2,6 +2,7 @@ import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
+import window from 'ember-window-mock';
/**
* Controller for managing organizations in the admin console.
@@ -311,21 +312,12 @@ export default class ConsoleAdminOrganizationsController extends Controller {
await this.router.transitionTo('console');
this.session.manuallyAuthenticate(token);
this.notifications.info(`Now impersonating ${owner?.email || 'organization owner'}...`);
- this.reloadWindow();
+ window.location.reload();
} catch (error) {
this.notifications.serverError(error);
}
}
- /* istanbul ignore next -- window.location.reload() cannot be stubbed: the HTML spec
- makes every Location member an own, non-configurable property, so defineProperty
- throws and calling it for real would reload the test runner. Extracted so callers can
- be tested by replacing reloadWindow() on the instance, mirroring
- InstallationService.reloadConsole(). */
- reloadWindow() {
- window.location.reload();
- }
-
resolveBelongsTo(record) {
if (!record) {
return null;
diff --git a/console/app/controllers/console/admin/organizations/index/users.js b/console/app/controllers/console/admin/organizations/index/users.js
index 1280fdbc..e047a0e8 100644
--- a/console/app/controllers/console/admin/organizations/index/users.js
+++ b/console/app/controllers/console/admin/organizations/index/users.js
@@ -3,6 +3,7 @@ import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { later } from '@ember/runloop';
+import window from 'ember-window-mock';
export default class ConsoleAdminOrganizationsIndexUsersController extends Controller {
@service filters;
@@ -133,7 +134,7 @@ export default class ConsoleAdminOrganizationsIndexUsersController extends Contr
// Handed back so the caller can cancel the pending reload; the same timer on
// ImpersonatorTray was unreachable once scheduled.
- return later(this, this.reloadWindow, 600);
+ return later(() => window.location.reload(), 600);
} catch (error) {
this.notifications.serverError(error);
}
@@ -185,14 +186,4 @@ export default class ConsoleAdminOrganizationsIndexUsersController extends Contr
return this.router.transitionTo('console.admin.organizations.index');
}
-
- /**
- * window.location.reload() cannot be stubbed — Location members are non-configurable
- * per spec — so it is isolated here and callers are tested by replacing this method.
- * Matches InstallationService, ConsoleController and the organizations controllers.
- */
- /* istanbul ignore next -- window.location.reload() cannot be stubbed */
- reloadWindow() {
- window.location.reload();
- }
}
diff --git a/console/app/services/installation.js b/console/app/services/installation.js
index 5588d4cd..39d7873b 100644
--- a/console/app/services/installation.js
+++ b/console/app/services/installation.js
@@ -2,6 +2,7 @@ import Service from '@ember/service';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { later, cancel } from '@ember/runloop';
+import window from 'ember-window-mock';
const NOT_CONFIGURED_ERROR = 'fleetbase_not_configured';
const INSTALL_CHANNEL = 'fleetbase.install';
@@ -159,15 +160,6 @@ export default class InstallationService extends Service {
}
this.isRefreshing = true;
- this.reloadConsole();
- }
-
- /* istanbul ignore next -- window.location.reload() cannot be stubbed: the HTML spec
- marks every Location member as an own, non-configurable property, so defineProperty
- throws and calling it for real would reload the test runner. This wrapper exists
- precisely so callers can be tested by replacing reloadConsole() on the instance,
- which the handleInstallCompleteEvent tests do. */
- reloadConsole() {
window.location.reload();
}
diff --git a/console/package.json b/console/package.json
index af735b9d..b123bb63 100644
--- a/console/package.json
+++ b/console/package.json
@@ -120,6 +120,7 @@
"ember-responsive": "^5.0.0",
"ember-source": "~5.4.1",
"ember-template-lint": "^5.13.0",
+ "ember-window-mock": "^0.9.0",
"ember-wormhole": "^0.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
diff --git a/console/tests/helpers/index.js b/console/tests/helpers/index.js
index 5add2c00..f3f1b3fd 100644
--- a/console/tests/helpers/index.js
+++ b/console/tests/helpers/index.js
@@ -1,5 +1,6 @@
import { setupApplicationTest as upstreamSetupApplicationTest, setupRenderingTest as upstreamSetupRenderingTest, setupTest as upstreamSetupTest } from 'ember-qunit';
import { _resetStorages } from 'ember-local-storage/helpers/storage';
+import { setupWindowMock } from 'ember-window-mock/test-support';
// This file exists to provide wrappers around ember-qunit's
// test setup functions. This way, you can easily extend the setup that is
@@ -25,9 +26,17 @@ function setupLocalStorageIsolation(hooks) {
});
}
+/**
+ * App code imports `window` from ember-window-mock, which outside tests is the raw global
+ * and inside them is a proxy. That proxy passes straight through to the real window until
+ * setupWindowMock() installs the mocking handler — so without this, window.location.reload()
+ * would reload the test runner. It is applied to every test type rather than per module so
+ * no caller has to remember. The handler is reset after each test.
+ */
function setupApplicationTest(hooks, options) {
upstreamSetupApplicationTest(hooks, options);
setupLocalStorageIsolation(hooks);
+ setupWindowMock(hooks);
// Additional setup for application tests can be done here.
//
@@ -48,6 +57,7 @@ function setupApplicationTest(hooks, options) {
function setupRenderingTest(hooks, options) {
upstreamSetupRenderingTest(hooks, options);
setupLocalStorageIsolation(hooks);
+ setupWindowMock(hooks);
// Additional setup for rendering tests can be done here.
}
@@ -55,6 +65,7 @@ function setupRenderingTest(hooks, options) {
function setupTest(hooks, options) {
upstreamSetupTest(hooks, options);
setupLocalStorageIsolation(hooks);
+ setupWindowMock(hooks);
// Additional setup for unit tests can be done here.
}
diff --git a/console/tests/integration/components/impersonator-tray-test.js b/console/tests/integration/components/impersonator-tray-test.js
index b58689a0..109d3a08 100644
--- a/console/tests/integration/components/impersonator-tray-test.js
+++ b/console/tests/integration/components/impersonator-tray-test.js
@@ -6,6 +6,7 @@ import Service from '@ember/service';
import { cancel } from '@ember/runloop';
import ImpersonatorTrayComponent from '@fleetbase/console/components/impersonator-tray';
import { captureComponent } from '@fleetbase/console/tests/helpers/capture-component';
+import window from 'ember-window-mock';
function registerSession(owner, authenticated) {
class SessionStub extends Service {
@@ -186,7 +187,7 @@ module('Integration | Component | impersonator-tray | reload', function (hooks)
Object.defineProperty(component.router, 'transitionTo', { configurable: true, value: () => Promise.resolve() });
this.reloads = 0;
- Object.defineProperty(component, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
return component;
};
diff --git a/console/tests/integration/components/onboarding/verify-email-test.js b/console/tests/integration/components/onboarding/verify-email-test.js
index 03b84a1a..71639fb3 100644
--- a/console/tests/integration/components/onboarding/verify-email-test.js
+++ b/console/tests/integration/components/onboarding/verify-email-test.js
@@ -17,7 +17,7 @@ module('Integration | Component | onboarding/verify-email', function (hooks) {
const started = [];
- // The real user-verification service schedules a 75s `later` in start(), which
+ // The real onboarding-verification service schedules a 75s `later` in start(), which
// would keep settled() waiting for the whole timeout. The template also binds
// several of its members directly, so the stub has to provide them all.
class VerificationStub extends Service {
@@ -39,7 +39,7 @@ module('Integration | Component | onboarding/verify-email', function (hooks) {
}
}
- this.owner.register('service:user-verification', VerificationStub);
+ this.owner.register('service:onboarding-verification', VerificationStub);
this.owner.register('service:url-search-params', UrlSearchParamsStub);
this.started = started;
});
@@ -113,7 +113,7 @@ module('Integration | Component | onboarding/verify-email | verify', function (h
this.serverErrors.push(error);
}
}
- this.owner.register('service:user-verification', VerificationStub);
+ this.owner.register('service:onboarding-verification', VerificationStub);
this.owner.register('service:url-search-params', UrlSearchParamsStub);
this.owner.register('service:fetch', FetchStub);
this.owner.register('service:notifications', NotificationsStub);
diff --git a/console/tests/unit/controllers/console-test.js b/console/tests/unit/controllers/console-test.js
index 497097ef..7fc28be6 100644
--- a/console/tests/unit/controllers/console-test.js
+++ b/console/tests/unit/controllers/console-test.js
@@ -3,6 +3,7 @@ import { setupTest } from '@fleetbase/console/tests/helpers';
import { settled } from '@ember/test-helpers';
import Service from '@ember/service';
import { cancel } from '@ember/runloop';
+import window from 'ember-window-mock';
class IntlStub extends Service {
t(key) {
@@ -297,7 +298,7 @@ module('Unit | Controller | console | reload timers and defaults', function (hoo
this.build = () => {
const controller = this.owner.lookup('controller:console');
this.reloads = 0;
- Object.defineProperty(controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
return controller;
};
this.modals = () => this.owner.lookup('service:modals-manager');
diff --git a/console/tests/unit/controllers/console/account/organizations-test.js b/console/tests/unit/controllers/console/account/organizations-test.js
index bac4c747..fe149207 100644
--- a/console/tests/unit/controllers/console/account/organizations-test.js
+++ b/console/tests/unit/controllers/console/account/organizations-test.js
@@ -3,6 +3,7 @@ import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
import { cancel } from '@ember/runloop';
import { settled } from '@ember/test-helpers';
+import window from 'ember-window-mock';
// Captures whatever the controller hands to the modals manager so the modal's
// `confirm` callback can be driven directly.
@@ -457,7 +458,7 @@ module('Unit | Controller | console/account/organizations | reload and stale cou
this.controller.router.refresh = () => this.refreshed++;
this.reloads = 0;
- Object.defineProperty(this.controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
});
test('switching organizations reloads the console once the timer fires', async function (assert) {
diff --git a/console/tests/unit/controllers/console/admin-test.js b/console/tests/unit/controllers/console/admin-test.js
index 1e34083f..1e62ab37 100644
--- a/console/tests/unit/controllers/console/admin-test.js
+++ b/console/tests/unit/controllers/console/admin-test.js
@@ -1,6 +1,7 @@
import { module, test } from 'qunit';
import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
+import window from 'ember-window-mock';
const ADMIN_MENU_ITEMS = [
{
@@ -164,11 +165,15 @@ module('Unit | Controller | console/admin', function (hooks) {
const navigatorAppItem = controller.navigationItems[7].children[0];
const mapItem = controller.navigationItems[7].children[1];
- // activeWhen delegates to isMenuItemActive, which reads window.location.pathname and
- // (via getUrlParam) window.location.search off the real global window. replaceState
- // rewrites both synchronously without navigating the test iframe.
- const originalUrl = window.location.href;
- const visit = (url) => window.history.replaceState(null, '', url);
+ // activeWhen delegates to ember-ui's isMenuItemActive, which reads location.pathname
+ // through ember-window-mock — but its collaborator getUrlParam has no such import and
+ // reads location.search off the real global window. The two therefore disagree unless
+ // both are pointed at the URL under test, so this sets each of them.
+ const originalUrl = globalThis.location.href;
+ const visit = (url) => {
+ window.location.href = url;
+ globalThis.history.replaceState(null, '', url);
+ };
try {
visit('/admin/fleet-ops?view=navigator-app');
@@ -182,7 +187,7 @@ module('Unit | Controller | console/admin', function (hooks) {
assert.true(rootRegistryItem.activeWhen(), 'loose registry item is active for /admin/<slug>');
assert.false(navigatorAppItem.activeWhen(), 'panel child is not active for loose registry URL');
} finally {
- window.history.replaceState(null, '', originalUrl);
+ globalThis.history.replaceState(null, '', originalUrl);
}
});
diff --git a/console/tests/unit/controllers/console/admin/organizations/details-test.js b/console/tests/unit/controllers/console/admin/organizations/details-test.js
index 3fe885fd..7dcb251e 100644
--- a/console/tests/unit/controllers/console/admin/organizations/details-test.js
+++ b/console/tests/unit/controllers/console/admin/organizations/details-test.js
@@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
import { settled } from '@ember/test-helpers';
+import window from 'ember-window-mock';
class NotificationsStub extends Service {
successes = [];
@@ -497,9 +498,8 @@ module('Unit | Controller | console/admin/organizations/details | registry fallb
});
/**
- * The impersonation success path ends in a window reload, which is isolated behind
- * reloadWindow() precisely so it can be replaced here — Location members are
- * non-configurable, so the real call can never be stubbed.
+ * The impersonation success path ends in a window reload. ember-window-mock makes that a
+ * no-op in tests and lets the call be spied on, so the whole path can be driven.
*/
module('Unit | Controller | console/admin/organizations/details | impersonation', function (hooks) {
setupTest(hooks);
@@ -541,7 +541,7 @@ module('Unit | Controller | console/admin/organizations/details | impersonation'
});
this.reloads = 0;
- Object.defineProperty(this.controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
});
test('impersonating an owner authenticates as them and reloads the console', async function (assert) {
diff --git a/console/tests/unit/controllers/console/admin/organizations/details/users-test.js b/console/tests/unit/controllers/console/admin/organizations/details/users-test.js
index 00383118..3c4c33b2 100644
--- a/console/tests/unit/controllers/console/admin/organizations/details/users-test.js
+++ b/console/tests/unit/controllers/console/admin/organizations/details/users-test.js
@@ -2,6 +2,7 @@ import { module, test } from 'qunit';
import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
import { settled } from '@ember/test-helpers';
+import window from 'ember-window-mock';
class IntlStub extends Service {
t(key) {
@@ -299,7 +300,7 @@ module('Unit | Controller | console/admin/organizations/details/users | imperson
Object.defineProperty(this.controller.router, 'transitionTo', { configurable: true, value: () => Promise.resolve() });
this.reloads = 0;
- Object.defineProperty(this.controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
});
test('impersonating a user swaps the session and reloads once the timer fires', async function (assert) {
diff --git a/console/tests/unit/controllers/console/admin/organizations/index-test.js b/console/tests/unit/controllers/console/admin/organizations/index-test.js
index e9d0b7d2..13be7ce5 100644
--- a/console/tests/unit/controllers/console/admin/organizations/index-test.js
+++ b/console/tests/unit/controllers/console/admin/organizations/index-test.js
@@ -1,6 +1,7 @@
import { module, test } from 'qunit';
import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
+import window from 'ember-window-mock';
class IntlStub extends Service {
t(key) {
@@ -338,7 +339,7 @@ module('Unit | Controller | console/admin/organizations/index | actions', functi
},
});
this.reloads = 0;
- Object.defineProperty(controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
return controller;
};
this.notifications = () => this.owner.lookup('service:notifications');
diff --git a/console/tests/unit/controllers/console/admin/organizations/index/users-test.js b/console/tests/unit/controllers/console/admin/organizations/index/users-test.js
index 7169bc15..1b24822b 100644
--- a/console/tests/unit/controllers/console/admin/organizations/index/users-test.js
+++ b/console/tests/unit/controllers/console/admin/organizations/index/users-test.js
@@ -3,6 +3,7 @@ import { setupTest } from '@fleetbase/console/tests/helpers';
import Service from '@ember/service';
import { settled } from '@ember/test-helpers';
import { cancel } from '@ember/runloop';
+import window from 'ember-window-mock';
module('Unit | Controller | console/admin/organizations/index/users', function (hooks) {
setupTest(hooks);
@@ -236,7 +237,7 @@ module('Unit | Controller | console/admin/organizations/index/users | impersonat
Object.defineProperty(this.controller.router, 'transitionTo', { configurable: true, value: () => Promise.resolve() });
this.reloads = 0;
- Object.defineProperty(this.controller, 'reloadWindow', { configurable: true, value: () => this.reloads++ });
+ window.location.reload = () => this.reloads++;
});
test('impersonating a user swaps the session and hands back a cancellable reload', async function (assert) {
diff --git a/console/tests/unit/services/installation-test.js b/console/tests/unit/services/installation-test.js
index 3352a00e..ea495cac 100644
--- a/console/tests/unit/services/installation-test.js
+++ b/console/tests/unit/services/installation-test.js
@@ -3,6 +3,7 @@ import Service from '@ember/service';
import { setupTest } from '@fleetbase/console/tests/helpers';
import { settled } from '@ember/test-helpers';
import { later } from '@ember/runloop';
+import window from 'ember-window-mock';
/**
* Builds a socket service whose channel yields the given payloads to the service's
@@ -255,7 +256,7 @@ module('Unit | Service | installation', function (hooks) {
const service = this.owner.lookup('service:installation');
let reloadCount = 0;
- service.reloadConsole = () => {
+ window.location.reload = () => {
reloadCount++;
};
@@ -402,7 +403,7 @@ module('Unit | Service | installation', function (hooks) {
const service = this.owner.lookup('service:installation');
let reloads = 0;
- service.reloadConsole = () => reloads++;
+ window.location.reload = () => reloads++;
await service.listenForInstallComplete();