feat: 🎸 hosts capabilities create lit
This commit is contained in:
1 parent
144c7d13ee
commit
451c1e861b
8 files changed
+197
-19
No files matched your search
+35
-1
@@ -10,7 +10,7 @@ import {
|
||||
//invalidateSession,
|
||||
} from 'ember-simple-auth/test-support';
|
||||
|
||||
module('Acceptance | host-catalogs | hosts', function (hooks) {
|
||||
module('Acceptance | host-catalogs | hosts | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
@@ -79,6 +79,40 @@ module('Acceptance | host-catalogs | hosts', function (hooks) {
|
||||
assert.equal(getHostCount(), count + 1);
|
||||
});
|
||||
|
||||
test('Users cannot create a new host without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = [];
|
||||
await visit(urls.hostCatalog);
|
||||
assert.notOk(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`.rose-layout-page-actions [href="${urls.newHost}"]`));
|
||||
});
|
||||
test('Users can navigate to new host catalogs route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.hostCatalog);
|
||||
assert.ok(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.ok(find(`[href="${urls.hosts}"]`));
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new host catalogs route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = [];
|
||||
await visit(urls.hostCatalog);
|
||||
assert.notOk(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'create'
|
||||
)
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.hosts}"]`));
|
||||
});
|
||||
|
||||
test('can cancel create new host', async function (assert) {
|
||||
assert.expect(2);
|
||||
const count = getHostCount();
|
||||
@@ -0,0 +1,92 @@
|
||||
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 | hosts | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
project: null,
|
||||
hostCatalog: null,
|
||||
host: null,
|
||||
},
|
||||
};
|
||||
const urls = {
|
||||
globalScope: null,
|
||||
orgScope: null,
|
||||
projectScope: null,
|
||||
hostCatalogs: null,
|
||||
hostCatalog: null,
|
||||
hosts: null,
|
||||
host: null,
|
||||
unknownHost: null,
|
||||
newHost: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
// Generate resources
|
||||
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.hostCatalog = this.server.create('host-catalog', {
|
||||
scope: instances.scopes.project,
|
||||
});
|
||||
instances.host = this.server.create('host', {
|
||||
scope: instances.scopes.project,
|
||||
hostCatalog: instances.hostCatalog,
|
||||
});
|
||||
// Generate route URLs for resources
|
||||
urls.globalScope = `/scopes/global/scopes`;
|
||||
urls.orgScope = `/scopes/${instances.scopes.org.id}/scopes`;
|
||||
urls.projectScope = `/scopes/${instances.scopes.project.id}`;
|
||||
urls.hostCatalogs = `${urls.projectScope}/host-catalogs`;
|
||||
urls.hostCatalog = `${urls.hostCatalogs}/${instances.hostCatalog.id}`;
|
||||
urls.hosts = `${urls.hostCatalog}/hosts`;
|
||||
urls.host = `${urls.hosts}/${instances.host.id}`;
|
||||
urls.unknownHost = `${urls.hosts}/foo`;
|
||||
urls.newHost = `${urls.hosts}/new`;
|
||||
authenticateSession({});
|
||||
});
|
||||
test('Users can navigate to hosts with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(urls.hostCatalog);
|
||||
assert.ok(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.hosts}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = [];
|
||||
await visit(urls.hostCatalog);
|
||||
assert.notOk(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.hosts}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = ['create'];
|
||||
await visit(urls.hostCatalog);
|
||||
assert.ok(find(`[href="${urls.hosts}"]`));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user