refactor: 💡 remove route-action usage for targets (#2297)
* refactor: 💡 remove route-action usage for targets ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12611
This commit is contained in:
1 parent
fc82980d68
commit
2f6e36c035
51 files changed
+1133
-496
No files matched your search
@@ -5,14 +5,76 @@
|
||||
|
||||
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 { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import { TYPE_TARGET_TCP, TYPE_TARGET_SSH } from 'api/models/target';
|
||||
|
||||
module('Unit | Controller | scopes/scope/targets/index', function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
setupIndexedDb(hooks);
|
||||
|
||||
let store;
|
||||
let controller;
|
||||
let getTargetCount;
|
||||
let getAliasCount;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
hostSet: null,
|
||||
credential: null,
|
||||
alias: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
targets: null,
|
||||
alias: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup('controller:scopes/scope/targets/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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.hostSet = this.server.create('host-set', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.alias = this.server.create('alias', {
|
||||
scope: instances.scopes.global,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.targets = `${urls.projectScope}/targets`;
|
||||
urls.alias = `${urls.projectScope}/targets/${instances.target.id}/${instances.alias.id}`;
|
||||
|
||||
getTargetCount = () => this.server.schema.targets.all().models.length;
|
||||
getAliasCount = () => this.server.schema.aliases.all().models.length;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup('controller:scopes/scope/targets/index');
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
@@ -56,4 +118,146 @@ module('Unit | Controller | scopes/scope/targets/index', function (hooks) {
|
||||
assert.strictEqual(controller.page, 1);
|
||||
assert.deepEqual(controller.availableSessions, selectedItems);
|
||||
});
|
||||
|
||||
test('cancel action rolls-back changes on the specified model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
target.name = 'test';
|
||||
|
||||
assert.strictEqual(target.name, 'test');
|
||||
|
||||
await controller.cancel(target);
|
||||
|
||||
assert.notEqual(target.name, 'test');
|
||||
});
|
||||
|
||||
test('save action saves changes on the specified model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
target.name = 'test';
|
||||
|
||||
await controller.save(target);
|
||||
|
||||
assert.strictEqual(target.name, 'test');
|
||||
});
|
||||
|
||||
test('saveWithAddress action saves address and removes host sources on the specified model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
await target.addHostSources([instances.hostSet.id]);
|
||||
target.address = '127.0.0.1';
|
||||
|
||||
assert.deepEqual(target.host_sources, [
|
||||
{ host_source_id: instances.hostSet.id },
|
||||
]);
|
||||
|
||||
await controller.saveWithAddress(target);
|
||||
|
||||
assert.deepEqual(target.host_sources, []);
|
||||
assert.strictEqual(target.address, '127.0.0.1');
|
||||
});
|
||||
|
||||
test('delete action destroys specified model', async function (assert) {
|
||||
await visit(urls.projectScope);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
const targetCount = getTargetCount();
|
||||
|
||||
await controller.delete(target);
|
||||
|
||||
assert.strictEqual(getTargetCount(), targetCount - 1);
|
||||
});
|
||||
|
||||
test('removeHostSource action removes specified host-set from model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
await target.addHostSources([instances.hostSet.id]);
|
||||
|
||||
assert.deepEqual(target.host_sources, [
|
||||
{ host_source_id: instances.hostSet.id },
|
||||
]);
|
||||
|
||||
await controller.removeHostSource(target, instances.hostSet);
|
||||
|
||||
assert.deepEqual(target.host_sources, []);
|
||||
});
|
||||
|
||||
test('removeInjectedApplicationCredentialSource action removes specified credential from model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
await target.addInjectedApplicationCredentialSources([
|
||||
instances.credential.id,
|
||||
]);
|
||||
|
||||
assert.deepEqual(target.injected_application_credential_source_ids, [
|
||||
{ value: instances.credential.id },
|
||||
]);
|
||||
|
||||
await controller.removeInjectedApplicationCredentialSource(
|
||||
target,
|
||||
instances.credential,
|
||||
);
|
||||
|
||||
assert.deepEqual(target.injected_application_credential_source_ids, []);
|
||||
});
|
||||
|
||||
test('removeBrokeredCredentialSource action removes specified credential from model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
await target.addBrokeredCredentialSources([instances.credential.id]);
|
||||
|
||||
assert.deepEqual(target.brokered_credential_source_ids, [
|
||||
{ value: instances.credential.id },
|
||||
]);
|
||||
|
||||
await controller.removeBrokeredCredentialSource(
|
||||
target,
|
||||
instances.credential,
|
||||
);
|
||||
|
||||
assert.deepEqual(target.brokered_credential_source_ids, []);
|
||||
});
|
||||
|
||||
test('deleteAlias action destroys specified model', async function (assert) {
|
||||
await visit(urls.targets);
|
||||
const alias = await store.findRecord('alias', instances.alias.id);
|
||||
const aliasCount = getAliasCount();
|
||||
|
||||
await controller.deleteAlias(alias);
|
||||
|
||||
assert.strictEqual(getAliasCount(), aliasCount - 1);
|
||||
});
|
||||
|
||||
test('clearAlias action removes destination_id from model', async function (assert) {
|
||||
await visit(urls.alias);
|
||||
const alias = await store.findRecord('alias', instances.alias.id);
|
||||
alias.destination_id = 'www.test.com';
|
||||
|
||||
assert.strictEqual(alias.destination_id, 'www.test.com');
|
||||
|
||||
await controller.clearAlias(alias);
|
||||
|
||||
assert.notOk(alias.destination_id);
|
||||
});
|
||||
|
||||
test('saveAlias action saves changes on the specified model', async function (assert) {
|
||||
await visit(urls.alias);
|
||||
const alias = await store.findRecord('alias', instances.alias.id);
|
||||
alias.name = 'test';
|
||||
|
||||
await controller.saveAlias(alias);
|
||||
|
||||
assert.strictEqual(alias.name, 'test');
|
||||
});
|
||||
|
||||
test('cancelAlias action rolls-back changes on the specified model', async function (assert) {
|
||||
await visit(urls.alias);
|
||||
const alias = await store.findRecord('alias', instances.alias.id);
|
||||
alias.name = 'test';
|
||||
|
||||
assert.strictEqual(alias.name, 'test');
|
||||
|
||||
await controller.cancelAlias(alias);
|
||||
|
||||
assert.notEqual(alias.name, 'test');
|
||||
});
|
||||
});
|
||||
+71
-12
@@ -5,25 +5,68 @@
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { currentURL, visit } from '@ember/test-helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/add-brokered-credential-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
const controller = this.owner.lookup(
|
||||
let store;
|
||||
let controller;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
credential: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
addCredentialSources: null,
|
||||
credentialSources: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-brokered-credential-sources',
|
||||
);
|
||||
|
||||
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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.addCredentialSources = `${urls.projectScope}/targets/${instances.target.id}/add-brokered-credential-sources`;
|
||||
urls.credentialSources = `${urls.projectScope}/targets/${instances.target.id}/brokered-credential-sources`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('hasAvailableBrokeredCredentialSources returns true if target has available credentials', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-brokered-credential-sources',
|
||||
);
|
||||
|
||||
const target = store.createRecord('target', {
|
||||
brokered_credential_source_ids: [{ value: 'cred_123' }],
|
||||
});
|
||||
@@ -37,11 +80,6 @@ module(
|
||||
});
|
||||
|
||||
test('hasAvailableBrokeredCredentialSources returns false if target has no available credentials', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-brokered-credential-sources',
|
||||
);
|
||||
|
||||
const target = store.createRecord('target', {
|
||||
brokered_credential_source_ids: [{ value: 'cred_123' }],
|
||||
});
|
||||
@@ -53,5 +91,26 @@ module(
|
||||
|
||||
assert.false(controller.hasAvailableBrokeredCredentialSources);
|
||||
});
|
||||
|
||||
test('save action saves credential sources on the specified model', async function (assert) {
|
||||
await visit(urls.addCredentialSources);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
|
||||
assert.deepEqual(target.brokered_credential_source_ids, []);
|
||||
|
||||
await controller.save(target, [instances.credential.id]);
|
||||
|
||||
assert.deepEqual(target.brokered_credential_source_ids, [
|
||||
{ value: instances.credential.id },
|
||||
]);
|
||||
});
|
||||
|
||||
test('cancel action causes transition to expected route', async function (assert) {
|
||||
await visit(urls.addCredentialSources);
|
||||
|
||||
await controller.cancel();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credentialSources);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,85 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { currentURL, visit } from '@ember/test-helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/add-host-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let store;
|
||||
let controller;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
hostSet: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
addHostSources: null,
|
||||
hostSources: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-host-sources',
|
||||
);
|
||||
|
||||
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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.hostSet = this.server.create('host-set', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.addHostSources = `${urls.projectScope}/targets/${instances.target.id}/add-host-sources`;
|
||||
urls.hostSources = `${urls.projectScope}/targets/${instances.target.id}/host-sources`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('save action saves host sources on the specified model', async function (assert) {
|
||||
await visit(urls.addHostSources);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
|
||||
assert.deepEqual(target.host_sources, []);
|
||||
|
||||
await controller.save(target, [instances.hostSet.id]);
|
||||
|
||||
assert.deepEqual(target.host_sources, [
|
||||
{ host_source_id: instances.hostSet.id },
|
||||
]);
|
||||
});
|
||||
|
||||
test('cancel action causes transition to expected route', async function (assert) {
|
||||
await visit(urls.addHostSources);
|
||||
|
||||
await controller.cancel();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.hostSources);
|
||||
});
|
||||
},
|
||||
);
|
||||
+71
-12
@@ -5,25 +5,68 @@
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
import { currentURL, visit } from '@ember/test-helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/add-injected-application-credential-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
const controller = this.owner.lookup(
|
||||
let store;
|
||||
let controller;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
credential: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
addCredentialSources: null,
|
||||
credentialSources: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-injected-application-credential-sources',
|
||||
);
|
||||
|
||||
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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.credential = this.server.create('credential', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.addCredentialSources = `${urls.projectScope}/targets/${instances.target.id}/add-injected-application-credential-sources`;
|
||||
urls.credentialSources = `${urls.projectScope}/targets/${instances.target.id}/injected-application-credential-sources`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('hasAvailableInjectedApplicationCredentialSources returns true if target has available credentials', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-injected-application-credential-sources',
|
||||
);
|
||||
|
||||
const target = store.createRecord('target', {
|
||||
injected_application_credential_source_ids: [{ value: 'cred_123' }],
|
||||
});
|
||||
@@ -37,11 +80,6 @@ module(
|
||||
});
|
||||
|
||||
test('hasAvailableInjectedApplicationCredentialSources returns false if target has no available credentials', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/add-injected-application-credential-sources',
|
||||
);
|
||||
|
||||
const target = store.createRecord('target', {
|
||||
injected_application_credential_source_ids: [{ value: 'cred_123' }],
|
||||
});
|
||||
@@ -53,5 +91,26 @@ module(
|
||||
|
||||
assert.false(controller.hasAvailableInjectedApplicationCredentialSources);
|
||||
});
|
||||
|
||||
test('save action saves credential sources on the specified model', async function (assert) {
|
||||
await visit(urls.addCredentialSources);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
|
||||
assert.deepEqual(target.injected_application_credential_source_ids, []);
|
||||
|
||||
await controller.save(target, [instances.credential.id]);
|
||||
|
||||
assert.deepEqual(target.injected_application_credential_source_ids, [
|
||||
{ value: instances.credential.id },
|
||||
]);
|
||||
});
|
||||
|
||||
test('cancel action causes transition to expected route', async function (assert) {
|
||||
await visit(urls.addCredentialSources);
|
||||
|
||||
await controller.cancel();
|
||||
|
||||
assert.strictEqual(currentURL(), urls.credentialSources);
|
||||
});
|
||||
},
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/brokered-credential-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/brokered-credential-sources',
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/create-alias',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/create-alias',
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
},
|
||||
);
|
||||
+77
-4
@@ -4,19 +4,92 @@
|
||||
*/
|
||||
|
||||
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 { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/enable-session-recording/create-storage-bucket',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
// TODO: Replace this with your real tests.
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
let store;
|
||||
let controller;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
storageBucket: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
createStorageBucket: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/enable-session-recording/create-storage-bucket',
|
||||
);
|
||||
|
||||
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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.storageBucket = this.server.create('storage-bucket', {
|
||||
scope: instances.scopes.org,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.createStorageBucket = `${urls.projectScope}/targets/${instances.target.id}/enable-session-recording`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('cancel action rolls-back changes on the specified model', async function (assert) {
|
||||
await visit(urls.createStorageBucket);
|
||||
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.createStorageBucket);
|
||||
const storageBucket = await store.findRecord(
|
||||
'storage-bucket',
|
||||
instances.storageBucket.id,
|
||||
);
|
||||
storageBucket.name = 'test';
|
||||
|
||||
await controller.save(storageBucket);
|
||||
|
||||
assert.strictEqual(storageBucket.name, 'test');
|
||||
});
|
||||
},
|
||||
);
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
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';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/enable-session-recording/index',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let store;
|
||||
let controller;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
target: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
projectScope: null,
|
||||
enableSessionRecording: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
store = this.owner.lookup('service:store');
|
||||
controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/enable-session-recording/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.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.enableSessionRecording = `${urls.projectScope}/targets/${instances.target.id}/enable-session-recording`;
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(controller);
|
||||
});
|
||||
|
||||
test('cancel action rolls-back changes on the specified model', async function (assert) {
|
||||
await visit(urls.enableSessionRecording);
|
||||
const target = await store.findRecord('target', instances.target.id);
|
||||
target.enable_session_recording = 'true';
|
||||
|
||||
assert.strictEqual(target.enable_session_recording, 'true');
|
||||
|
||||
await controller.cancel(target);
|
||||
|
||||
assert.notEqual(target.enable_session_recording, 'true');
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/host-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/host-sources',
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
},
|
||||
);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/injected-application-credential-sources',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/injected-application-credential-sources',
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module(
|
||||
'Unit | Controller | scopes/scope/targets/target/manage-alias',
|
||||
function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let controller = this.owner.lookup(
|
||||
'controller:scopes/scope/targets/target/manage-alias',
|
||||
);
|
||||
assert.ok(controller);
|
||||
});
|
||||
},
|
||||
);
|
||||
Reference in new issue
Block a user