chore: 🤖 merge main + resolve conflicts
This commit is contained in:
commit
10fb5c8265
20 files changed
+608
-137
No files matched your search
+58
-54
@@ -2,7 +2,6 @@ import { module, test } from 'qunit';
|
||||
import { visit, currentURL, click, find, fillIn } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import a11yAudit from 'ember-a11y-testing/test-support/audit';
|
||||
import { Response } from 'miragejs';
|
||||
import {
|
||||
authenticateSession,
|
||||
@@ -12,7 +11,7 @@ import {
|
||||
} from 'ember-simple-auth/test-support';
|
||||
import { enableFeature } from 'ember-feature-flags/test-support';
|
||||
|
||||
module('Acceptance | auth methods', function (hooks) {
|
||||
module('Acceptance | auth-methods | create ', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -20,9 +19,12 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
authMethod: null,
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
authMethods: null,
|
||||
@@ -31,58 +33,33 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Setup Mirage mock resources for this test
|
||||
authenticateSession({});
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.orgScope.id, type: instances.orgScope.type },
|
||||
});
|
||||
|
||||
instances.authMethod = this.server.create('auth-method', {
|
||||
scope: instances.scopes.org,
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
|
||||
// Generate route URLs for resources
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}`;
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}`;
|
||||
urls.authMethods = `${urls.orgScope}/auth-methods`;
|
||||
urls.newAuthMethod = `${urls.authMethods}/new?type=password`;
|
||||
urls.authMethod = `${urls.authMethods}/${instances.authMethod.id}`;
|
||||
});
|
||||
|
||||
test('visiting auth methods', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.authMethods);
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.authMethods);
|
||||
});
|
||||
|
||||
test('can navigate to an auth method form', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.authMethods);
|
||||
await click('main tbody .rose-table-header-cell:nth-child(1) a');
|
||||
await a11yAudit();
|
||||
assert.equal(currentURL(), urls.authMethod);
|
||||
});
|
||||
|
||||
test('can update an auth method and save changes', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.authMethod);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'update name');
|
||||
await click('form [type="submit"]:not(:disabled)');
|
||||
assert.equal(this.server.db.authMethods[0].name, 'update name');
|
||||
});
|
||||
|
||||
test('can update an auth method and cancel changes', async function (assert) {
|
||||
assert.expect(1);
|
||||
await visit(urls.authMethod);
|
||||
await click('form [type="button"]', 'Activate edit mode');
|
||||
await fillIn('[name="name"]', 'update name');
|
||||
await click('form button:not([type="submit"])');
|
||||
assert.notEqual(this.server.db.authMethods[0].name, 'update name');
|
||||
});
|
||||
|
||||
test('can create new auth method', async function (assert) {
|
||||
test('Users can create new auth method', async function (assert) {
|
||||
assert.expect(1);
|
||||
const authMethodsCount = this.server.db.authMethods.length;
|
||||
await visit(urls.newAuthMethod);
|
||||
@@ -92,6 +69,33 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
assert.equal(this.server.db.authMethods.length, authMethodsCount + 1);
|
||||
});
|
||||
|
||||
test('Users can navigate to new auth-methods route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'] = [
|
||||
'create',
|
||||
'list',
|
||||
];
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.authMethods}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new auth-methods route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'] = [];
|
||||
await visit(urls.orgScope);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.authMethods}"]`));
|
||||
});
|
||||
|
||||
test('can cancel new auth method creation', async function (assert) {
|
||||
assert.expect(2);
|
||||
const authMethodsCount = this.server.db.authMethods.length;
|
||||
@@ -106,7 +110,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
test('user can make primary an auth method', async function (assert) {
|
||||
assert.expect(2);
|
||||
assert.notOk(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
instances.orgScope.primaryAuthMethodId,
|
||||
'Primary auth method is not yet set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
@@ -114,7 +118,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
await click(
|
||||
'.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
const scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
const scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
assert.equal(
|
||||
scope.primaryAuthMethodId,
|
||||
instances.authMethod.id,
|
||||
@@ -136,7 +140,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
);
|
||||
});
|
||||
assert.notOk(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
instances.orgScope.primaryAuthMethodId,
|
||||
'Primary auth method is not yet set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
@@ -149,11 +153,11 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
|
||||
test('user can remove as primary an auth method', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.org.update({
|
||||
instances.orgScope.update({
|
||||
primaryAuthMethodId: instances.authMethod.id,
|
||||
});
|
||||
assert.ok(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
instances.orgScope.primaryAuthMethodId,
|
||||
'Primary auth method is set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
@@ -161,7 +165,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
await click(
|
||||
'.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
const scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
const scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
||||
});
|
||||
|
||||
@@ -178,11 +182,11 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
}
|
||||
);
|
||||
});
|
||||
instances.scopes.org.update({
|
||||
instances.orgScope.update({
|
||||
primaryAuthMethodId: instances.authMethod.id,
|
||||
});
|
||||
assert.ok(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
instances.orgScope.primaryAuthMethodId,
|
||||
'Primary auth method is set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
@@ -196,7 +200,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
test('user can make and remove primary auth methods from index', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.notOk(
|
||||
instances.scopes.org.primaryAuthMethodId,
|
||||
instances.orgScope.primaryAuthMethodId,
|
||||
'Primary auth method is not yet set.'
|
||||
);
|
||||
enableFeature('primary-auth-method');
|
||||
@@ -204,7 +208,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
await click(
|
||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
let scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
let scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
assert.equal(
|
||||
scope.primaryAuthMethodId,
|
||||
instances.authMethod.id,
|
||||
@@ -213,7 +217,7 @@ module('Acceptance | auth methods', function (hooks) {
|
||||
await click(
|
||||
'.rose-table-body .rose-table-row:first-child .rose-dropdown-content [type="button"]:first-child'
|
||||
);
|
||||
scope = this.server.schema.scopes.find(instances.scopes.org.id);
|
||||
scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | auth-methods | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
},
|
||||
authMethods: null,
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}`;
|
||||
urls.authMethods = `/scopes/${instances.orgScope.id}/auth-methods`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can navigate to auth methods with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.authMethods}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'] = [];
|
||||
await visit(urls.orgScope);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'].includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.authMethods}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.orgScope.authorized_collection_actions['auth-methods'] = [
|
||||
'create',
|
||||
];
|
||||
await visit(urls.orgScope);
|
||||
assert.ok(find(`[href="${urls.authMethods}"]`));
|
||||
});
|
||||
});
|
||||
+40
-5
@@ -10,7 +10,7 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | host-catalogs', function (hooks) {
|
||||
module('Acceptance | host-catalogs | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -22,6 +22,7 @@ module('Acceptance | host-catalogs', function (hooks) {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
@@ -35,6 +36,14 @@ module('Acceptance | host-catalogs', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
@@ -46,21 +55,23 @@ module('Acceptance | host-catalogs', function (hooks) {
|
||||
instances.hostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.hostCatalogs = `${urls.projectScope}/host-catalogs`;
|
||||
|
||||
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
|
||||
urls.unknownHostCatalog = `${urls.hostCatalogs}/foo`;
|
||||
urls.newHostCatalog = `${urls.hostCatalogs}/new`;
|
||||
// Generate resource couner
|
||||
gethostCatalogCount = () =>
|
||||
this.server.schema.hostCatalogs.all().models.length;
|
||||
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can create new host catalogs', async function (assert) {
|
||||
test('Users can create new host catalogs', async function (assert) {
|
||||
assert.expect(1);
|
||||
const count = gethostCatalogCount();
|
||||
await visit(urls.newHostCatalog);
|
||||
@@ -69,7 +80,7 @@ module('Acceptance | host-catalogs', function (hooks) {
|
||||
assert.equal(gethostCatalogCount(), count + 1);
|
||||
});
|
||||
|
||||
test('can cancel create new host catalogs', async function (assert) {
|
||||
test('Users can cancel create new host catalogs', async function (assert) {
|
||||
assert.expect(2);
|
||||
const count = gethostCatalogCount();
|
||||
await visit(urls.newHostCatalog);
|
||||
@@ -79,6 +90,30 @@ module('Acceptance | host-catalogs', function (hooks) {
|
||||
assert.equal(gethostCatalogCount(), count);
|
||||
});
|
||||
|
||||
test('Users can navigate to new host catalogs route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(
|
||||
instances.scopes.project.authorized_collection_actions[
|
||||
'host-catalogs'
|
||||
].includes('create')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.hostCatalogs}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new host catalogs route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions['host-catalogs'] =
|
||||
[];
|
||||
await visit(urls.projectScope);
|
||||
assert.notOk(
|
||||
instances.scopes.project.authorized_collection_actions[
|
||||
'host-catalogs'
|
||||
].includes('create')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.hostCatalogs}"]`));
|
||||
});
|
||||
|
||||
test('saving a new host catalog with invalid fields displays error messages', async function (assert) {
|
||||
assert.expect(2);
|
||||
this.server.post('/host-catalogs', () => {
|
||||
@@ -0,0 +1,97 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | host-catalogs | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
},
|
||||
projectScope: null,
|
||||
hostCatalogs: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
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.hostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
|
||||
urls.hostCatalogs = `/scopes/${instances.orgScope.id}/host-catalogs`;
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.orgScope.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.hostCatalogs = `${urls.projectScope}/host-catalogs`;
|
||||
|
||||
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can navigate to host catalogs with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(
|
||||
instances.scopes.project.authorized_collection_actions[
|
||||
'host-catalogs'
|
||||
].includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.hostCatalogs}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions['host-catalogs'] =
|
||||
[];
|
||||
await visit(urls.projectScope);
|
||||
assert.notOk(
|
||||
instances.scopes.project.authorized_collection_actions[
|
||||
'host-catalogs'
|
||||
].includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.hostCatalogs}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.scopes.project.authorized_collection_actions['host-catalogs'] = [
|
||||
'create',
|
||||
];
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(find(`[href="${urls.hostCatalogs}"]`));
|
||||
});
|
||||
});
|
||||
@@ -15,13 +15,13 @@ import {
|
||||
module('Acceptance | sessions', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
sessions: null,
|
||||
orgScope: null,
|
||||
};
|
||||
const urls = {
|
||||
orgScope: null,
|
||||
@@ -31,6 +31,14 @@ module('Acceptance | sessions', function (hooks) {
|
||||
hooks.beforeEach(function () {
|
||||
authenticateSession({});
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
@@ -66,6 +74,7 @@ module('Acceptance | sessions', function (hooks) {
|
||||
},
|
||||
'withAssociations'
|
||||
);
|
||||
urls.orgScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.sessions = `/scopes/${instances.scopes.project.id}/sessions`;
|
||||
});
|
||||
|
||||
@@ -81,6 +90,38 @@ module('Acceptance | sessions', function (hooks) {
|
||||
await visit(urls.sessions);
|
||||
});
|
||||
|
||||
test('Users cannot navigate to sessions without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions.sessions = [];
|
||||
authenticateSession({});
|
||||
later(async () => {
|
||||
run.cancelTimers();
|
||||
assert.notOk(
|
||||
instances.scopes.project.authorized_collection_actions.sessions.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.sessions}"]`));
|
||||
}, 750);
|
||||
await visit(urls.orgScope);
|
||||
});
|
||||
|
||||
test('Users can navigate to sessions with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions.sessions = ['list'];
|
||||
authenticateSession({});
|
||||
later(async () => {
|
||||
run.cancelTimers();
|
||||
assert.ok(
|
||||
instances.scopes.project.authorized_collection_actions.sessions.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.sessions}"]`));
|
||||
}, 750);
|
||||
await visit(urls.orgScope);
|
||||
});
|
||||
|
||||
test('visiting sessions without users or targets is OK', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.sessions[0].update({
|
||||
|
||||
+24
-2
@@ -10,7 +10,7 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | targets', function (hooks) {
|
||||
module('Acceptance | targets | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -33,7 +33,6 @@ module('Acceptance | targets', function (hooks) {
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.scopes.org = this.server.create('scope', {
|
||||
type: 'org',
|
||||
@@ -68,6 +67,29 @@ module('Acceptance | targets', function (hooks) {
|
||||
assert.equal(getTargetCount(), count + 1);
|
||||
});
|
||||
|
||||
test('can navigate to new targets route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.targets}"]`));
|
||||
});
|
||||
|
||||
test('cannot navigate to new targets route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions.targets = [];
|
||||
await visit(urls.projectScope);
|
||||
assert.notOk(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.targets}"]`));
|
||||
});
|
||||
|
||||
test('can cancel create new targets', async function (assert) {
|
||||
assert.expect(2);
|
||||
const count = getTargetCount();
|
||||
@@ -0,0 +1,84 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'ember-qunit';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import {
|
||||
authenticateSession,
|
||||
// These are left here intentionally for future reference.
|
||||
//currentSession,
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | targets | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
scopes: {
|
||||
org: null,
|
||||
project: null,
|
||||
},
|
||||
targets: null,
|
||||
projectScope: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.scopes.project = this.server.create('scope', {
|
||||
type: 'project',
|
||||
scope: { id: instances.orgScope.id, type: 'org' },
|
||||
});
|
||||
instances.target = this.server.create('target', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.targets = `${urls.projectScope}/targets`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can navigate to targets with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.targets}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.scopes.project.authorized_collection_actions.targets = [];
|
||||
await visit(urls.projectScope);
|
||||
assert.notOk(
|
||||
instances.scopes.project.authorized_collection_actions.targets.includes(
|
||||
'list'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.targets}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.scopes.project.authorized_collection_actions.targets = ['create'];
|
||||
await visit(urls.projectScope);
|
||||
assert.ok(find(`[href="${urls.targets}"]`));
|
||||
});
|
||||
});
|
||||
@@ -45,14 +45,14 @@ module('Acceptance | users | create', function (hooks) {
|
||||
assert.equal(this.server.db.users.length, usersCount + 1);
|
||||
});
|
||||
|
||||
test('can navigate to new users route with proper authorization', async function (assert) {
|
||||
test('Users can navigate to new users route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(orgScope.authorized_collection_actions.users.includes('create'));
|
||||
assert.ok(find(`[href="${orgURL}/users"]`));
|
||||
});
|
||||
|
||||
test('cannot navigate to new users route without proper authorization', async function (assert) {
|
||||
test('Users cannot navigate to new users route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
orgScope.authorized_collection_actions.users = [];
|
||||
await visit(orgURL);
|
||||
|
||||
@@ -47,7 +47,7 @@ module('Acceptance | users | list', function (hooks) {
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
test('can navigate to users with proper authorization', async function (assert) {
|
||||
test('Users can navigate to users with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
|
||||
Reference in new issue
Block a user