test: 💍 add test

This commit is contained in:
dharini committed 2021-08-26 00:02:57 -07:00
1 parent b0326e0c99
commit b5fdb850f6
2 files changed
+30 -12

No files matched your search

@@ -14,14 +14,12 @@ 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',
{
@@ -58,7 +56,9 @@ module('Acceptance | users | create', function (hooks) {
assert.expect(2);
orgScope.authorized_collection_actions.users = [];
await visit(orgURL);
assert.notOk(orgScope.authorized_collection_actions.users.includes('create'));
assert.notOk(
orgScope.authorized_collection_actions.users.includes('create')
);
assert.notOk(find(`[href="${orgURL}/users"]`));
});
+27 -9
View File
@@ -1,8 +1,7 @@
import { module, test } from 'qunit';
import { visit, currentURL, find } from '@ember/test-helpers';
import { visit, 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.
@@ -13,25 +12,33 @@ import {
module('Acceptance | users | list', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
let usersURL;
let orgScope;
let orgURL;
const instances = {
scopes: {
global: null,
org: null,
}
},
};
const urls = {
scopes: {
org: null
org: null,
},
users: null
users: null,
};
hooks.beforeEach(function () {
instances.scopes.global = this.server.create('scope', { id: 'global' });
orgScope = this.server.create(
'scope',
{
type: 'org',
scope: { id: 'global', type: 'global' },
},
'withChildren'
);
instances.org = this.server.create(
'scope',
{
@@ -43,15 +50,26 @@ module('Acceptance | users | list', function (hooks) {
instances.user = this.server.create('user', {
scope: instances.org,
});
orgURL = `/scopes/${orgScope.id}`;
urls.users = `/scopes/${instances.org.id}/users`;
authenticateSession({});
});
test('can navigate to users with proper authorization', async function (assert) {
// TODO
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 users with proper authorization', async function (assert) {
// TODO
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"]`));
});
});