test: 💍 fix tests
This commit is contained in:
1 parent
3a3fdf2396
commit
e291956c1b
2 files changed
+41
-25
No files matched your search
+32
-7
@@ -13,12 +13,15 @@ import {
|
||||
module('Acceptance | groups | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
let orgURL;
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
group: null,
|
||||
orgScope: null,
|
||||
};
|
||||
const urls = {
|
||||
groups: null,
|
||||
@@ -28,17 +31,21 @@ module('Acceptance | groups | create', function (hooks) {
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
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.group = this.server.create('group', {
|
||||
scope: instances.scopes.org,
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
urls.groups = `/scopes/${instances.scopes.org.id}/groups`;
|
||||
urls.groups = `/scopes/${instances.orgScope.id}/groups`;
|
||||
urls.group = `${urls.groups}/${instances.group.id}`;
|
||||
urls.newGroup = `${urls.groups}/new`;
|
||||
orgURL = `/scopes/${instances.orgScope.id}`;
|
||||
});
|
||||
|
||||
test('can create new group', async function (assert) {
|
||||
@@ -50,6 +57,24 @@ module('Acceptance | groups | create', function (hooks) {
|
||||
assert.equal(this.server.db.groups.length, groupsCount + 1);
|
||||
});
|
||||
|
||||
test('can navigate to new groups route with proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('create')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('cannot navigate to new groups route without proper authorization', async function (assert) {
|
||||
assert.expect(2);
|
||||
instances.orgScope.authorized_collection_actions.groups = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('create')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
test('can cancel new group creation', async function (assert) {
|
||||
assert.expect(2);
|
||||
const groupsCount = this.server.db.groups.length;
|
||||
@@ -19,6 +19,7 @@ module('Acceptance | groups | list', function (hooks) {
|
||||
global: null,
|
||||
org: null,
|
||||
},
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
const urls = {
|
||||
@@ -26,20 +27,11 @@ module('Acceptance | groups | list', function (hooks) {
|
||||
org: null,
|
||||
},
|
||||
groups: null,
|
||||
orgScope: null,
|
||||
};
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
instances.scopes.global = this.server.create('scope', { id: 'global' });
|
||||
urls.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
scope: { id: 'global', type: 'global' },
|
||||
},
|
||||
'withChildren'
|
||||
);
|
||||
instances.org = this.server.create(
|
||||
instances.orgScope = this.server.create(
|
||||
'scope',
|
||||
{
|
||||
type: 'org',
|
||||
@@ -48,12 +40,11 @@ module('Acceptance | groups | list', function (hooks) {
|
||||
'withChildren'
|
||||
);
|
||||
instances.group = this.server.create('group', {
|
||||
scope: instances.org,
|
||||
scope: instances.orgScope,
|
||||
});
|
||||
orgURL = `/scopes/${urls.orgScope.id}`;
|
||||
//urls.orgScope = `/scopes/${instances.org.id}/scopes`;
|
||||
orgURL = `/scopes/${instances.orgScope.id}`;
|
||||
|
||||
urls.groups = `/scopes/${urls.orgScope.id}/groups`;
|
||||
urls.groups = `/scopes/${instances.orgScope.id}/groups`;
|
||||
authenticateSession({});
|
||||
});
|
||||
|
||||
@@ -61,24 +52,24 @@ module('Acceptance | groups | list', function (hooks) {
|
||||
assert.expect(2);
|
||||
await visit(orgURL);
|
||||
assert.ok(
|
||||
urls.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
assert.expect(2);
|
||||
urls.orgScope.authorized_collection_actions.groups = [];
|
||||
instances.orgScope.authorized_collection_actions.groups = [];
|
||||
await visit(orgURL);
|
||||
assert.notOk(
|
||||
urls.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
instances.orgScope.authorized_collection_actions.groups.includes('list')
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
assert.expect(1);
|
||||
urls.orgScope.authorized_collection_actions.groups = ['create'];
|
||||
instances.orgScope.authorized_collection_actions.groups = ['create'];
|
||||
await visit(orgURL);
|
||||
assert.ok(find(`[href="${urls.groups}"]`));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user