diff --git a/ui/admin/tests/acceptance/roles/create-test.js b/ui/admin/tests/acceptance/roles/create-test.js index a0364c8b0..c2a86e46c 100644 --- a/ui/admin/tests/acceptance/roles/create-test.js +++ b/ui/admin/tests/acceptance/roles/create-test.js @@ -16,7 +16,6 @@ module('Acceptance | roles | create', function (hooks) { setupMirage(hooks); let orgURL; - let orgScope; const instances = { scopes: { @@ -25,16 +24,17 @@ module('Acceptance | roles | create', function (hooks) { project: null, }, role: null, + orgScope: null, }; const urls = { - orgScope: null, roles: null, role: null, newRoleURL: null, }; hooks.beforeEach(function () { - orgScope = this.server.create( + authenticateSession({}); + instances.orgScope = this.server.create( 'scope', { type: 'org', @@ -43,30 +43,29 @@ module('Acceptance | roles | create', function (hooks) { 'withChildren' ); - orgURL = `/scopes/${orgScope.id}`; - authenticateSession({}); - instances.scopes.global = this.server.create('scope', { id: 'global' }); - instances.scopes.org = this.server.create('scope', { - type: 'org', - scope: { id: 'global', type: 'global' }, - }); + // instances.scopes.global = this.server.create('scope', { id: 'global' }); + // instances.scopes.org = this.server.create('scope', { + // type: 'org', + // scope: { id: 'global', type: 'global' }, + // }); // The project scope is not yet used for role tests (though it will be // in the future). This is created simply to test the grant scope loading // mechanism. instances.scopes.project = this.server.create('scope', { type: 'project', - scope: { id: instances.scopes.org.id, type: instances.scopes.org.type }, + scope: { id: instances.orgScope.id, type: instances.orgScope.type }, }); instances.role = this.server.create( 'role', { - scope: instances.scopes.org, + scope: instances.orgScope, }, 'withPrincipals' ); - urls.roles = `/scopes/${instances.scopes.org.id}/roles`; + urls.roles = `/scopes/${instances.orgScope.id}/roles`; urls.role = `${urls.roles}/${instances.role.id}`; urls.newRoleURL = `${urls.roles}/new`; + orgURL = `/scopes/${instances.orgScope.id}`; }); test('can create new role', async function (assert) { @@ -81,18 +80,20 @@ module('Acceptance | roles | create', function (hooks) { test('can navigate to new roles route with proper authorization', async function (assert) { assert.expect(2); await visit(orgURL); - assert.ok(orgScope.authorized_collection_actions.roles.includes('create')); - assert.ok(find(`[href="${orgURL}/roles"]`)); + assert.ok( + instances.orgScope.authorized_collection_actions.roles.includes('create') + ); + assert.ok(find(`[href="${urls.roles}"]`)); }); test('cannot navigate to new roles route without proper authorization', async function (assert) { assert.expect(2); - orgScope.authorized_collection_actions.roles = []; + instances.orgScope.authorized_collection_actions.roles = []; await visit(orgURL); assert.notOk( - orgScope.authorized_collection_actions.roles.includes('create') + instances.orgScope.authorized_collection_actions.roles.includes('create') ); - assert.notOk(find(`[href="${orgURL}/roles"]`)); + assert.notOk(find(`[href="${urls.roles}"]`)); }); test('can cancel new role creation', async function (assert) { diff --git a/ui/admin/tests/acceptance/roles/list-test.js b/ui/admin/tests/acceptance/roles/list-test.js index 78e7d22fa..e6e13cfb7 100644 --- a/ui/admin/tests/acceptance/roles/list-test.js +++ b/ui/admin/tests/acceptance/roles/list-test.js @@ -19,6 +19,7 @@ module('Acceptance | roles | list', function (hooks) { global: null, org: null, }, + orgScope: null, }; const urls = { @@ -26,20 +27,10 @@ module('Acceptance | roles | list', function (hooks) { org: null, }, roles: 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,11 +39,11 @@ module('Acceptance | roles | list', function (hooks) { 'withChildren' ); instances.role = this.server.create('role', { - scope: instances.org, + scope: instances.orgScope, }); - orgURL = `/scopes/${urls.orgScope.id}`; + orgURL = `/scopes/${instances.orgScope.id}`; - urls.roles = `/scopes/${urls.orgScope.id}/roles`; + urls.roles = `/scopes/${instances.orgScope.id}/roles`; authenticateSession({}); }); @@ -60,24 +51,24 @@ module('Acceptance | roles | list', function (hooks) { assert.expect(2); await visit(orgURL); assert.ok( - urls.orgScope.authorized_collection_actions.roles.includes('list') + instances.orgScope.authorized_collection_actions.roles.includes('list') ); assert.ok(find(`[href="${urls.roles}"]`)); }); test('User cannot navigate to index without either list or create actions', async function (assert) { assert.expect(2); - urls.orgScope.authorized_collection_actions.roles = []; + instances.orgScope.authorized_collection_actions.roles = []; await visit(orgURL); assert.notOk( - urls.orgScope.authorized_collection_actions.roles.includes('list') + instances.orgScope.authorized_collection_actions.roles.includes('list') ); assert.notOk(find(`[href="${urls.roles}"]`)); }); test('User can navigate to index with only create action', async function (assert) { assert.expect(1); - urls.orgScope.authorized_collection_actions.roles = ['create']; + instances.orgScope.authorized_collection_actions.roles = ['create']; await visit(orgURL); assert.ok(find(`[href="${urls.roles}"]`)); });