chore: 🤖 deprecate window object service (#1652)
* chore: 🤖 deprecate window object service Deprecate `browser-object` service in favor of `ember-browser-services` ✅ Closes: ICU-7152 * refactor: 💡 cluster-url test fail commit with cluster-url test failing ✅ Closes: ICU-7152 * refactor: 💡 refactor test to reflect changes Refactor test to reflect `browser/window` service in `cluster-url` route ✅ Closes: ICU-7152 * refactor: 💡 refactor cluster url test change logic of mockIPC to a function call ✅ Closes: ICU-7152
This commit is contained in:
1 parent
0a76111944
commit
3ba53dfc2e
8 files changed
+27
-104
No files matched your search
@@ -22,7 +22,7 @@ class Tag {
|
||||
export default class FormWorkerCreateWorkerLedComponent extends Component {
|
||||
// =services
|
||||
@service features;
|
||||
@service browserObject;
|
||||
@service('browser/window') window;
|
||||
|
||||
// =attributes
|
||||
@tracked generatedWorkerAuthToken;
|
||||
@@ -35,7 +35,7 @@ export default class FormWorkerCreateWorkerLedComponent extends Component {
|
||||
@tracked newWorkerValue;
|
||||
|
||||
get clusterIDFromURL() {
|
||||
const hostname = this.browserObject.hostname;
|
||||
const hostname = this.window?.location?.hostname;
|
||||
|
||||
// Match against a guid with either the prod, int, or dev hcp domain
|
||||
const clusterIDMatcher =
|
||||
|
||||
@@ -11,14 +11,14 @@ export default class OnboardingSuccessRoute extends Route {
|
||||
// =services
|
||||
@service router;
|
||||
@service session;
|
||||
@service browserObject;
|
||||
@service('browser/window') window;
|
||||
|
||||
// =methods
|
||||
model() {
|
||||
const model = this.modelFor('onboarding');
|
||||
return {
|
||||
...model,
|
||||
clusterUrl: this.browserObject.window.origin,
|
||||
clusterUrl: this.window.origin,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@ import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
import { v1 } from 'ember-uuid';
|
||||
import { setupIntl } from 'ember-intl/test-support';
|
||||
import { setupBrowserFakes } from 'ember-browser-services/test-support';
|
||||
|
||||
module(
|
||||
'Integration | Component | form/worker/create-worker-led',
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
setupBrowserFakes(hooks, { window: true });
|
||||
setupIntl(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
@@ -23,14 +25,13 @@ module(
|
||||
});
|
||||
|
||||
test('it correctly populates the cluster id for an hcp dev cluster', async function (assert) {
|
||||
const windowService = this.owner.lookup('service:browser/window');
|
||||
const guid = v1();
|
||||
this.model = {};
|
||||
this.submit = () => {};
|
||||
this.refresh = () => {};
|
||||
const service = { hostname: `${guid}.boundary.hcp.dev` };
|
||||
this.owner.register('service:browser-object', service, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
windowService.location.hostname = `${guid}.boundary.hcp.dev`;
|
||||
|
||||
await render(
|
||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
||||
@@ -40,14 +41,13 @@ module(
|
||||
});
|
||||
|
||||
test('it correctly populates the cluster id for an hcp int cluster', async function (assert) {
|
||||
const windowService = this.owner.lookup('service:browser/window');
|
||||
const guid = v1();
|
||||
this.model = {};
|
||||
this.submit = () => {};
|
||||
this.refresh = () => {};
|
||||
const service = { hostname: `${guid}.boundary.hcp.to` };
|
||||
this.owner.register('service:browser-object', service, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
windowService.location.hostname = `${guid}.boundary.hcp.to`;
|
||||
|
||||
await render(
|
||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
||||
@@ -57,14 +57,13 @@ module(
|
||||
});
|
||||
|
||||
test('it correctly populates the cluster id for an hcp prod cluster', async function (assert) {
|
||||
const windowService = this.owner.lookup('service:browser/window');
|
||||
const guid = v1();
|
||||
this.model = {};
|
||||
this.submit = () => {};
|
||||
this.refresh = () => {};
|
||||
const service = { hostname: `${guid}.boundary.hashicorp.cloud` };
|
||||
this.owner.register('service:browser-object', service, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
windowService.location.hostname = `${guid}.boundary.hashicorp.cloud`;
|
||||
|
||||
await render(
|
||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
||||
@@ -74,13 +73,12 @@ module(
|
||||
});
|
||||
|
||||
test('it leaves the cluster id as blank for any other url', async function (assert) {
|
||||
const windowService = this.owner.lookup('service:browser/window');
|
||||
this.model = {};
|
||||
this.submit = () => {};
|
||||
this.refresh = () => {};
|
||||
const service = { hostname: `personal.website.com` };
|
||||
this.owner.register('service:browser-object', service, {
|
||||
instantiate: false,
|
||||
});
|
||||
|
||||
windowService.location.hostname = `personal.website.com`;
|
||||
|
||||
await render(
|
||||
hbs`<Form::Worker::CreateWorkerLed @model={{this.model}} @submit={{this.submit}} @refresh={{this.refresh}} />`
|
||||
|
||||
Reference in new issue
Block a user