diff --git a/ui/admin/app/templates/scopes/scope.hbs b/ui/admin/app/templates/scopes/scope.hbs index 65e456c51..fd768111d 100644 --- a/ui/admin/app/templates/scopes/scope.hbs +++ b/ui/admin/app/templates/scopes/scope.hbs @@ -98,10 +98,12 @@ {{t 'resources.user.title_plural'}} - - - {{t 'resources.group.title_plural'}} - + {{#if (can 'navigate collection' @model collection='groups')}} + + + {{t 'resources.group.title_plural'}} + + {{/if}} {{t 'resources.role.title_plural'}} diff --git a/ui/admin/tests/acceptance/groups/create-test.js b/ui/admin/tests/acceptance/group-create-test.js similarity index 86% rename from ui/admin/tests/acceptance/groups/create-test.js rename to ui/admin/tests/acceptance/group-create-test.js index 291222647..616ce66b4 100644 --- a/ui/admin/tests/acceptance/groups/create-test.js +++ b/ui/admin/tests/acceptance/group-create-test.js @@ -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; diff --git a/ui/admin/tests/acceptance/groups/delete-test.js b/ui/admin/tests/acceptance/groups/delete-test.js index ed9838d24..c1dec7fdb 100644 --- a/ui/admin/tests/acceptance/groups/delete-test.js +++ b/ui/admin/tests/acceptance/groups/delete-test.js @@ -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'; diff --git a/ui/admin/tests/acceptance/groups/list-test.js b/ui/admin/tests/acceptance/groups/list-test.js index 988136963..fd93645a7 100644 --- a/ui/admin/tests/acceptance/groups/list-test.js +++ b/ui/admin/tests/acceptance/groups/list-test.js @@ -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}"]`)); }); });