Merge branch 'feature-user-collection-abilities' into feature-scope-capabilities

This commit is contained in:
Randall Morey committed 2021-08-30 17:24:08 -04:00
commit 064c857d20
10 files changed
+149 -18

No files matched your search

@@ -10,23 +10,28 @@ import {
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | users', function (hooks) {
module('Acceptance | users | create', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let globalScope;
let orgScope;
let orgURL;
let usersURL;
let newUserURL;
hooks.beforeEach(function () {
globalScope = this.server.create('scope', { id: 'global' });
orgScope = this.server.create(
'scope',
{
type: 'org',
scope: { id: 'global', type: 'global' },
},
'withChildren'
);
orgURL = `/scopes/${orgScope.id}`;
usersURL = `/scopes/${orgScope.id}/users`;
newUserURL = `${usersURL}/new`;
@@ -42,6 +47,21 @@ module('Acceptance | users', function (hooks) {
assert.equal(this.server.db.users.length, usersCount + 1);
});
test('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) {
assert.expect(2);
orgScope.authorized_collection_actions.users = [];
await visit(orgURL);
assert.notOk(orgScope.authorized_collection_actions.users.includes('create'));
assert.notOk(find(`[href="${orgURL}/users"]`));
});
test('can cancel creation of a new user', async function (assert) {
assert.expect(2);
const usersCount = this.server.db.users.length;
@@ -0,0 +1,57 @@
import { module, test } from 'qunit';
import { visit, currentURL, find } 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 {
authenticateSession,
// These are left here intentionally for future reference.
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
module('Acceptance | users | list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let usersURL;
const instances = {
scopes: {
global: null,
org: null,
}
};
const urls = {
scopes: {
org: null
},
users: null
};
hooks.beforeEach(function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.org = this.server.create(
'scope',
{
type: 'org',
scope: { id: 'global', type: 'global' },
},
'withChildren'
);
instances.user = this.server.create('user', {
scope: instances.org,
});
urls.users = `/scopes/${instances.org.id}/users`;
authenticateSession({});
});
test('can navigate to users with proper authorization', async function (assert) {
// TODO
});
test('cannot navigate to users with proper authorization', async function (assert) {
// TODO
});
});