Icu 12708 add scopes tab route in role route (#2322)

* feat: 🎸 add roles/role/scopes route

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 update role and scope mirage factories

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* feat: 🎸 add grantScopes to role model

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* feat: 🎸 fetch all scopes recursively

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* feat: 🎸 add new role grant scopes translations

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* feat: 🎸 add table to list grant scopes on a role

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* test: 💍 acceptance test for grant scope table and controller

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* test: 💍 add unit tests for grantScopes method on role model

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 small updates from PR feedback

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 update grantScopes to use sort

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* feat: 🎸 update role scope description for each scope type

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 make grant_scope_ids sort better

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 update global scope to show as Global vs global

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 update logic for display grant scope keywords

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 small improvement in role.grantScopes

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 move scope query to roles/scope route

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708

* refactor: 💡 remove console.log

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12708
This commit is contained in:
Cameron Perera authored and Lisbet Alvarez committed 2024-07-15 17:23:00 -07:00
1 parent e60b774d05
commit 2bc314d271
14 files changed
+587 -2

No files matched your search

@@ -0,0 +1,63 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { authenticateSession } from 'ember-simple-auth/test-support';
import {
GRANT_SCOPE_THIS,
GRANT_SCOPE_CHILDREN,
GRANT_SCOPE_DESCENDANTS,
} from 'api/models/role';
module('Unit | Controller | scopes/scope/roles/role/scopes', function (hooks) {
setupTest(hooks);
setupMirage(hooks);
let controller;
const instances = {
scopes: {
global: null,
},
role: null,
};
const urls = {
globalScope: null,
scopes: null,
};
hooks.beforeEach(async function () {
authenticateSession({});
controller = this.owner.lookup('controller:scopes/scope/roles/role/scopes');
instances.scopes.global = this.server.create('scope', { id: 'global' });
instances.role = this.server.create('role', {
scopeId: 'global',
});
urls.globalScope = `/scopes/global`;
urls.scopes = `${urls.globalScope}/roles/${instances.role.id}/scopes`;
});
test('it exists', function (assert) {
assert.ok(controller);
});
test('isKeywordThis action returns true if id is GRANT_SCOPE_THIS', function (assert) {
assert.ok(controller.isKeywordThis(GRANT_SCOPE_THIS));
assert.notOk(controller.isKeywordThis(GRANT_SCOPE_CHILDREN));
});
test('isKeywordChildrenOrDescendants action returns true if id is GRANT_SCOPE_CHILDREN or GRANT_SCOPE_DESCENDANTS', function (assert) {
assert.ok(controller.isKeywordChildrenOrDescendants(GRANT_SCOPE_CHILDREN));
assert.ok(
controller.isKeywordChildrenOrDescendants(GRANT_SCOPE_DESCENDANTS),
);
assert.notOk(controller.isKeywordChildrenOrDescendants(GRANT_SCOPE_THIS));
});
});