From 58cd75ef67e2f4007be82f39f16dd2de957f0fe8 Mon Sep 17 00:00:00 2001 From: Devon Anderson Date: Thu, 28 Sep 2023 12:55:52 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20ICU-11208=20fix=20view=20?= =?UTF-8?q?of=20role=20scopes=20(#1929)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 ICU-11208 fix view of role under org, and project scope Fixed view of role under org, and project scope. ✅ Closes: ICU-11208 * refactor: 💡 Refactor scopes in roll Refactor role to disregard subscopes for project scope ✅ Closes: ICU-11208 * refactor: 💡 refactor test Refactor test to include test for a role having the correct grand scopes ✅ Closes: ICU-11208 * refactor: 💡 refactor test Refactor test to test that role fectches scopes correctly * quick refactor of previous test commit to grab the role id from the response and use it in the next request * refactor: 💡 refactor test refactor test for scope fetching --- .../app/routes/scopes/scope/roles/role/index.js | 10 ++++++---- ui/admin/tests/acceptance/roles/read-test.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/roles/role/index.js b/ui/admin/app/routes/scopes/scope/roles/role/index.js index 4d64d1d8b..af5bcf837 100644 --- a/ui/admin/app/routes/scopes/scope/roles/role/index.js +++ b/ui/admin/app/routes/scopes/scope/roles/role/index.js @@ -17,16 +17,18 @@ export default class ScopesScopeRolesRoleIndexRoute extends Route { */ async afterModel() { const currentScope = this.modelFor('scopes.scope'); - const scopes = await this.store.query('scope', { - scope_id: currentScope.id, - }); let subScopes = []; //await the store query to fix ember's proxy promise deprecation warning if (!currentScope.isProject) { + const scopes = await this.store.query('scope', { + scope_id: currentScope.id, + }); subScopes = await Promise.all( scopes.map(async (scope) => ({ model: scope, - subScopes: await this.store.query('scope', { scope_id: scope.id }), + subScopes: !scope.isProject + ? await this.store.query('scope', { scope_id: scope.id }) + : [], })) ); } diff --git a/ui/admin/tests/acceptance/roles/read-test.js b/ui/admin/tests/acceptance/roles/read-test.js index 15aabe613..4d1e5732a 100644 --- a/ui/admin/tests/acceptance/roles/read-test.js +++ b/ui/admin/tests/acceptance/roles/read-test.js @@ -82,4 +82,18 @@ module('Acceptance | roles | read', function (hooks) { await visit(urls.roles); assert.notOk(find('main tbody .hds-table__tr:nth-child(1) a')); }); + + test('can navigate to a roles and fetches scopes correctly', async function (assert) { + assert.expect(1); + this.server.get('/scopes/:id', ({ scopes }, { params: { id } }) => { + const scope = scopes.find(id); + const response = scope.type === 'project' ? new Response(400) : scope; + return response; + }); + + await visit(urls.roles); + await click('main tbody .hds-table__tr:nth-child(1) a'); + await a11yAudit(); + assert.strictEqual(currentURL(), urls.role); + }); });