From b5fdb850f6a14f7077439cdb35684144eae9917d Mon Sep 17 00:00:00 2001 From: dharini Date: Thu, 26 Aug 2021 00:02:57 -0700 Subject: [PATCH 1/4] =?UTF-8?q?test:=20=F0=9F=92=8D=20add=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/acceptance/users/create-test.js | 6 ++-- ui/admin/tests/acceptance/users/list-test.js | 36 ++++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/ui/admin/tests/acceptance/users/create-test.js b/ui/admin/tests/acceptance/users/create-test.js index 069ca0102..fbff7fbee 100644 --- a/ui/admin/tests/acceptance/users/create-test.js +++ b/ui/admin/tests/acceptance/users/create-test.js @@ -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"]`)); }); diff --git a/ui/admin/tests/acceptance/users/list-test.js b/ui/admin/tests/acceptance/users/list-test.js index bf768b334..8e071febc 100644 --- a/ui/admin/tests/acceptance/users/list-test.js +++ b/ui/admin/tests/acceptance/users/list-test.js @@ -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"]`)); }); }); From 350c4f5f70e2e4b67ee7df42506ce722557e1d56 Mon Sep 17 00:00:00 2001 From: dharini Date: Fri, 27 Aug 2021 08:06:24 -0700 Subject: [PATCH 2/4] =?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}"]`)); }); }); From 40c2acd6ab476c3b5863d5cafe76c06d174c3318 Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Fri, 27 Aug 2021 10:17:34 -0700 Subject: [PATCH 3/4] Update list-test.js --- ui/admin/tests/acceptance/users/list-test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/admin/tests/acceptance/users/list-test.js b/ui/admin/tests/acceptance/users/list-test.js index 0d8aaa60e..d752d8687 100644 --- a/ui/admin/tests/acceptance/users/list-test.js +++ b/ui/admin/tests/acceptance/users/list-test.js @@ -51,8 +51,6 @@ module('Acceptance | users | list', function (hooks) { scope: instances.org, }); orgURL = `/scopes/${urls.orgScope.id}`; - //urls.orgScope = `/scopes/${instances.org.id}/scopes`; - urls.users = `/scopes/${urls.orgScope.id}/users`; authenticateSession({}); }); From ce286964d11a85d3d1305de598a6a65e28a2e04c Mon Sep 17 00:00:00 2001 From: dharini Date: Mon, 30 Aug 2021 21:49:48 -0700 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20tests=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/tests/acceptance/users/list-test.js | 28 +++++++------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/ui/admin/tests/acceptance/users/list-test.js b/ui/admin/tests/acceptance/users/list-test.js index d752d8687..72a6e35eb 100644 --- a/ui/admin/tests/acceptance/users/list-test.js +++ b/ui/admin/tests/acceptance/users/list-test.js @@ -19,6 +19,7 @@ module('Acceptance | users | list', function (hooks) { global: null, org: null, }, + orgScope: null, }; const urls = { @@ -26,20 +27,11 @@ module('Acceptance | users | list', function (hooks) { org: null, }, users: null, - orgScope: null, }; hooks.beforeEach(function () { instances.scopes.global = this.server.create('scope', { id: 'global' }); - urls.orgScope = this.server.create( - 'scope', - { - type: 'org', - scope: { id: 'global', type: 'global' }, - }, - 'withChildren' - ); - instances.org = this.server.create( + instances.orgScope = this.server.create( 'scope', { type: 'org', @@ -48,10 +40,10 @@ module('Acceptance | users | list', function (hooks) { 'withChildren' ); instances.user = this.server.create('user', { - scope: instances.org, + scope: instances.orgScope, }); - orgURL = `/scopes/${urls.orgScope.id}`; - urls.users = `/scopes/${urls.orgScope.id}/users`; + orgURL = `/scopes/${instances.orgScope.id}`; + urls.users = `/scopes/${instances.orgScope.id}/users`; authenticateSession({}); }); @@ -59,24 +51,24 @@ module('Acceptance | users | list', function (hooks) { assert.expect(2); await visit(orgURL); assert.ok( - urls.orgScope.authorized_collection_actions.users.includes('list') + instances.orgScope.authorized_collection_actions.users.includes('list') ); assert.ok(find(`[href="${urls.users}"]`)); }); test('User cannot navigate to index without either list or create actions', async function (assert) { assert.expect(2); - urls.orgScope.authorized_collection_actions.users = []; + instances.orgScope.authorized_collection_actions.users = []; await visit(orgURL); assert.notOk( - urls.orgScope.authorized_collection_actions.users.includes('list') + instances.orgScope.authorized_collection_actions.users.includes('list') ); - assert.notOk(find(`[href="${urls.usersorgURL}"]`)); + assert.notOk(find(`[href="${urls.users}"]`)); }); test('User can navigate to index with only create action', async function (assert) { assert.expect(1); - urls.orgScope.authorized_collection_actions.users = ['create']; + instances.orgScope.authorized_collection_actions.users = ['create']; await visit(orgURL); assert.ok(find(`[href="${urls.users}"]`)); });