From 350c4f5f70e2e4b67ee7df42506ce722557e1d56 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 27 Aug 2021 08:06:24 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/tests/acceptance/users/list-test.js | 30 +++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ui/admin/tests/acceptance/users/list-test.js b/ui/admin/tests/acceptance/users/list-test.js index 8e071febc..0d8aaa60e 100644 --- a/ui/admin/tests/acceptance/users/list-test.js +++ b/ui/admin/tests/acceptance/users/list-test.js @@ -12,7 +12,6 @@ import { module('Acceptance | users | list', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); - let orgScope; let orgURL; const instances = { @@ -27,11 +26,12 @@ module('Acceptance | users | list', function (hooks) { org: null, }, users: null, + orgScope: null, }; hooks.beforeEach(function () { instances.scopes.global = this.server.create('scope', { id: 'global' }); - orgScope = this.server.create( + urls.orgScope = this.server.create( 'scope', { type: 'org', @@ -50,26 +50,36 @@ module('Acceptance | users | list', function (hooks) { instances.user = this.server.create('user', { scope: instances.org, }); - orgURL = `/scopes/${orgScope.id}`; + orgURL = `/scopes/${urls.orgScope.id}`; + //urls.orgScope = `/scopes/${instances.org.id}/scopes`; - urls.users = `/scopes/${instances.org.id}/users`; + urls.users = `/scopes/${urls.orgScope.id}/users`; authenticateSession({}); }); test('can navigate to users 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"]`)); + assert.ok( + urls.orgScope.authorized_collection_actions.users.includes('list') + ); + assert.ok(find(`[href="${urls.users}"]`)); }); - test('cannot navigate to users with proper authorization', async function (assert) { + test('User cannot navigate to index without either list or create actions', async function (assert) { assert.expect(2); - orgScope.authorized_collection_actions.users = []; + urls.orgScope.authorized_collection_actions.users = []; await visit(orgURL); assert.notOk( - orgScope.authorized_collection_actions.users.includes('create') + urls.orgScope.authorized_collection_actions.users.includes('list') ); - assert.notOk(find(`[href="${orgURL}/users"]`)); + assert.notOk(find(`[href="${urls.usersorgURL}"]`)); + }); + + test('User can navigate to index with only create action', async function (assert) { + assert.expect(1); + urls.orgScope.authorized_collection_actions.users = ['create']; + await visit(orgURL); + assert.ok(find(`[href="${urls.users}"]`)); }); });