fix: 🐛 ICU-11208 fix view of role scopes (#1929)
* 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
This commit is contained in:
1 parent
4de41763b7
commit
58cd75ef67
2 files changed
+20
-4
No files matched your search
@@ -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 })
|
||||
: [],
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user