feat: 🎸 grp create/list

This commit is contained in:
dharini committed 2021-08-27 13:09:00 -07:00
1 parent b2f11f712b
commit 3a3fdf2396
4 files changed
+28 -37

No files matched your search

+6 -4
View File
@@ -98,10 +98,12 @@
<Rose::Icon @name='app-icons/users' @size='medium' />
{{t 'resources.user.title_plural'}}
</nav.link>
<nav.link @route='scopes.scope.groups'>
<Rose::Icon @name='app-icons/group' @size='medium' />
{{t 'resources.group.title_plural'}}
</nav.link>
{{#if (can 'navigate collection' @model collection='groups')}}
<nav.link @route='scopes.scope.groups'>
<Rose::Icon @name='app-icons/group' @size='medium' />
{{t 'resources.group.title_plural'}}
</nav.link>
{{/if}}
<nav.link @route='scopes.scope.roles'>
<Rose::Icon @name='app-icons/roles' @size='medium' />
{{t 'resources.role.title_plural'}}
@@ -13,7 +13,6 @@ import {
module('Acceptance | groups | create', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
const instances = {
scopes: {
global: null,
@@ -30,14 +29,6 @@ module('Acceptance | groups | create', function (hooks) {
hooks.beforeEach(function () {
authenticateSession({});
instances.scopes.global = this.server.create('scope', { id: 'global' });
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' },
@@ -59,13 +50,6 @@ module('Acceptance | groups | create', function (hooks) {
assert.equal(this.server.db.groups.length, groupsCount + 1);
});
test('cannot create new group without proper authorization', async function (assert) {
assert.expect(1);
orgScope.authorized_collection_actions.groups = ['list'];
await visit(urls.groups);
assert.notOk(find('.rose-layout-page-actions .rose-button-primary'));
});
test('can cancel new group creation', async function (assert) {
assert.expect(2);
const groupsCount = this.server.db.groups.length;
@@ -1,4 +1,4 @@
import { module, test } from 'qunit';
import { module, test } from 'qunit';
import { visit, click, find } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
+21 -16
View File
@@ -12,8 +12,8 @@ import {
module('Acceptance | groups | list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let orgScope;
let orgURL;
const instances = {
scopes: {
global: null,
@@ -31,7 +31,7 @@ module('Acceptance | groups | list', function (hooks) {
hooks.beforeEach(function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
orgScope = this.server.create(
urls.orgScope = this.server.create(
'scope',
{
type: 'org',
@@ -47,34 +47,39 @@ module('Acceptance | groups | list', function (hooks) {
},
'withChildren'
);
instances.scopes.org = this.server.create('scope', {
type: 'org',
scope: { id: 'global', type: 'global' },
});
instances.group = this.server.create('group', {
scope: instances.org,
});
urls.groups = `/scopes/${instances.scopes.org.id}/groups`;
orgURL = `/scopes/${orgScope.id}`;
orgURL = `/scopes/${urls.orgScope.id}`;
//urls.orgScope = `/scopes/${instances.org.id}/scopes`;
urls.groups = `/scopes/${urls.orgScope.id}/groups`;
authenticateSession({});
});
test('can navigate to groups with proper authorization', async function (assert) {
assert.expect(2);
orgScope.authorized_collection_actions.groups = ['list'];
await visit(orgURL);
assert.ok(orgScope.authorized_collection_actions.groups.includes('list'));
assert.ok(find(`[href="${orgURL}/groups"]`));
assert.ok(
urls.orgScope.authorized_collection_actions.groups.includes('list')
);
assert.ok(find(`[href="${urls.groups}"]`));
});
test('cannot navigate to groups without proper authorization', async function (assert) {
assert.expect(1);
orgScope.authorized_collection_actions.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 = [];
await visit(orgURL);
assert.notOk(
orgScope.authorized_collection_actions.groups.includes('list')
urls.orgScope.authorized_collection_actions.groups.includes('list')
);
//assert.notOk(find(`[href="${orgURL}/groups"]`));
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'];
await visit(orgURL);
assert.ok(find(`[href="${urls.groups}"]`));
});
});