diff --git a/addons/api/addon/adapters/application.js b/addons/api/addon/adapters/application.js index 12112ed67..04a9ebe6f 100644 --- a/addons/api/addon/adapters/application.js +++ b/addons/api/addon/adapters/application.js @@ -2,7 +2,7 @@ import RESTAdapter from '@ember-data/adapter/rest'; import { serializeIntoHash } from '@ember-data/adapter/-private'; /* eslint-disable-next-line ember/no-mixins */ import AdapterBuildURLMixin from '../mixins/adapter-build-url'; -import config from 'ember-get-config'; +import { getOwner } from '@ember/application'; import { get } from '@ember/object'; import { InvalidError } from '@ember-data/adapter/error'; import { dasherize } from '@ember/string'; @@ -44,19 +44,36 @@ export default class ApplicationAdapter extends RESTAdapter.extend( ) { // =attributes + #host; + #namespace; + /** * Sets host to the `api.host` string in the application's config, * if set. * @type {string} */ - host = get(config, 'api.host'); + get host() { + const config = getOwner(this).resolveRegistration('config:environment'); + return this.#host || get(config, 'api.host'); + } + set host(value) { + // Setting this value is useful for testing purposes. + this.#host = value; + } /** * Sets namespace to the `api.namespace` string in the application's config, * if set. * @type {string} */ - namespace = get(config, 'api.namespace'); + get namespace() { + const config = getOwner(this).resolveRegistration('config:environment'); + return this.#namespace || get(config, 'api.namespace'); + } + set namespace(value) { + // Setting this value is useful for testing purposes. + this.#namespace = value; + } // =methods diff --git a/addons/api/mirage/config.js b/addons/api/mirage/config.js index a7523ad69..89e2a82b5 100644 --- a/addons/api/mirage/config.js +++ b/addons/api/mirage/config.js @@ -8,7 +8,7 @@ import makeBooleanFilter from './helpers/bexpr-filter'; const isTesting = config.environment === 'test'; export default function () { - initializeMockIPC(this); + initializeMockIPC(this, config); // make this `http://localhost:8080`, for example, if your API is on a different server // this.urlPrefix = ''; diff --git a/addons/api/mirage/scenarios/ipc.js b/addons/api/mirage/scenarios/ipc.js index 0c01a656e..dd39c931e 100644 --- a/addons/api/mirage/scenarios/ipc.js +++ b/addons/api/mirage/scenarios/ipc.js @@ -1,9 +1,8 @@ -import config from 'ember-get-config'; import { datatype } from 'faker'; -const isTesting = config.environment === 'test'; +export default function initializeMockIPC(server, config) { + const isTesting = config.environment === 'test'; -export default function initializeMockIPC(server) { /** * We strive to make this application runnable in a regular web browser, since * it is a convenient environment for development and testing. But only an diff --git a/addons/api/package.json b/addons/api/package.json index 2fcc5ae78..2556cfe95 100644 --- a/addons/api/package.json +++ b/addons/api/package.json @@ -51,7 +51,6 @@ "ember-copy": "^2.0.1", "ember-disable-prototype-extensions": "^1.1.3", "ember-export-application-global": "^2.0.1", - "ember-get-config": "^0.3.0", "ember-load-initializers": "^2.1.2", "ember-maybe-import-regenerator": "^1.0.0", "ember-page-title": "^6.2.2", diff --git a/addons/api/tests/unit/adapters/application-test.js b/addons/api/tests/unit/adapters/application-test.js index a2d8d9b0e..f06e308c0 100644 --- a/addons/api/tests/unit/adapters/application-test.js +++ b/addons/api/tests/unit/adapters/application-test.js @@ -1,6 +1,5 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import config from 'ember-get-config'; import RESTAdapter from '@ember-data/adapter/rest'; import { InvalidError } from '@ember-data/adapter/error'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; @@ -10,6 +9,12 @@ module('Unit | Adapter | application', function (hooks) { setupTest(hooks); setupMirage(hooks); + let config; + + hooks.beforeEach(function () { + config = this.owner.resolveRegistration('config:environment'); + }); + test('its namespace is equal to the configured namespace', function (assert) { assert.expect(2); const adapter = this.owner.lookup('adapter:application'); diff --git a/addons/core/addon/helpers/app-name.js b/addons/core/addon/helpers/app-name.js index a45e86cc6..69c73c730 100644 --- a/addons/core/addon/helpers/app-name.js +++ b/addons/core/addon/helpers/app-name.js @@ -1,6 +1,9 @@ -import { helper } from '@ember/component/helper'; -import config from 'ember-get-config'; +import Helper from '@ember/component/helper'; +import { getOwner } from '@ember/application'; -export default helper(function appName() { - return config.appName; -}); +export default class extends Helper { + compute() { + const config = getOwner(this).resolveRegistration('config:environment'); + return config.appName; + } +} diff --git a/addons/core/addon/helpers/company-copyright.js b/addons/core/addon/helpers/company-copyright.js index 26154cf22..cccf95d46 100644 --- a/addons/core/addon/helpers/company-copyright.js +++ b/addons/core/addon/helpers/company-copyright.js @@ -1,7 +1,10 @@ -import { helper } from '@ember/component/helper'; -import config from 'ember-get-config'; +import Helper from '@ember/component/helper'; +import { getOwner } from '@ember/application'; -export default helper(function companyCopyright() { - const currentYear = new Date().getFullYear(); - return `© ${currentYear} ${config.companyName}`; -}); +export default class extends Helper { + compute() { + const config = getOwner(this).resolveRegistration('config:environment'); + const currentYear = new Date().getFullYear(); + return `© ${currentYear} ${config.companyName}`; + } +} diff --git a/addons/core/addon/helpers/company-name.js b/addons/core/addon/helpers/company-name.js index 8fda6bc78..4aa13af1e 100644 --- a/addons/core/addon/helpers/company-name.js +++ b/addons/core/addon/helpers/company-name.js @@ -1,6 +1,9 @@ -import { helper } from '@ember/component/helper'; -import config from 'ember-get-config'; +import Helper from '@ember/component/helper'; +import { getOwner } from '@ember/application'; -export default helper(function companyName() { - return config.companyName; -}); +export default class extends Helper { + compute() { + const config = getOwner(this).resolveRegistration('config:environment'); + return config.companyName; + } +} diff --git a/addons/core/addon/helpers/doc-url.js b/addons/core/addon/helpers/doc-url.js index 563b67a44..b09c96165 100644 --- a/addons/core/addon/helpers/doc-url.js +++ b/addons/core/addon/helpers/doc-url.js @@ -1,20 +1,23 @@ -import { helper } from '@ember/component/helper'; +import Helper from '@ember/component/helper'; +import { getOwner } from '@ember/application'; import { assert } from '@ember/debug'; -import config from 'ember-get-config'; -export default helper(function docUrl(params /*, hash*/) { - const baseURL = config.documentation.baseURL; - const docKey = params[0] || ''; - const configuredPath = config.documentation.topics[docKey]; - if (docKey) { - assert( - ` - Documentation for "${docKey}" could not be found. Please ensure that - this key exists under "documentation" in your app config. - `, - configuredPath - ); +export default class extends Helper { + compute(params) { + const config = getOwner(this).resolveRegistration('config:environment'); + const baseURL = config.documentation.baseURL; + const docKey = params[0] || ''; + const configuredPath = config.documentation.topics[docKey]; + if (docKey) { + assert( + ` + Documentation for "${docKey}" could not be found. Please ensure that + this key exists under "documentation" in your app config. + `, + configuredPath + ); + } + const path = configuredPath || ''; + return `${baseURL}${path}`; } - const path = configuredPath || ''; - return `${baseURL}${path}`; -}); +} diff --git a/addons/core/addon/initializers/deprecations.js b/addons/core/addon/initializers/deprecations.js index c955b7e4b..3baf1a60b 100644 --- a/addons/core/addon/initializers/deprecations.js +++ b/addons/core/addon/initializers/deprecations.js @@ -1,9 +1,8 @@ import { registerDeprecationHandler } from '@ember/debug'; -import config from 'ember-get-config'; -const isTesting = config.environment === 'test'; - -export function initialize(/* application */) { +export function initialize(application) { + const config = application.resolveRegistration('config:environment'); + const isTesting = config.environment === 'test'; if (isTesting) { // Disable all deprecations for now in tests. registerDeprecationHandler((/*message, options, next*/) => { diff --git a/addons/core/addon/services/confirm.js b/addons/core/addon/services/confirm.js index e63a76fdf..9d2413da9 100644 --- a/addons/core/addon/services/confirm.js +++ b/addons/core/addon/services/confirm.js @@ -3,7 +3,7 @@ import { filterBy } from '@ember/object/computed'; import { A } from '@ember/array'; import { tracked } from '@glimmer/tracking'; import { defer, resolve } from 'rsvp'; -import config from 'ember-get-config'; +import { getOwner } from '@ember/application'; /** * A simple service that emits Confirmation instances and @@ -17,13 +17,21 @@ import config from 'ember-get-config'; export default class ConfirmationsService extends Service { // =attributes + #enabled; + /** * When the confirm service is disabled, it always returns resolving promises. * By default the service is enabled but it is useful to disable it for test * purposes. * @type {boolean} */ - enabled = config.enableConfirmService ?? true; + get enabled() { + const config = getOwner(this).resolveRegistration('config:environment'); + return this.#enabled ?? config.enableConfirmService ?? true; + } + set enabled(value) { + this.#enabled = value; + } /** * @type {Array} diff --git a/addons/core/package.json b/addons/core/package.json index c12f03dcd..b51acc24b 100644 --- a/addons/core/package.json +++ b/addons/core/package.json @@ -34,7 +34,6 @@ "ember-cli-babel": "^7.26.6", "ember-cli-htmlbars": "^5.7.1", "ember-feature-flags": "^6.0.0", - "ember-get-config": "^0.3.0", "ember-intl": "^5.7.0", "ember-loading": "^0.4.0", "ember-route-action-helper": "^2.0.8", diff --git a/addons/core/tests/integration/helpers/doc-url-test.js b/addons/core/tests/integration/helpers/doc-url-test.js index 26d017095..6267c73e6 100644 --- a/addons/core/tests/integration/helpers/doc-url-test.js +++ b/addons/core/tests/integration/helpers/doc-url-test.js @@ -2,13 +2,13 @@ import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -import config from 'ember-get-config'; module('Integration | Helper | doc-url', function (hooks) { setupRenderingTest(hooks); test('it renders a URL generated from the documentation config', async function (assert) { assert.expect(3); + const config = this.owner.resolveRegistration('config:environment'); const baseURL = config.documentation.baseURL; const path = config.documentation.topics.account; await render(hbs`{{doc-url 'account'}}`); @@ -19,7 +19,8 @@ module('Integration | Helper | doc-url', function (hooks) { test('it throws an error if the specified documentation path cannot be found', async function (assert) { assert.expect(2); - const helper = this.owner.lookup('helper:doc-url'); + const Helper = this.owner.lookup('helper:doc-url'); + const helper = new Helper(this.owner); assert.ok(helper.compute(['account']), 'Specified document exists.'); assert.throws(() => { helper.compute(['no.such.doc']); diff --git a/addons/rose/addon/components/rose/link-button/index.hbs b/addons/rose/addon/components/rose/link-button/index.hbs index c7cc9b387..b7311e3eb 100644 --- a/addons/rose/addon/components/rose/link-button/index.hbs +++ b/addons/rose/addon/components/rose/link-button/index.hbs @@ -1,8 +1,6 @@ {{#if @iconLeft}} diff --git a/addons/rose/package.json b/addons/rose/package.json index 84e823e4d..27dd6680e 100644 --- a/addons/rose/package.json +++ b/addons/rose/package.json @@ -38,7 +38,6 @@ "emberx-select": "github:adopted-ember-addons/emberx-select#bc5f774" }, "devDependencies": { - "ember-get-config": "^0.3.0", "@babel/core": "^7.15.5", "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.4.2", diff --git a/addons/rose/tests/dummy/app/initializers/deprecations.js b/addons/rose/tests/dummy/app/initializers/deprecations.js index c955b7e4b..3baf1a60b 100644 --- a/addons/rose/tests/dummy/app/initializers/deprecations.js +++ b/addons/rose/tests/dummy/app/initializers/deprecations.js @@ -1,9 +1,8 @@ import { registerDeprecationHandler } from '@ember/debug'; -import config from 'ember-get-config'; -const isTesting = config.environment === 'test'; - -export function initialize(/* application */) { +export function initialize(application) { + const config = application.resolveRegistration('config:environment'); + const isTesting = config.environment === 'test'; if (isTesting) { // Disable all deprecations for now in tests. registerDeprecationHandler((/*message, options, next*/) => { diff --git a/ui/admin/tests/acceptance/accounts/create-test.js b/ui/admin/tests/acceptance/accounts/create-test.js index e852a5b64..e019df150 100644 --- a/ui/admin/tests/acceptance/accounts/create-test.js +++ b/ui/admin/tests/acceptance/accounts/create-test.js @@ -94,25 +94,25 @@ module('Acceptance | accounts | create', function (hooks) { test('Users can navigate to new account route with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.authMethod); + await visit(urls.accounts); assert.ok( instances.authMethod.authorized_collection_actions.accounts.includes( 'create' ) ); - assert.ok(find(`[href="${urls.accounts}"]`)); + assert.ok(find(`[href="${urls.newAccount}"]`)); }); test('Users cannot navigate to new account route without proper authorization', async function (assert) { assert.expect(2); instances.authMethod.authorized_collection_actions.accounts = []; - await visit(urls.authMethod); + await visit(urls.accounts); assert.notOk( instances.authMethod.authorized_collection_actions.accounts.includes( 'create' ) ); - assert.notOk(find(`[href="${urls.accounts}"]`)); + assert.notOk(find(`[href="${urls.newAccount}"]`)); }); test('can cancel a new account creation', async function (assert) { diff --git a/ui/admin/tests/acceptance/auth-methods/create-test.js b/ui/admin/tests/acceptance/auth-methods/create-test.js index 684984999..62ee0638e 100644 --- a/ui/admin/tests/acceptance/auth-methods/create-test.js +++ b/ui/admin/tests/acceptance/auth-methods/create-test.js @@ -75,25 +75,25 @@ module('Acceptance | auth-methods | create ', function (hooks) { 'create', 'list', ]; - await visit(urls.orgScope); + await visit(urls.authMethods); assert.ok( instances.orgScope.authorized_collection_actions['auth-methods'].includes( 'create' ) ); - assert.ok(find(`[href="${urls.authMethods}"]`)); + assert.ok(find(`[href="${urls.newAuthMethod}"]`)); }); test('Users cannot navigate to new auth-methods route without proper authorization', async function (assert) { assert.expect(2); instances.orgScope.authorized_collection_actions['auth-methods'] = []; - await visit(urls.orgScope); + await visit(urls.authMethods); assert.notOk( instances.orgScope.authorized_collection_actions['auth-methods'].includes( 'create' ) ); - assert.notOk(find(`[href="${urls.authMethods}"]`)); + assert.notOk(find(`[href="${urls.newAuthMethod}"]`)); }); test('can cancel new auth method creation', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-library/create-test.js b/ui/admin/tests/acceptance/credential-library/create-test.js index 58d663f2f..47cc0f8a8 100644 --- a/ui/admin/tests/acceptance/credential-library/create-test.js +++ b/ui/admin/tests/acceptance/credential-library/create-test.js @@ -29,7 +29,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { credentialLibrary: null, credentialLibraries: null, newCredentialLibrary: null, - unknownCredentialLibrary: null, }; hooks.beforeEach(function () { @@ -59,7 +58,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { urls.credentialLibraries = `${urls.credentialStore}/credential-libraries`; urls.credentialLibrary = `${urls.credentialLibraries}/${instances.credentialLibrary.id}`; urls.newCredentialLibrary = `${urls.credentialLibraries}/new`; - urls.unknownCredentialLibrary = `${urls.credentialLibraries}/foo`; // Generate resource counter getCredentialLibraryCount = () => this.server.schema.credentialLibraries.all().models.length; @@ -76,14 +74,6 @@ module('Acceptance | credential-libraries | create', function (hooks) { assert.equal(currentURL(), urls.credentialLibrary); }); - test('visiting an unknown credential library displays 404 message', async function (assert) { - assert.expect(1); - await visit(urls.unknownCredentialLibrary); - await a11yAudit(); - console.debug(find('.rose-message-subtitle')); - assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404'); - }); - test('can create a credential library', async function (assert) { assert.expect(1); const count = getCredentialLibraryCount(); @@ -98,13 +88,13 @@ module('Acceptance | credential-libraries | create', function (hooks) { instances.credentialStore.authorized_collection_actions[ 'credential-libraries' ] = []; - await visit(urls.credentialStore); + await visit(urls.credentialLibraries); assert.notOk( instances.credentialStore.authorized_collection_actions[ 'credential-libraries' ].includes('create') ); - assert.notOk(find(`[href="${urls.credentialLibraries}"]`)); + assert.notOk(find(`[href="${urls.newCredentialLibrary}"]`)); }); test('can cancel create a new credential library', async function (assert) { diff --git a/ui/admin/tests/acceptance/credential-library/read-test.js b/ui/admin/tests/acceptance/credential-library/read-test.js index 6e94637da..012662d72 100644 --- a/ui/admin/tests/acceptance/credential-library/read-test.js +++ b/ui/admin/tests/acceptance/credential-library/read-test.js @@ -77,4 +77,12 @@ module('Acceptance | credential-libraries | read', function (hooks) { await visit(urls.credentialLibraries); assert.notOk(find('main tbody .rose-table-header-cell a')); }); + + test('visiting an unknown credential library displays 404 message', async function (assert) { + assert.expect(1); + await visit(urls.unknownCredentialLibrary); + await a11yAudit(); + console.debug(find('.rose-message-subtitle')); + assert.ok(find('.rose-message-subtitle').textContent.trim(), 'Error 404'); + }); }); diff --git a/ui/admin/tests/acceptance/credential-store/create-test.js b/ui/admin/tests/acceptance/credential-store/create-test.js index e651a641b..647baacd2 100644 --- a/ui/admin/tests/acceptance/credential-store/create-test.js +++ b/ui/admin/tests/acceptance/credential-store/create-test.js @@ -24,7 +24,6 @@ module('Acceptance | credential-stores | create', function (hooks) { projectScope: null, credentialStores: null, credentialStore: null, - unknownCredentialStore: null, newCredentialStore: null, }; @@ -47,7 +46,6 @@ module('Acceptance | credential-stores | create', function (hooks) { urls.projectScope = `/scopes/${instances.scopes.project.id}`; urls.credentialStores = `${urls.projectScope}/credential-stores`; urls.credentialStore = `${urls.credentialStores}/${instances.credentialStore.id}`; - urls.unknownCredentialStore = `${urls.credentialStores}/foo`; urls.newCredentialStore = `${urls.credentialStores}/new`; // Generate resource counter getCredentialStoresCount = () => { @@ -80,13 +78,13 @@ module('Acceptance | credential-stores | create', function (hooks) { instances.scopes.project.authorized_collection_actions[ 'credential-stores' ] = []; - await visit(urls.projectScope); + await visit(urls.credentialStores); assert.notOk( instances.scopes.project.authorized_collection_actions[ 'credential-stores' ].includes('create') ); - assert.notOk(find(`[href="${urls.credentialStores}"]`)); + assert.notOk(find(`[href="${urls.newCredentialStore}"]`)); }); test('saving a new credential store with invalid fields displays error messages', async function (assert) { diff --git a/ui/admin/tests/acceptance/groups/create-test.js b/ui/admin/tests/acceptance/groups/create-test.js index d3cc5fffb..740760d45 100644 --- a/ui/admin/tests/acceptance/groups/create-test.js +++ b/ui/admin/tests/acceptance/groups/create-test.js @@ -13,7 +13,6 @@ import { module('Acceptance | groups | create', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - let orgURL; const instances = { scopes: { @@ -45,7 +44,6 @@ module('Acceptance | groups | create', function (hooks) { urls.groups = `/scopes/${instances.orgScope.id}/groups`; urls.group = `${urls.groups}/${instances.group.id}`; urls.newGroup = `${urls.groups}/new`; - orgURL = `/scopes/${instances.orgScope.id}`; }); test('can create new group', async function (assert) { @@ -59,21 +57,21 @@ module('Acceptance | groups | create', function (hooks) { test('can navigate to new groups route with proper authorization', async function (assert) { assert.expect(2); - await visit(orgURL); + await visit(urls.groups); assert.ok( instances.orgScope.authorized_collection_actions.groups.includes('create') ); - assert.ok(find(`[href="${urls.groups}"]`)); + assert.ok(find(`[href="${urls.newGroup}"]`)); }); test('cannot navigate to new groups route without proper authorization', async function (assert) { assert.expect(2); instances.orgScope.authorized_collection_actions.groups = []; - await visit(orgURL); + await visit(urls.groups); assert.notOk( instances.orgScope.authorized_collection_actions.groups.includes('create') ); - assert.notOk(find(`[href="${urls.groups}"]`)); + assert.notOk(find(`[href="${urls.newGroup}"]`)); }); test('can cancel new group creation', async function (assert) { assert.expect(2); diff --git a/ui/admin/tests/acceptance/host-catalogs/create-test.js b/ui/admin/tests/acceptance/host-catalogs/create-test.js index e95ecbde0..b47b3b4ea 100644 --- a/ui/admin/tests/acceptance/host-catalogs/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/create-test.js @@ -92,26 +92,26 @@ module('Acceptance | host-catalogs | create', function (hooks) { test('Users can navigate to new host catalogs route with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.projectScope); + await visit(urls.hostCatalogs); assert.ok( instances.scopes.project.authorized_collection_actions[ 'host-catalogs' ].includes('create') ); - assert.ok(find(`[href="${urls.hostCatalogs}"]`)); + assert.ok(find(`[href="${urls.newHostCatalog}"]`)); }); test('Users cannot navigate to new host catalogs route without proper authorization', async function (assert) { assert.expect(2); instances.scopes.project.authorized_collection_actions['host-catalogs'] = []; - await visit(urls.projectScope); + await visit(urls.hostCatalogs); assert.notOk( instances.scopes.project.authorized_collection_actions[ 'host-catalogs' ].includes('create') ); - assert.notOk(find(`[href="${urls.hostCatalogs}"]`)); + assert.notOk(find(`[href="${urls.newHostCatalog}"]`)); }); test('saving a new host catalog with invalid fields displays error messages', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js index a7ede23ed..0c37a98ab 100644 --- a/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/host-sets/create-test.js @@ -94,13 +94,13 @@ module('Acceptance | host-catalogs | host sets | create', function (hooks) { test('Users cannot navigate to new host sets route without proper authorization', async function (assert) { assert.expect(2); instances.hostCatalog.authorized_collection_actions['host-sets'] = []; - await visit(urls.hostCatalog); + await visit(urls.hostSets); assert.notOk( instances.hostCatalog.authorized_collection_actions['host-sets'].includes( 'create' ) ); - assert.notOk(find(`[href="${urls.hostSets}"]`)); + assert.notOk(find(`[href="${urls.newHostSet}"]`)); }); test('can cancel create new host', async function (assert) { diff --git a/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js b/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js index 1b50b301b..75a436274 100644 --- a/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js +++ b/ui/admin/tests/acceptance/host-catalogs/hosts/create-test.js @@ -90,27 +90,27 @@ module('Acceptance | host-catalogs | hosts | create', function (hooks) { ); assert.notOk(find(`.rose-layout-page-actions [href="${urls.newHost}"]`)); }); - test('Users can navigate to new host catalogs route with proper authorization', async function (assert) { + test('Users can navigate to new host route with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.hostCatalog); + await visit(urls.hosts); assert.ok( instances.hostCatalog.authorized_collection_actions.hosts.includes( 'create' ) ); - assert.ok(find(`[href="${urls.hosts}"]`)); + assert.ok(find(`[href="${urls.newHost}"]`)); }); - test('Users cannot navigate to new host catalogs route without proper authorization', async function (assert) { + test('Users cannot navigate to new host route without proper authorization', async function (assert) { assert.expect(2); instances.hostCatalog.authorized_collection_actions.hosts = []; - await visit(urls.hostCatalog); + await visit(urls.hosts); assert.notOk( instances.hostCatalog.authorized_collection_actions.hosts.includes( 'create' ) ); - assert.notOk(find(`[href="${urls.hosts}"]`)); + assert.notOk(find(`[href="${urls.newHost}"]`)); }); test('can cancel create new host', async function (assert) { diff --git a/ui/admin/tests/acceptance/roles/create-test.js b/ui/admin/tests/acceptance/roles/create-test.js index a0564f67d..15ff5e750 100644 --- a/ui/admin/tests/acceptance/roles/create-test.js +++ b/ui/admin/tests/acceptance/roles/create-test.js @@ -73,21 +73,21 @@ module('Acceptance | roles | create', function (hooks) { test('Users can navigate to new roles route with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.orgScope); + await visit(urls.roles); assert.ok( instances.orgScope.authorized_collection_actions.roles.includes('create') ); - assert.ok(find(`[href="${urls.roles}"]`)); + assert.ok(find(`[href="${urls.newRole}"]`)); }); test('Users cannot navigate to new roles route without proper authorization', async function (assert) { assert.expect(2); instances.orgScope.authorized_collection_actions.roles = []; - await visit(urls.orgScope); + await visit(urls.roles); assert.notOk( instances.orgScope.authorized_collection_actions.roles.includes('create') ); - assert.notOk(find(`[href="${urls.roles}"]`)); + assert.notOk(find(`[href="${urls.newRole}"]`)); }); test('can cancel new role creation', async function (assert) { diff --git a/ui/admin/tests/acceptance/roles/list-test.js b/ui/admin/tests/acceptance/roles/list-test.js index ff170aeb7..525dab3f6 100644 --- a/ui/admin/tests/acceptance/roles/list-test.js +++ b/ui/admin/tests/acceptance/roles/list-test.js @@ -18,7 +18,6 @@ module('Acceptance | roles | list', function (hooks) { global: null, org: null, }, - orgScope: null, }; const urls = { @@ -26,50 +25,46 @@ module('Acceptance | roles | list', function (hooks) { org: null, }, roles: null, - orgScope: null, }; hooks.beforeEach(function () { - instances.orgScope = this.server.create( - 'scope', - { - type: 'org', - scope: { id: 'global', type: 'global' }, - }, - 'withChildren' - ); - instances.role = this.server.create('role', { - scope: instances.orgScope, + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, }); - urls.orgScope = `/scopes/${instances.orgScope.id}`; + instances.role = this.server.create('role', { + scope: instances.scopes.org, + }); + urls.scopes.org = `/scopes/${instances.scopes.org.id}`; - urls.roles = `/scopes/${instances.orgScope.id}/roles`; + urls.roles = `/scopes/${instances.scopes.org.id}/roles`; authenticateSession({}); }); test('Users can navigate to roles with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.orgScope); + await visit(urls.scopes.org); assert.ok( - instances.orgScope.authorized_collection_actions.roles.includes('list') + instances.scopes.org.authorized_collection_actions.roles.includes('list') ); assert.ok(find(`[href="${urls.roles}"]`)); }); test('Users cannot navigate to index without either list or create actions', async function (assert) { assert.expect(2); - instances.orgScope.authorized_collection_actions.roles = []; - await visit(urls.orgScope); + instances.scopes.org.authorized_collection_actions.roles = []; + await visit(urls.scopes.org); assert.notOk( - instances.orgScope.authorized_collection_actions.roles.includes('list') + instances.scopes.org.authorized_collection_actions.roles.includes('list') ); assert.notOk(find(`[href="${urls.roles}"]`)); }); test('Users can navigate to index with only create action', async function (assert) { assert.expect(1); - instances.orgScope.authorized_collection_actions.roles = ['create']; - await visit(urls.orgScope); + instances.scopes.org.authorized_collection_actions.roles = ['create']; + await visit(urls.scopes.org); assert.ok(find(`[href="${urls.roles}"]`)); }); }); diff --git a/ui/admin/tests/acceptance/targets/create-test.js b/ui/admin/tests/acceptance/targets/create-test.js index 16215cb7a..fd69af27e 100644 --- a/ui/admin/tests/acceptance/targets/create-test.js +++ b/ui/admin/tests/acceptance/targets/create-test.js @@ -69,25 +69,25 @@ module('Acceptance | targets | create', function (hooks) { test('can navigate to new targets route with proper authorization', async function (assert) { assert.expect(2); - await visit(urls.projectScope); + await visit(urls.targets); assert.ok( instances.scopes.project.authorized_collection_actions.targets.includes( 'create' ) ); - assert.ok(find(`[href="${urls.targets}"]`)); + assert.ok(find(`[href="${urls.newTarget}"]`)); }); test('cannot navigate to new targets route without proper authorization', async function (assert) { assert.expect(2); instances.scopes.project.authorized_collection_actions.targets = []; - await visit(urls.projectScope); + await visit(urls.targets); assert.notOk( instances.scopes.project.authorized_collection_actions.targets.includes( 'create' ) ); - assert.notOk(find(`[href="${urls.targets}"]`)); + assert.notOk(find(`[href="${urls.newTarget}"]`)); }); test('can cancel create new targets', async function (assert) { diff --git a/ui/admin/tests/acceptance/users/create-test.js b/ui/admin/tests/acceptance/users/create-test.js index 12261e9f5..c20ab05bf 100644 --- a/ui/admin/tests/acceptance/users/create-test.js +++ b/ui/admin/tests/acceptance/users/create-test.js @@ -15,7 +15,6 @@ module('Acceptance | users | create', function (hooks) { setupMirage(hooks); let orgScope; - let orgURL; let usersURL; let newUserURL; @@ -30,7 +29,6 @@ module('Acceptance | users | create', function (hooks) { 'withChildren' ); - orgURL = `/scopes/${orgScope.id}`; usersURL = `/scopes/${orgScope.id}/users`; newUserURL = `${usersURL}/new`; @@ -48,19 +46,19 @@ module('Acceptance | users | create', function (hooks) { test('Users can navigate to new users route with proper authorization', async function (assert) { assert.expect(2); - await visit(orgURL); + await visit(usersURL); assert.ok(orgScope.authorized_collection_actions.users.includes('create')); - assert.ok(find(`[href="${orgURL}/users"]`)); + assert.ok(find(`[href="${newUserURL}"]`)); }); test('Users cannot navigate to new users route without proper authorization', async function (assert) { assert.expect(2); orgScope.authorized_collection_actions.users = []; - await visit(orgURL); + await visit(usersURL); assert.notOk( orgScope.authorized_collection_actions.users.includes('create') ); - assert.notOk(find(`[href="${orgURL}/users"]`)); + assert.notOk(find(`[href="${newUserURL}"]`)); }); test('can cancel creation of a new user', async function (assert) { diff --git a/yarn.lock b/yarn.lock index 8eb8bf3ed..3d3cb02ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9984,7 +9984,7 @@ ember-focus-trap@^0.7.0: ember-modifier-manager-polyfill "^1.2.0" focus-trap "^6.4.0" -"ember-get-config@^0.2.4 || ^0.3.0", ember-get-config@^0.3.0: +"ember-get-config@^0.2.4 || ^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/ember-get-config/-/ember-get-config-0.3.0.tgz#a73a1a87b48d9dde4c66a0e52ed5260b8a48cfbd" integrity sha512-0e2pKzwW5lBZ4oJnvu9qHOht4sP1MWz/m3hyz8kpSoMdrlZVf62LDKZ6qfKgy8drcv5YhCMYE6QV7MhnqlrzEQ==