From 57568f9a8c00a8b7557c99c75bcc2d528d446035 Mon Sep 17 00:00:00 2001 From: Lisbet Alvarez <107949262+lisbet-alvarez@users.noreply.github.com> Date: Tue, 12 Nov 2024 09:27:07 -0800 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20missing=20controll?= =?UTF-8?q?er=20unit=20tests=20in=20admin-ui=20(#2553)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: 💍 add missing controller unit tests in admin-ui ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14740 --- .../scopes/scope/auth-methods/new.js | 2 - .../scopes/scope/storage-buckets/index.js | 5 +- .../account/change-password-test.js | 76 ++++++++++++ .../unit/controllers/application-test.js | 47 +++++++- .../scopes/scope/aliases/alias/index-test.js | 3 +- .../scopes/scope/aliases/new-test.js | 3 +- .../accounts/account/index-test.js | 1 + .../accounts/account/set-password-test.js | 64 +++++++++- .../auth-method/accounts/index-test.js | 81 ++++++++++++- .../auth-method/accounts/new-test.js | 1 + .../auth-methods/auth-method/index-test.js | 1 + .../auth-method/managed-groups/index-test.js | 104 +++++++++++++++- .../managed-group/index-test.js | 2 + .../managed-group/members-test.js | 1 + .../auth-method/managed-groups/new-test.js | 2 + .../scopes/scope/auth-methods/index-test.js | 2 +- .../scopes/scope/auth-methods/new-test.js | 1 + .../credential-library/index-test.js | 1 + .../credential-libraries/index-test.js | 114 +++++++++++++++++- .../credential-libraries/new-test.js | 2 +- .../credentials/credential/index-test.js | 1 + .../credentials/index-test.js | 98 ++++++++++++++- .../credential-store/credentials/new-test.js | 1 + .../credential-store/index-test.js | 1 + .../scope/credential-stores/index-test.js | 82 ++++++++++++- .../scope/credential-stores/new-test.js | 1 + .../scopes/scope/groups/group/index-test.js | 3 +- .../scopes/scope/groups/group/members-test.js | 3 +- .../scopes/scope/groups/index-test.js | 87 ++++++++++++- .../scopes/scope/groups/new-test.js | 3 +- .../host-sets/host-set/add-hosts-test.js | 11 +- .../host-set/create-and-add-host-test.js | 8 +- .../host-sets/host-set/hosts/index-test.js | 1 + .../host-sets/host-set/index-test.js | 1 + .../host-catalog/host-sets/index-test.js | 12 +- .../host-catalog/host-sets/new-test.js | 3 +- .../host-catalog/hosts/host/index-test.js | 1 + .../host-catalog/hosts/index-test.js | 1 + .../host-catalog/hosts/new-test.js | 1 + .../host-catalogs/host-catalog/index-test.js | 1 + .../scopes/scope/host-catalogs/index-test.js | 10 +- .../scopes/scope/host-catalogs/new-test.js | 1 + .../scopes/scope/policies/index-test.js | 7 +- .../scopes/scope/policies/new-test.js | 1 + .../scope/policies/policy/index-test.js | 1 + .../scopes/scope/roles/index-test.js | 4 +- .../scopes/scope/roles/new-test.js | 1 + .../scope/roles/role/add-principals-test.js | 4 +- .../scopes/scope/roles/role/grants-test.js | 7 +- .../scopes/scope/roles/role/index-test.js | 1 + .../manage-custom-scopes-test.js | 1 + .../manage-scopes/manage-org-projects-test.js | 1 + .../scope/roles/role/principals-test.js | 1 + .../scopes/scope/roles/role/scopes-test.js | 4 +- .../channels-by-connection/index-test.js | 4 + .../scope/storage-buckets/index-test.js | 85 ++++++++++++- .../scopes/scope/storage-buckets/new-test.js | 4 +- .../storage-bucket/index-test.js | 4 +- .../scopes/scope/targets/new-test.js | 1 + .../brokered-credential-sources-test.js | 1 + .../scope/targets/target/create-alias-test.js | 1 + .../target/edit-egress-worker-filter-test.js | 1 + .../target/edit-ingress-worker-filter-test.js | 1 + .../create-storage-bucket-test.js | 1 + .../enable-session-recording/index-test.js | 1 + .../scope/targets/target/host-sources-test.js | 1 + ...ted-application-credential-sources-test.js | 1 + .../scope/targets/target/manage-alias-test.js | 1 + .../scope/targets/target/workers-test.js | 1 + .../scopes/scope/users/index-test.js | 4 +- .../scopes/scope/users/new-test.js | 1 + .../scopes/scope/users/user/accounts-test.js | 1 + .../scopes/scope/users/user/index-test.js | 1 + .../scopes/scope/workers/new-test.js | 4 +- .../scopes/scope/workers/worker/index-test.js | 22 ++++ .../scopes/scope/workers/worker/tags-test.js | 1 + .../unit/controllers/application-test.js | 8 ++ 77 files changed, 946 insertions(+), 81 deletions(-) create mode 100644 ui/admin/tests/unit/controllers/account/change-password-test.js create mode 100644 ui/admin/tests/unit/controllers/scopes/scope/workers/worker/index-test.js diff --git a/ui/admin/app/controllers/scopes/scope/auth-methods/new.js b/ui/admin/app/controllers/scopes/scope/auth-methods/new.js index a0a355bc96..652dacbc95 100644 --- a/ui/admin/app/controllers/scopes/scope/auth-methods/new.js +++ b/ui/admin/app/controllers/scopes/scope/auth-methods/new.js @@ -8,8 +8,6 @@ import Controller, { inject as controller } from '@ember/controller'; export default class ScopesScopeAuthMethodsNewController extends Controller { @controller('scopes/scope/auth-methods/index') authMethods; - // =services - // =attributes queryParams = ['type']; diff --git a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js index d35475c251..27ef587682 100644 --- a/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js +++ b/ui/admin/app/controllers/scopes/scope/storage-buckets/index.js @@ -12,6 +12,7 @@ import { notifySuccess, notifyError } from 'core/decorators/notify'; export default class ScopesScopeStorageBucketsIndexController extends Controller { // =services + @service router; // =actions @@ -63,7 +64,7 @@ export default class ScopesScopeStorageBucketsIndexController extends Controller } /** - * Updates credentil type + * Updates credential type * @param {object} storageBucket * @param {string} credentialType */ @@ -74,7 +75,7 @@ export default class ScopesScopeStorageBucketsIndexController extends Controller /** * Changes the plugin type. - * @param {*} pluginType + * @param {string} pluginType */ @action async changePluginType(pluginType) { diff --git a/ui/admin/tests/unit/controllers/account/change-password-test.js b/ui/admin/tests/unit/controllers/account/change-password-test.js new file mode 100644 index 0000000000..facd93f5d2 --- /dev/null +++ b/ui/admin/tests/unit/controllers/account/change-password-test.js @@ -0,0 +1,76 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; + +module('Unit | Controller | account/change-password', function (hooks) { + setupTest(hooks); + setupMirage(hooks); + + let controller; + let store; + + const instances = { + scopes: { + global: null, + }, + authMethod: null, + account: null, + }; + + const urls = { + globalScope: null, + }; + + hooks.beforeEach(async function () { + authenticateSession({}); + controller = this.owner.lookup('controller:account/change-password'); + store = this.owner.lookup('service:store'); + + instances.scopes.global = this.server.create('scope', { + id: 'global', + type: 'global', + }); + instances.authMethod = this.server.create('auth-method', { + scope: instances.scopes.global, + type: TYPE_AUTH_METHOD_PASSWORD, + }); + instances.account = this.server.create('account', { + scope: instances.scopes.global, + authMethod: instances.authMethod, + }); + + urls.globalScope = `/scopes/global`; + }); + + test('it exists', function (assert) { + assert.ok(controller); + }); + + test('changePassword action makes the correct API call with correct values', async function (assert) { + assert.expect(2); + const password = 'current password'; + const newPassword = 'new password'; + this.server.post( + '/accounts/:idMethod', + (_, { params: { idMethod }, requestBody }) => { + const attrs = JSON.parse(requestBody); + assert.strictEqual(attrs.current_password, password); + assert.strictEqual(attrs.new_password, newPassword); + const id = idMethod.split(':')[0]; + return { id }; + }, + ); + await visit(urls.globalScope); + const account = await store.findRecord('account', instances.account.id); + + await controller.changePassword(account, password, newPassword); + }); +}); diff --git a/ui/admin/tests/unit/controllers/application-test.js b/ui/admin/tests/unit/controllers/application-test.js index 02e3e248a8..705d584066 100644 --- a/ui/admin/tests/unit/controllers/application-test.js +++ b/ui/admin/tests/unit/controllers/application-test.js @@ -5,12 +5,57 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { authenticateSession } from 'ember-simple-auth/test-support'; module('Unit | Controller | application', function (hooks) { setupTest(hooks); + let controller; + let featureEdition; + let featuresService; + let session; + + hooks.beforeEach(async function () { + authenticateSession({}); + controller = this.owner.lookup('controller:application'); + featureEdition = this.owner.lookup('service:featureEdition'); + featuresService = this.owner.lookup('service:features'); + session = this.owner.lookup('service:session'); + }); + test('it exists', function (assert) { - let controller = this.owner.lookup('controller:application'); assert.ok(controller); }); + + test('invalidateSession action de-authenticates a user', async function (assert) { + assert.true(session.isAuthenticated); + + await controller.invalidateSession(); + + assert.false(session.isAuthenticated); + }); + + test('toggleTheme action sets theme to specified value', function (assert) { + assert.notOk(session.data.theme); + + controller.toggleTheme('light'); + + assert.strictEqual(session.data.theme, 'light'); + }); + + test('toggleEdition action sets edition to specified value', function (assert) { + assert.notOk(featureEdition.edition); + + controller.toggleEdition('oss'); + + assert.strictEqual(featureEdition.edition, 'oss'); + }); + + test('toggleFeature action toggles specified feature', function (assert) { + assert.false(featuresService.isEnabled('ssh-target')); + + controller.toggleFeature('ssh-target'); + + assert.true(featuresService.isEnabled('ssh-target')); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/aliases/alias/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/aliases/alias/index-test.js index d5e1f79c5b..838858661e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/aliases/alias/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/aliases/alias/index-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module( 'Unit | Controller | scopes/scope/aliases/alias/index', @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/aliases/alias/index', ); assert.ok(controller); + assert.ok(controller.aliases); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/aliases/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/aliases/new-test.js index c0264813fb..2fad5cb2d0 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/aliases/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/aliases/new-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module('Unit | Controller | scopes/scope/aliases/new', function (hooks) { setupTest(hooks); @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/aliases/new', function (hooks) { test('it exists', function (assert) { let controller = this.owner.lookup('controller:scopes/scope/aliases/new'); assert.ok(controller); + assert.ok(controller.aliases); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js index 19388c08c0..1b5c539a96 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/auth-methods/auth-method/accounts/account/index', ); assert.ok(controller); + assert.ok(controller.accounts); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/set-password-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/set-password-test.js index 8d5e060a12..158f2c6a07 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/set-password-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/account/set-password-test.js @@ -5,17 +5,77 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; module( 'Unit | Controller | scopes/scope/auth-methods/auth-method/accounts/account/set-password', function (hooks) { setupTest(hooks); + setupMirage(hooks); - test('it exists', function (assert) { - let controller = this.owner.lookup( + let controller; + let store; + + const instances = { + scopes: { + global: null, + }, + authMethod: null, + account: null, + }; + + const urls = { + globalScope: null, + accounts: null, + }; + + hooks.beforeEach(async function () { + authenticateSession({}); + controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/accounts/account/set-password', ); + store = this.owner.lookup('service:store'); + + instances.scopes.global = this.server.create('scope', { + id: 'global', + type: 'global', + }); + instances.authMethod = this.server.create('auth-method', { + scope: instances.scopes.global, + type: TYPE_AUTH_METHOD_PASSWORD, + }); + instances.account = this.server.create('account', { + scope: instances.scopes.global, + authMethod: instances.authMethod, + }); + + urls.globalScope = `/scopes/global`; + }); + + test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.accounts); + }); + + test('setPassword action makes the correct API call with correct values', async function (assert) { + assert.expect(1); + const password = 'current password'; + this.server.post( + '/accounts/:idMethod', + (_, { params: { idMethod }, requestBody }) => { + const attrs = JSON.parse(requestBody); + assert.strictEqual(attrs.password, password); + const id = idMethod.split(':')[0]; + return { id }; + }, + ); + await visit(urls.globalScope); + const account = await store.findRecord('account', instances.account.id); + + await controller.setPassword(account, password); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js index ea87128f52..c70fbe3b83 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/index-test.js @@ -5,17 +5,94 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; +import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_AUTH_METHOD_PASSWORD } from 'api/models/auth-method'; module( 'Unit | Controller | scopes/scope/auth-methods/auth-method/accounts/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIntl(hooks, 'en-us'); - test('it exists', function (assert) { - let controller = this.owner.lookup( + let controller; + let store; + let getAccountCount; + + const instances = { + scopes: { + global: null, + }, + authMethod: null, + account: null, + }; + + const urls = { + accounts: null, + }; + + hooks.beforeEach(async function () { + authenticateSession({}); + controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/accounts/index', ); + store = this.owner.lookup('service:store'); + + instances.scopes.global = this.server.create('scope', { + id: 'global', + type: 'global', + }); + instances.authMethod = this.server.create('auth-method', { + scope: instances.scopes.global, + type: TYPE_AUTH_METHOD_PASSWORD, + }); + instances.account = this.server.create('account', { + scope: instances.scopes.global, + authMethod: instances.authMethod, + }); + + getAccountCount = () => this.server.schema.accounts.all().models.length; + + urls.accounts = `/scopes/global/auth-methods/${instances.authMethod.id}/accounts`; + }); + + test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.authMethods); + }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.accounts); + const account = await store.findRecord('account', instances.account.id); + account.name = 'test'; + + assert.strictEqual(account.name, 'test'); + + await controller.cancel(account); + + assert.notEqual(account.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.accounts); + const account = await store.findRecord('account', instances.account.id); + account.name = 'test'; + + await controller.save(account); + + assert.strictEqual(account.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const account = await store.findRecord('account', instances.account.id); + const accountCount = getAccountCount(); + + await controller.delete(account); + + assert.strictEqual(getAccountCount(), accountCount - 1); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/new-test.js index 715bc42d89..28934914c3 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/accounts/new-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/auth-methods/auth-method/accounts/new', ); assert.ok(controller); + assert.ok(controller.accounts); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/index-test.js index 5c52ac2a41..7abf0fbb97 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/auth-methods/auth-method/index', ); assert.ok(controller); + assert.ok(controller.authMethods); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js index 70e88eca1b..e8d3171737 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/index-test.js @@ -5,17 +5,117 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; +import { visit } from '@ember/test-helpers'; +import { authenticateSession } from 'ember-simple-auth/test-support'; +import { TYPE_AUTH_METHOD_LDAP } from 'api/models/auth-method'; module( 'Unit | Controller | scopes/scope/auth-methods/auth-method/managed-groups/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIntl(hooks, 'en-us'); - test('it exists', function (assert) { - let controller = this.owner.lookup( + let controller; + let store; + let getManagedGroupCount; + + const instances = { + scopes: { + global: null, + }, + authMethod: null, + managedGroup: null, + }; + + const urls = { + managedGroups: null, + }; + + hooks.beforeEach(async function () { + authenticateSession({}); + controller = this.owner.lookup( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/index', ); + store = this.owner.lookup('service:store'); + + instances.scopes.global = this.server.create('scope', { + id: 'global', + type: 'global', + }); + instances.authMethod = this.server.create('auth-method', { + scope: instances.scopes.global, + type: TYPE_AUTH_METHOD_LDAP, + }); + instances.managedGroup = this.server.create('managed-group', { + scope: instances.scopes.global, + authMethod: instances.authMethod, + }); + + getManagedGroupCount = () => + this.server.schema.managedGroups.all().models.length; + + urls.managedGroups = `/scopes/global/auth-methods/${instances.authMethod.id}/managed-groups`; + }); + + test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.authMethods); + }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.managedGroups); + const managedGroup = await store.findRecord( + 'managed-group', + instances.managedGroup.id, + ); + managedGroup.name = 'test'; + + assert.strictEqual(managedGroup.name, 'test'); + + await controller.cancel(managedGroup); + + assert.notEqual(managedGroup.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.managedGroups); + const managedGroup = await store.findRecord( + 'managed-group', + instances.managedGroup.id, + ); + managedGroup.name = 'test'; + + await controller.save(managedGroup); + + assert.strictEqual(managedGroup.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const managedGroup = await store.findRecord( + 'managed-group', + instances.managedGroup.id, + ); + const managedGroupCount = getManagedGroupCount(); + + await controller.delete(managedGroup); + + assert.strictEqual(getManagedGroupCount(), managedGroupCount - 1); + }); + + test('edit action updates to a dirty state', async function (assert) { + const managedGroup = await store.findRecord( + 'managed-group', + instances.managedGroup.id, + ); + + assert.false(managedGroup.hasDirtyAttributes); + + controller.edit(managedGroup); + + assert.true(managedGroup.hasDirtyAttributes); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index-test.js index 5ec04f8cc0..e1b4f96dee 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index-test.js @@ -16,6 +16,8 @@ module( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/managed-group/index', ); assert.ok(controller); + assert.ok(controller.authMethods); + assert.ok(controller.managedGroups); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/members-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/members-test.js index 622f3b503f..07312aea6e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/members-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/managed-group/members-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/managed-group/members', ); assert.ok(controller); + assert.ok(controller.managedGroups); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/new-test.js index fa9a4475d9..b9904cc37e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/auth-method/managed-groups/new-test.js @@ -16,6 +16,8 @@ module( 'controller:scopes/scope/auth-methods/auth-method/managed-groups/new', ); assert.ok(controller); + assert.ok(controller.authMethods); + assert.ok(controller.managedGroups); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js index c212b9a627..19bcd7534b 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/index-test.js @@ -43,7 +43,7 @@ module('Unit | Controller | scopes/scope/auth-methods/index', function (hooks) { instances.scope.global = this.server.create('scope', { id: 'global' }); instances.authMethod = this.server.create('auth-method', { - scopeId: 'global', + scope: instances.scope.global, }); getAuthMethodCount = () => diff --git a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/new-test.js index 1cb3a1d43b..a913fc9e52 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/auth-methods/new-test.js @@ -14,5 +14,6 @@ module('Unit | Controller | scopes/scope/auth-methods/new', function (hooks) { 'controller:scopes/scope/auth-methods/new', ); assert.ok(controller); + assert.ok(controller.authMethods); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/credential-library/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/credential-library/index-test.js index 70b5ca7c54..0618ececea 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/credential-library/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/credential-library/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/credential-library/index', ); assert.ok(controller); + assert.ok(controller.credentialLibraries); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js index d7b979cc77..03561476a5 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/index-test.js @@ -5,17 +5,127 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; +import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; +import { authenticateSession } from 'ember-simple-auth/test-support'; module( 'Unit | Controller | scopes/scope/credential-stores/credential-store/credential-libraries/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); - test('it exists', function (assert) { - let controller = this.owner.lookup( + let store; + let controller; + let getCredentialLibraryCount; + + const instances = { + scopes: { + global: null, + org: null, + project: null, + }, + credentialStore: null, + credentialLibrary: null, + }; + + const urls = { + credentialLibraries: null, + }; + + hooks.beforeEach(function () { + authenticateSession({}); + store = this.owner.lookup('service:store'); + controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/index', ); + + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, + }); + instances.scopes.project = this.server.create('scope', { + type: 'project', + scope: { id: instances.scopes.org.id, type: 'org' }, + }); + instances.credentialStore = this.server.create('credential-store', { + scope: instances.scopes.project, + }); + instances.credentialLibrary = this.server.create('credential-library', { + credentialStore: instances.credentialStore, + extensions: [{ key: 'foo', value: 'bar' }], + }); + + urls.credentialLibraries = `/scopes/${instances.scopes.project.id}/credential-stores/${instances.credentialStore.id}/credential-libraries`; + + getCredentialLibraryCount = () => + this.server.schema.credentialLibraries.all().models.length; + }); + + test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.credentialStores); + }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.credentialLibraries); + const credentialLibrary = await store.findRecord( + 'credential-library', + instances.credentialLibrary.id, + ); + credentialLibrary.name = 'test'; + + assert.strictEqual(credentialLibrary.name, 'test'); + + await controller.cancel(credentialLibrary); + + assert.notEqual(credentialLibrary.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.credentialLibraries); + const credentialLibrary = await store.findRecord( + 'credential-library', + instances.credentialLibrary.id, + ); + credentialLibrary.name = 'test'; + + await controller.save(credentialLibrary); + + assert.strictEqual(credentialLibrary.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const credentialLibrary = await store.findRecord( + 'credential-library', + instances.credentialLibrary.id, + ); + const credentialLibraryCount = getCredentialLibraryCount(); + + await controller.delete(credentialLibrary); + + assert.strictEqual( + getCredentialLibraryCount(), + credentialLibraryCount - 1, + ); + }); + + test('edit action updates to a dirty state', async function (assert) { + const credentialLibrary = await store.findRecord( + 'credential-library', + instances.credentialLibrary.id, + ); + + assert.false(credentialLibrary.hasDirtyAttributes); + + controller.edit(credentialLibrary); + + assert.true(credentialLibrary.hasDirtyAttributes); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js index f7c980059b..433c170ae4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credential-libraries/new-test.js @@ -11,12 +11,12 @@ module( function (hooks) { setupTest(hooks); - // TODO: Replace this with your real tests. test('it exists', function (assert) { let controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credential-libraries/new', ); assert.ok(controller); + assert.ok(controller.credentialLibraries); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/credential/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/credential/index-test.js index e4c5793edf..bf6ff91309 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/credential/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/credential/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/credential-stores/credential-store/credentials/credential/index', ); assert.ok(controller); + assert.ok(controller.credentials); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js index 3fcbb6a539..a4f326e1df 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/index-test.js @@ -5,17 +5,111 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; +import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; +import { authenticateSession } from 'ember-simple-auth/test-support'; module( 'Unit | Controller | scopes/scope/credential-stores/credential-store/credentials/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); - test('it exists', function (assert) { - let controller = this.owner.lookup( + let store; + let controller; + let getCredentialCount; + + const instances = { + scopes: { + global: null, + org: null, + project: null, + }, + credentialStore: null, + credential: null, + }; + + const urls = { + credentials: null, + }; + + hooks.beforeEach(function () { + authenticateSession({}); + store = this.owner.lookup('service:store'); + controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/credential-store/credentials/index', ); + + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, + }); + instances.scopes.project = this.server.create('scope', { + type: 'project', + scope: { id: instances.scopes.org.id, type: 'org' }, + }); + instances.credentialStore = this.server.create('credential-store', { + scope: instances.scopes.project, + }); + instances.credential = this.server.create('credential', { + credentialStore: instances.credentialStore, + extensions: [{ key: 'foo', value: 'bar' }], + }); + + urls.credentials = `/scopes/${instances.scopes.project.id}/credential-stores/${instances.credentialStore.id}/credentials`; + + getCredentialCount = () => + this.server.schema.credentials.all().models.length; + }); + + test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.credentialStores); + }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.credentials); + const credential = await store.findRecord( + 'credential', + instances.credential.id, + ); + credential.name = 'test'; + + assert.strictEqual(credential.name, 'test'); + + await controller.cancel(credential); + + assert.notEqual(credential.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.credentials); + const credential = await store.findRecord( + 'credential', + instances.credential.id, + ); + credential.name = 'test'; + + await controller.save(credential); + + assert.strictEqual(credential.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const credential = await store.findRecord( + 'credential', + instances.credential.id, + ); + const credentialCount = getCredentialCount(); + + await controller.delete(credential); + + assert.strictEqual(getCredentialCount(), credentialCount - 1); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/new-test.js index 413cb9a656..ee0037b2be 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/credentials/new-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/credential-stores/credential-store/credentials/new', ); assert.ok(controller); + assert.ok(controller.credentials); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/index-test.js index 0aaa161085..20561945b6 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/credential-store/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/credential-stores/credential-store/index', ); assert.ok(controller); + assert.ok(controller.credentialStores); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js index 45abef8cee..8e89d88f43 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/index-test.js @@ -6,7 +6,10 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { setupIntl } from 'ember-intl/test-support'; -import { waitUntil } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; +import { waitUntil, visit } from '@ember/test-helpers'; +import { authenticateSession } from 'ember-simple-auth/test-support'; import { TYPE_CREDENTIAL_STORE_STATIC, TYPE_CREDENTIAL_STORE_VAULT, @@ -16,20 +19,97 @@ module( 'Unit | Controller | scopes/scope/credential-stores/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIndexedDb(hooks); setupIntl(hooks, 'en-us'); let controller; + let store; + let getCredentialStoreCount; + + const instances = { + scopes: { + global: null, + org: null, + project: null, + }, + credentialStore: null, + }; + + const urls = { + credentialStores: null, + }; hooks.beforeEach(function () { + authenticateSession({}); controller = this.owner.lookup( 'controller:scopes/scope/credential-stores/index', ); + store = this.owner.lookup('service:store'); + + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.scopes.org = this.server.create('scope', { + type: 'org', + scope: { id: 'global', type: 'global' }, + }); + instances.scopes.project = this.server.create('scope', { + type: 'project', + scope: { id: instances.scopes.org.id, type: 'org' }, + }); + instances.credentialStore = this.server.create('credential-store', { + scope: instances.scopes.project, + }); + + urls.credentialStores = `scopes/${instances.scopes.project.id}/credential-stores`; + + getCredentialStoreCount = () => + this.server.schema.credentialStores.all().models.length; }); test('it exists', function (assert) { assert.ok(controller); }); + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.credentialStores); + const credentialStore = await store.findRecord( + 'credential-store', + instances.credentialStore.id, + ); + credentialStore.name = 'test'; + + assert.strictEqual(credentialStore.name, 'test'); + + await controller.cancel(credentialStore); + + assert.notEqual(credentialStore.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.credentialStores); + const credentialStore = await store.findRecord( + 'credential-store', + instances.credentialStore.id, + ); + credentialStore.name = 'test'; + + await controller.save(credentialStore); + + assert.strictEqual(credentialStore.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const credentialStore = await store.findRecord( + 'credential-store', + instances.credentialStore.id, + ); + const credentialStoreCount = getCredentialStoreCount(); + + await controller.delete(credentialStore); + + assert.strictEqual(getCredentialStoreCount(), credentialStoreCount - 1); + }); + test('credStoreTypeOptions returns expected object', function (assert) { assert.deepEqual(controller.credStoreTypeOptions, [ { id: TYPE_CREDENTIAL_STORE_STATIC, name: 'Static' }, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/new-test.js index af957d165e..542990d925 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/credential-stores/new-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/credential-stores/new', ); assert.ok(controller); + assert.ok(controller.credentialStores); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/index-test.js index e04e049bd3..053b03990d 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/index-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module('Unit | Controller | scopes/scope/groups/group/index', function (hooks) { setupTest(hooks); @@ -14,5 +14,6 @@ module('Unit | Controller | scopes/scope/groups/group/index', function (hooks) { 'controller:scopes/scope/groups/group/index', ); assert.ok(controller); + assert.ok(controller.groups); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/members-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/members-test.js index 517acad2b7..9897ac843a 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/group/members-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/group/members-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module( 'Unit | Controller | scopes/scope/groups/group/members', @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/groups/group/members', ); assert.ok(controller); + assert.ok(controller.groups); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js index e7fd6bf719..9b9de64979 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/index-test.js @@ -5,18 +5,57 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; -import { waitUntil } from '@ember/test-helpers'; +import { waitUntil, visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; +import { setupIntl } from 'ember-intl/test-support'; +import { authenticateSession } from 'ember-simple-auth/test-support'; module('Unit | Controller | scopes/scope/groups/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); + + let store; + let controller; + let getGroupCount; + + const instances = { + scopes: { + global: null, + }, + group: null, + user: null, + }; + + const urls = { + groups: null, + }; + + hooks.beforeEach(function () { + authenticateSession({}); + store = this.owner.lookup('service:store'); + controller = this.owner.lookup('controller:scopes/scope/groups/index'); + + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.group = this.server.create('group', { + scope: instances.scopes.global, + }); + instances.user = this.server.create('user', { + scope: instances.scopes.global, + }); + + urls.groups = '/scopes/global/groups'; + + getGroupCount = () => this.server.schema.groups.all().models.length; + }); test('it exists', function (assert) { - let controller = this.owner.lookup('controller:scopes/scope/groups/index'); assert.ok(controller); }); test('handleSearchInput action sets expected values correctly', async function (assert) { - let controller = this.owner.lookup('controller:scopes/scope/targets/index'); const searchValue = 'group'; controller.handleSearchInput({ target: { value: searchValue } }); await waitUntil(() => controller.search === searchValue); @@ -24,4 +63,46 @@ module('Unit | Controller | scopes/scope/groups/index', function (hooks) { assert.strictEqual(controller.page, 1); assert.strictEqual(controller.search, searchValue); }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.groups); + const group = await store.findRecord('group', instances.group.id); + group.name = 'test'; + + assert.strictEqual(group.name, 'test'); + + await controller.cancel(group); + + assert.notEqual(group.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.groups); + const group = await store.findRecord('group', instances.group.id); + group.name = 'test'; + + await controller.save(group); + + assert.strictEqual(group.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const group = await store.findRecord('group', instances.group.id); + const groupCount = getGroupCount(); + + await controller.delete(group); + + assert.strictEqual(getGroupCount(), groupCount - 1); + }); + + test('removeMember action removes member from group', async function (assert) { + instances.group.update({ memberIds: [instances.user.id] }); + const group = await store.findRecord('group', instances.group.id); + + assert.deepEqual(group.member_ids, [instances.user.id]); + + await controller.removeMember(group, instances.user); + + assert.deepEqual(group.member_ids, []); + }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/groups/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/groups/new-test.js index cb2f323b8d..c58987961f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/groups/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/groups/new-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module('Unit | Controller | scopes/scope/groups/new', function (hooks) { setupTest(hooks); @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/groups/new', function (hooks) { test('it exists', function (assert) { let controller = this.owner.lookup('controller:scopes/scope/groups/new'); assert.ok(controller); + assert.ok(controller.groups); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js index 64d8ba1623..b826eef37f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/add-hosts-test.js @@ -50,21 +50,18 @@ module( scope: { id: instances.scopes.org.id, type: 'org' }, }); instances.hostCatalog = this.server.create('host-catalog', { - scopeId: instances.scopes.project.id, scope: instances.scopes.project, }); instances.hostSet = this.server.create('host-set', { - scopeId: instances.scopes.project.id, + scope: instances.scopes.project, hostCatalog: instances.hostCatalog, }); instances.host = this.server.create('host', { - scopeId: instances.scopes.project.id, + scope: instances.scopes.project, hostCatalog: instances.hostCatalog, }); - urls.globalScope = `/scopes/global`; - urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; - urls.projectScope = `/scopes/${instances.scopes.project.id}`; - urls.addHosts = `${urls.projectScope}/host-catalogs/${instances.hostCatalog.id}/host-sets/${instances.hostSet.id}/add-hosts`; + + urls.addHosts = `/scopes/${instances.scopes.project.id}/host-catalogs/${instances.hostCatalog.id}/host-sets/${instances.hostSet.id}/add-hosts`; }); test('it exists', function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js index 8abb8bfdea..46aadf1710 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/create-and-add-host-test.js @@ -30,7 +30,7 @@ module( }; const urls = { - createAndAddhost: null, + createAndAddHost: null, }; hooks.beforeEach(function () { @@ -64,7 +64,7 @@ module( urls.globalScope = `/scopes/global`; urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; urls.projectScope = `/scopes/${instances.scopes.project.id}`; - urls.createAndAddhost = `${urls.projectScope}/host-catalogs/${instances.hostCatalog.id}/host-sets/${instances.hostSet.id}/create-and-add-host`; + urls.createAndAddHost = `${urls.projectScope}/host-catalogs/${instances.hostCatalog.id}/host-sets/${instances.hostSet.id}/create-and-add-host`; }); test('it exists', function (assert) { @@ -72,7 +72,7 @@ module( }); test('cancel action rolls-back changes on the specified model', async function (assert) { - await visit(urls.createAndAddhost); + await visit(urls.createAndAddHost); const host = await store.findRecord('host', instances.host.id); host.name = 'test'; @@ -84,7 +84,7 @@ module( }); test('save action saves host and adds to the specified host-set', async function (assert) { - await visit(urls.createAndAddhost); + await visit(urls.createAndAddHost); const hostSet = await store.findRecord('host-set', instances.hostSet.id); const host = await store.findRecord('host', instances.host.id); host.name = 'test'; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/index-test.js index 04de9ba4ac..ae3928e5f9 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/host-set/hosts/index', ); assert.ok(controller); + assert.ok(controller.hostSets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/index-test.js index 51a49df570..b94f17d625 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/host-set/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/host-set/index', ); assert.ok(controller); + assert.ok(controller.hostSets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js index 30c5070acd..716afeaf01 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/index-test.js @@ -7,6 +7,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { visit } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; import { authenticateSession } from 'ember-simple-auth/test-support'; @@ -16,6 +17,7 @@ module( setupTest(hooks); setupMirage(hooks); setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); let store; let controller; @@ -52,23 +54,20 @@ module( scope: { id: instances.scopes.org.id, type: 'org' }, }); instances.hostCatalog = this.server.create('host-catalog', { - scopeId: instances.scopes.project.id, scope: instances.scopes.project, }); instances.hostSet = this.server.create('host-set', { - scopeId: instances.scopes.project.id, hostCatalog: instances.hostCatalog, }); - urls.globalScope = `/scopes/global`; - urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; - urls.projectScope = `/scopes/${instances.scopes.project.id}`; - urls.hostSets = `${urls.projectScope}/host-catalogs/${instances.hostCatalog.id}/host-sets`; + + urls.hostSets = `/scopes/${instances.scopes.project.id}/host-catalogs/${instances.hostCatalog.id}/host-sets`; getHostSetCount = () => this.server.schema.hostSets.all().models.length; }); test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.hostCatalogs); }); test('cancel action rolls-back changes on the specified model', async function (assert) { @@ -94,7 +93,6 @@ module( }); test('delete action destroys specified model', async function (assert) { - await visit(urls.projectScope); const hostSet = await store.findRecord('host-set', instances.hostSet.id); const hostSetCount = getHostSetCount(); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/new-test.js index 8865aaba5b..04dab004ff 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/host-sets/new-test.js @@ -4,7 +4,7 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module( 'Unit | Controller | scopes/scope/host-catalogs/host-catalog/host-sets/new', @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/host-sets/new', ); assert.ok(controller); + assert.ok(controller.hostSets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/host/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/host/index-test.js index 4dccbf4bb7..fc362542ec 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/host/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/host/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/hosts/host/index', ); assert.ok(controller); + assert.ok(controller.hosts); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js index 4d7ccaf682..af5bc9db7e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/index-test.js @@ -69,6 +69,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.hostCatalogs); }); test('cancel action rolls-back changes on the specified model', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/new-test.js index 1f64d9b7f9..d8ee9a1221 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/hosts/new-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/hosts/new', ); assert.ok(controller); + assert.ok(controller.hosts); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/index-test.js index 16fbbbdc70..3ea82bdd9f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/host-catalog/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/host-catalogs/host-catalog/index', ); assert.ok(controller); + assert.ok(controller.hostCatalogs); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js index 7d6fc9fb9f..100549c02f 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/index-test.js @@ -5,6 +5,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; +import { setupIntl } from 'ember-intl/test-support'; import { waitUntil, visit } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; @@ -16,6 +17,7 @@ module( setupTest(hooks); setupMirage(hooks); setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); let store; let controller; @@ -51,13 +53,10 @@ module( scope: { id: instances.scopes.org.id, type: 'org' }, }); instances.hostCatalog = this.server.create('host-catalog', { - scopeId: instances.scopes.project.id, scope: instances.scopes.project, }); - urls.globalScope = `/scopes/global`; - urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`; - urls.projectScope = `/scopes/${instances.scopes.project.id}`; - urls.hostCatalogs = `${urls.projectScope}/host-catalogs`; + + urls.hostCatalogs = `scopes/${instances.scopes.project.id}/host-catalogs`; getHostCatalogCount = () => this.server.schema.hostCatalogs.all().models.length; @@ -105,7 +104,6 @@ module( }); test('delete action destroys specified model', async function (assert) { - await visit(urls.projectScope); const hostCatalog = await store.findRecord( 'host-catalog', instances.hostCatalog.id, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js index 63b024e0fc..2548ab0243 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/host-catalogs/new-test.js @@ -14,5 +14,6 @@ module('Unit | Controller | scopes/scope/host-catalogs/new', function (hooks) { 'controller:scopes/scope/host-catalogs/new', ); assert.ok(controller); + assert.ok(controller.hostCatalogs); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js index 8b502fc805..fda6a713c8 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/policies/index-test.js @@ -7,6 +7,7 @@ import { module, test } from 'qunit'; import { setupTest } from 'ember-qunit'; import { visit } from '@ember/test-helpers'; import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIntl } from 'ember-intl/test-support'; import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; import { authenticateSession } from 'ember-simple-auth/test-support'; @@ -14,6 +15,7 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { setupTest(hooks); setupMirage(hooks); setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); let store; let controller; @@ -27,7 +29,6 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { }; const urls = { - globalScope: null, policies: null, }; @@ -41,8 +42,7 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { scopeId: 'global', }); - urls.globalScope = `/scopes/global`; - urls.policies = `${urls.globalScope}/policies`; + urls.policies = '/scopes/global/policies'; getPolicyCount = () => this.server.schema.policies.all().models.length; }); @@ -77,7 +77,6 @@ module('Unit | Controller | scopes/scope/policies/index', function (hooks) { }); test('delete action destroys specified model', async function (assert) { - await visit(urls.globalScope); const policy = await store.findRecord('policy', instances.policy.id); const policyCount = getPolicyCount(); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/policies/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/policies/new-test.js index 42c05d5398..6eab771463 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/policies/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/policies/new-test.js @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/policies/new', function (hooks) { test('it exists', function (assert) { let controller = this.owner.lookup('controller:scopes/scope/policies/new'); assert.ok(controller); + assert.ok(controller.policies); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/policies/policy/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/policies/policy/index-test.js index 43c2ade856..2ad58efa22 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/policies/policy/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/policies/policy/index-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/policies/policy/index', ); assert.ok(controller); + assert.ok(controller.policies); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js index 117f3bfc8f..3ee4b8beee 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/index-test.js @@ -41,10 +41,10 @@ module('Unit | Controller | scopes/scope/roles/index', function (hooks) { instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.role = this.server.create('role', { - scopeId: 'global', + scope: instances.scopes.global, }); instances.user = this.server.create('user', { - scopeId: 'global', + scope: instances.scopes.global, }); urls.globalScope = `/scopes/global`; diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/new-test.js index bac04d6933..2f80956479 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/new-test.js @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/roles/new', function (hooks) { test('it exists', function (assert) { let controller = this.owner.lookup('controller:scopes/scope/roles/new'); assert.ok(controller); + assert.ok(controller.roles); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js index eba139e058..8573d9f4df 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/add-principals-test.js @@ -29,7 +29,6 @@ module( }; const urls = { - globalScope: null, addPrincipals: null, }; @@ -56,8 +55,7 @@ module( scopeId: 'global', }); - urls.globalScope = `/scopes/global`; - urls.addPrincipals = `${urls.globalScope}/roles/${instances.role.id}/add-principals`; + urls.addPrincipals = `/scopes/global/roles/${instances.role.id}/add-principals`; }); test('it exists', function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js index e45ddb8caf..808b4b1c0d 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/grants-test.js @@ -24,7 +24,6 @@ module('Unit | Controller | scopes/scope/roles/role/grants', function (hooks) { }; const urls = { - globalScope: null, grants: null, }; @@ -35,15 +34,15 @@ module('Unit | Controller | scopes/scope/roles/role/grants', function (hooks) { instances.scopes.global = this.server.create('scope', { id: 'global' }); instances.role = this.server.create('role', { - scopeId: 'global', + scope: instances.scopes.global, }); - urls.globalScope = `/scopes/global`; - urls.grants = `${urls.globalScope}/roles/${instances.role.id}/grants`; + urls.grants = `/scopes/global/roles/${instances.role.id}/grants`; }); test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.roles); }); test('cancel action rolls-back changes on the specified model', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/index-test.js index 7e2678bc89..1ef089a84a 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/index-test.js @@ -14,5 +14,6 @@ module('Unit | Controller | scopes/scope/roles/role/index', function (hooks) { 'controller:scopes/scope/roles/role/index', ); assert.ok(controller); + assert.ok(controller.roles); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js index ac0501ad02..359c8215d4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-custom-scopes-test.js @@ -58,6 +58,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.manageScopes); }); test('handleSearchInput action sets expected values correctly', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js index 8e8402a193..5a923458d6 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/manage-scopes/manage-org-projects-test.js @@ -66,6 +66,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.manageScopes); }); test('handleSearchInput action sets expected values correctly', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/principals-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/principals-test.js index f26582f2c0..e2d2a13375 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/principals-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/principals-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/roles/role/principals', ); assert.ok(controller); + assert.ok(controller.roles); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js index 7a248819cf..8e3ce4eaf1 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/roles/role/scopes-test.js @@ -33,7 +33,6 @@ module('Unit | Controller | scopes/scope/roles/role/scopes', function (hooks) { }; const urls = { - globalScope: null, scopes: null, }; @@ -46,8 +45,7 @@ module('Unit | Controller | scopes/scope/roles/role/scopes', function (hooks) { scopeId: 'global', }); - urls.globalScope = `/scopes/global`; - urls.scopes = `${urls.globalScope}/roles/${instances.role.id}/scopes`; + urls.scopes = `/scopes/global/roles/${instances.role.id}/scopes`; }); test('it exists', function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index-test.js index bbaaf81e85..0f9632808b 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/session-recordings/session-recording/channels-by-connection/index-test.js @@ -48,6 +48,10 @@ module( this.server.schema.sessionRecordings.all().models.length; }); + test('it exists', function (assert) { + assert.ok(controller); + }); + test('isSessionInprogressWithNoConnections returns true if session has started with no connections', function (assert) { const sessionRecording = store.createRecord('session-recording', { state: STATE_SESSION_RECORDING_STARTED, diff --git a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js index 345c4467ce..3772353570 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/index-test.js @@ -4,19 +4,96 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; +import { visit } from '@ember/test-helpers'; +import setupMirage from 'ember-cli-mirage/test-support/setup-mirage'; +import { setupIndexedDb } from 'api/test-support/helpers/indexed-db'; +import { setupIntl } from 'ember-intl/test-support'; +import { authenticateSession } from 'ember-simple-auth/test-support'; module( 'Unit | Controller | scopes/scope/storage-buckets/index', function (hooks) { setupTest(hooks); + setupMirage(hooks); + setupIndexedDb(hooks); + setupIntl(hooks, 'en-us'); - // TODO: Replace this with your real tests. - test('it exists', function (assert) { - let controller = this.owner.lookup( + let store; + let controller; + let getStorageBucketCount; + + const instances = { + scopes: { + global: null, + }, + storageBucket: null, + }; + + const urls = { + storageBuckets: null, + }; + + hooks.beforeEach(function () { + authenticateSession({}); + store = this.owner.lookup('service:store'); + controller = this.owner.lookup( 'controller:scopes/scope/storage-buckets/index', ); + + instances.scopes.global = this.server.create('scope', { id: 'global' }); + instances.storageBucket = this.server.create('storage-bucket', { + scope: instances.scopes.global, + }); + + urls.storageBuckets = '/scopes/global/storage-buckets'; + + getStorageBucketCount = () => + this.server.schema.storageBuckets.all().models.length; + }); + + test('it exists', function (assert) { assert.ok(controller); }); + + test('cancel action rolls-back changes on the specified model', async function (assert) { + await visit(urls.storageBuckets); + const storageBucket = await store.findRecord( + 'storage-bucket', + instances.storageBucket.id, + ); + storageBucket.name = 'test'; + + assert.strictEqual(storageBucket.name, 'test'); + + await controller.cancel(storageBucket); + + assert.notEqual(storageBucket.name, 'test'); + }); + + test('save action saves changes on the specified model', async function (assert) { + await visit(urls.storageBuckets); + const storageBucket = await store.findRecord( + 'storage-bucket', + instances.storageBucket.id, + ); + storageBucket.name = 'test'; + + await controller.save(storageBucket); + + assert.strictEqual(storageBucket.name, 'test'); + }); + + test('delete action destroys specified model', async function (assert) { + const storageBucket = await store.findRecord( + 'storage-bucket', + instances.storageBucket.id, + ); + const storageBucketCount = getStorageBucketCount(); + + await controller.delete(storageBucket); + + assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1); + }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/new-test.js index 071cb00507..268c5fe486 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/new-test.js @@ -4,19 +4,19 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module( 'Unit | Controller | scopes/scope/storage-buckets/new', function (hooks) { setupTest(hooks); - // TODO: Replace this with your real tests. test('it exists', function (assert) { let controller = this.owner.lookup( 'controller:scopes/scope/storage-buckets/new', ); assert.ok(controller); + assert.ok(controller.storageBuckets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/storage-bucket/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/storage-bucket/index-test.js index e4df6d8f87..b7a49b59cd 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/storage-bucket/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/storage-buckets/storage-bucket/index-test.js @@ -4,19 +4,19 @@ */ import { module, test } from 'qunit'; -import { setupTest } from 'admin/tests/helpers'; +import { setupTest } from 'ember-qunit'; module( 'Unit | Controller | scopes/scope/storage-buckets/storage-bucket/index', function (hooks) { setupTest(hooks); - // TODO: Replace this with your real tests. test('it exists', function (assert) { let controller = this.owner.lookup( 'controller:scopes/scope/storage-buckets/storage-bucket/index', ); assert.ok(controller); + assert.ok(controller.storageBuckets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/new-test.js index a95dce4558..3a848dc333 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/new-test.js @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/targets/new', function (hooks) { test('it exists', function (assert) { const controller = this.owner.lookup('controller:scopes/scope/targets/new'); assert.ok(controller); + assert.ok(controller.targets); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/brokered-credential-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/brokered-credential-sources-test.js index 856dd4bc9c..fe1ee3fbf0 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/brokered-credential-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/brokered-credential-sources-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/brokered-credential-sources', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/create-alias-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/create-alias-test.js index 1499ca1184..b11d6eb757 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/create-alias-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/create-alias-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/create-alias', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-egress-worker-filter-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-egress-worker-filter-test.js index ed1d99926c..5e2e1baf20 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-egress-worker-filter-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-egress-worker-filter-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/edit-egress-worker-filter', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-ingress-worker-filter-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-ingress-worker-filter-test.js index fa3c70efa4..004e0c459c 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-ingress-worker-filter-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/edit-ingress-worker-filter-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/edit-ingress-worker-filter', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js index 12f4809875..5786fcba3e 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/create-storage-bucket-test.js @@ -62,6 +62,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.storageBuckets); }); test('cancel action rolls-back changes on the specified model', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js index edbd9bfd54..4f34bc50fb 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/enable-session-recording/index-test.js @@ -58,6 +58,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.targets); }); test('cancel action rolls-back changes on the specified model', async function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/host-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/host-sources-test.js index 0cc04e5998..96f5d8e456 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/host-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/host-sources-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/host-sources', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/injected-application-credential-sources-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/injected-application-credential-sources-test.js index 47b3fd4558..bbb8d20b67 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/injected-application-credential-sources-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/injected-application-credential-sources-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/injected-application-credential-sources', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/manage-alias-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/manage-alias-test.js index 787c37677c..630b831a72 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/manage-alias-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/manage-alias-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/manage-alias', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/workers-test.js b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/workers-test.js index 1735ecc8bf..b31fc9686c 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/targets/target/workers-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/targets/target/workers-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/targets/target/workers', ); assert.ok(controller); + assert.ok(controller.targets); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js index 83ee6a4cbd..d4228b47fb 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/index-test.js @@ -30,7 +30,6 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { }; const urls = { - globalScope: null, users: null, }; @@ -47,8 +46,7 @@ module('Unit | Controller | scopes/scope/users/index', function (hooks) { scope: instances.scopes.global, }); - urls.globalScope = `/scopes/global`; - urls.users = `${urls.globalScope}/users`; + urls.users = '/scopes/global/users'; getUserCount = () => this.server.schema.users.all().models.length; }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/new-test.js index 74888284c3..8b7ef44a99 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/new-test.js @@ -12,5 +12,6 @@ module('Unit | Controller | scopes/scope/users/new', function (hooks) { test('it exists', function (assert) { let controller = this.owner.lookup('controller:scopes/scope/users/new'); assert.ok(controller); + assert.ok(controller.users); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/user/accounts-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/user/accounts-test.js index c33064fd4d..5640f0e9cd 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/user/accounts-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/user/accounts-test.js @@ -16,6 +16,7 @@ module( 'controller:scopes/scope/users/user/accounts', ); assert.ok(controller); + assert.ok(controller.users); }); }, ); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/users/user/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/users/user/index-test.js index 1f2d3c1d31..d4e2c502b4 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/users/user/index-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/users/user/index-test.js @@ -14,5 +14,6 @@ module('Unit | Controller | scopes/scope/users/user/index', function (hooks) { 'controller:scopes/scope/users/user/index', ); assert.ok(controller); + assert.ok(controller.users); }); }); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js index 730124b0b8..a033e6940b 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/new-test.js @@ -24,7 +24,6 @@ module('Unit | Controller | scopes/scope/workers/new', function (hooks) { }; const urls = { - globalScope: null, workers: null, }; @@ -38,8 +37,7 @@ module('Unit | Controller | scopes/scope/workers/new', function (hooks) { scope: instances.scopes.global, }); - urls.globalScope = `/scopes/global`; - urls.workers = `${urls.globalScope}/workers`; + urls.workers = '/scopes/global/workers'; }); test('it exists', function (assert) { diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/index-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/index-test.js new file mode 100644 index 0000000000..97876d63d5 --- /dev/null +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/index-test.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module( + 'Unit | Controller | scopes/scope/workers/worker/index', + function (hooks) { + setupTest(hooks); + + test('it exists', function (assert) { + let controller = this.owner.lookup( + 'controller:scopes/scope/workers/worker/index', + ); + assert.ok(controller); + assert.ok(controller.workers); + }); + }, +); diff --git a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js index 556c4d27eb..f75e28a438 100644 --- a/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js +++ b/ui/admin/tests/unit/controllers/scopes/scope/workers/worker/tags-test.js @@ -52,6 +52,7 @@ module( test('it exists', function (assert) { assert.ok(controller); + assert.ok(controller.workers); }); test('tagDisplayName returns the display name of the tag', function (assert) { diff --git a/ui/desktop/tests/unit/controllers/application-test.js b/ui/desktop/tests/unit/controllers/application-test.js index 2c5ef8593c..651ba7f346 100644 --- a/ui/desktop/tests/unit/controllers/application-test.js +++ b/ui/desktop/tests/unit/controllers/application-test.js @@ -44,6 +44,14 @@ module('Unit | Controller | application', function (hooks) { assert.false(session.isAuthenticated); }); + test('toggleTheme action sets theme to specified value', function (assert) { + assert.notOk(session.data.theme); + + controller.toggleTheme('light'); + + assert.strictEqual(session.data.theme, 'light'); + }); + test('disconnect action de-authenticates a user and resets cluster url', async function (assert) { const url = 'http://localhost:9200'; await clusterUrl.setClusterUrl(url);