refactor: 💡 Update Manage Dropdown in auth-methods (#2460)
* refactor: 💡 Update Manage Dropdown in auth-methods ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14704 * refactor: 💡 Refactored tests ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14704 --------- Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
This commit is contained in:
1 parent
ce2649272f
commit
c38ba294cc
7 files changed
+78
-50
No files matched your search
@@ -40,55 +40,42 @@
|
||||
</Rose::Dropdown>
|
||||
{{/if}}
|
||||
|
||||
<Rose::Dropdown
|
||||
@text={{t 'actions.manage'}}
|
||||
@dropdownRight={{true}}
|
||||
as |dropdown|
|
||||
>
|
||||
<Hds::Dropdown data-test-manage-auth-methods-dropdown as |dd|>
|
||||
<dd.ToggleButton @text={{t 'actions.manage'}} @color='secondary' />
|
||||
{{#if @model.isPrimary}}
|
||||
<dropdown.button
|
||||
@disabled={{@model.canSave}}
|
||||
<dd.Interactive
|
||||
@text={{t 'resources.auth-method.actions.remove-as-primary'}}
|
||||
{{on 'click' (fn @removeAsPrimary @model)}}
|
||||
>
|
||||
{{t 'resources.auth-method.actions.remove-as-primary'}}
|
||||
</dropdown.button>
|
||||
/>
|
||||
{{else}}
|
||||
<dropdown.button
|
||||
@disabled={{@model.canSave}}
|
||||
<dd.Interactive
|
||||
@text={{t 'resources.auth-method.actions.make-primary'}}
|
||||
{{on 'click' (fn @makePrimary @model)}}
|
||||
>
|
||||
{{t 'resources.auth-method.actions.make-primary'}}
|
||||
</dropdown.button>
|
||||
/>
|
||||
{{/if}}
|
||||
{{#if (can 'create model' @model collection='accounts')}}
|
||||
|
||||
<dropdown.link
|
||||
<dd.Interactive
|
||||
@text={{t 'resources.account.actions.create'}}
|
||||
@route='scopes.scope.auth-methods.auth-method.accounts.new'
|
||||
@model={{@model}}
|
||||
>
|
||||
{{t 'resources.account.actions.create'}}
|
||||
</dropdown.link>
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
{{#if (can 'create model' @model collection='managed-groups')}}
|
||||
{{#if (or @model.isOIDC @model.isLDAP)}}
|
||||
<dropdown.link
|
||||
<dd.Interactive
|
||||
@text={{t 'resources.managed-group.actions.create'}}
|
||||
@route='scopes.scope.auth-methods.auth-method.managed-groups.new'
|
||||
@model={{@model}}
|
||||
>
|
||||
{{t 'resources.managed-group.actions.create'}}
|
||||
</dropdown.link>
|
||||
/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#if (can 'delete auth-method' @model)}}
|
||||
<dropdown.separator />
|
||||
<dropdown.button
|
||||
@style='danger'
|
||||
@disabled={{@model.canSave}}
|
||||
<dd.Separator />
|
||||
<dd.Interactive
|
||||
@text={{t 'resources.auth-method.actions.delete'}}
|
||||
@color='critical'
|
||||
{{on 'click' (fn @delete @model)}}
|
||||
>
|
||||
{{t 'resources.auth-method.actions.delete'}}
|
||||
</dropdown.button>
|
||||
/>
|
||||
{{/if}}
|
||||
</Rose::Dropdown>
|
||||
</Hds::Dropdown>
|
||||
@@ -20,6 +20,8 @@ module('Acceptance | accounts | create', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div:first-child button';
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -116,6 +118,7 @@ module('Acceptance | accounts | create', function (hooks) {
|
||||
'create',
|
||||
),
|
||||
);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
assert.ok(find(`[href="${urls.newAccount}"]`));
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ module('Acceptance | accounts | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div:first-child button';
|
||||
const CREATE_ACCOUNT_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] ul li:nth-child(2) a';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -89,6 +94,7 @@ module('Acceptance | accounts | list', function (hooks) {
|
||||
instances.authMethod.authorized_collection_actions.accounts = ['create'];
|
||||
await visit(urls.authMethod);
|
||||
assert.ok(find(`[href="${urls.accounts}"]`));
|
||||
assert.ok(find(`.rose-layout-page-actions [href="${urls.newAccount}"]`));
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
assert.dom(CREATE_ACCOUNT_SELECTOR).hasAttribute('href', urls.newAccount);
|
||||
});
|
||||
});
|
||||
@@ -32,8 +32,6 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
const NAME_INPUT_SELECTOR = '[name="name"]';
|
||||
const URLS_INPUT_SELECTOR = '[name="urls"]';
|
||||
const DESC_INPUT_SELECTOR = '[name="description"]';
|
||||
const MAKE_PRIMARY_SELECTOR =
|
||||
'.rose-layout-page-actions .rose-dropdown-content [type="button"]:first-child';
|
||||
const ERROR_MSG_SELECTOR = '.rose-notification-body';
|
||||
const FIELD_ERROR_TEXT_SELECTOR = '.hds-form-error__message';
|
||||
|
||||
@@ -48,6 +46,12 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
const CLAIMS_SCOPES_BTN_SELECTOR = '[name="claims_scopes"] button';
|
||||
const CLAIMS_SCOPES_INPUT_SELECTOR = '[name="claims_scopes"] input';
|
||||
const TOGGLE_SELECTOR = '[name="prompts"]';
|
||||
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div:first-child button';
|
||||
const MAKE_PRIMARY_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] ul li:first-child button';
|
||||
|
||||
let getAuthMethodsCount;
|
||||
let featuresService;
|
||||
|
||||
@@ -333,6 +337,7 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(MAKE_PRIMARY_SELECTOR);
|
||||
|
||||
const scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
@@ -360,6 +365,7 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
'Primary auth method is not yet set.',
|
||||
);
|
||||
await visit(urls.authMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(MAKE_PRIMARY_SELECTOR);
|
||||
assert.dom(ERROR_MSG_SELECTOR).exists();
|
||||
});
|
||||
@@ -375,6 +381,7 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(MAKE_PRIMARY_SELECTOR);
|
||||
const scope = this.server.schema.scopes.find(instances.orgScope.id);
|
||||
assert.notOk(scope.primaryAuthMethodId, 'Primary auth method is unset.');
|
||||
@@ -403,6 +410,7 @@ module('Acceptance | auth-methods | create', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(MAKE_PRIMARY_SELECTOR);
|
||||
|
||||
assert.dom(ERROR_MSG_SELECTOR).hasText('Sorry!');
|
||||
|
||||
@@ -26,12 +26,15 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
let featuresService;
|
||||
let getAuthMethodCount;
|
||||
|
||||
const DELETE_DROPDOWN_SELECTOR =
|
||||
'.rose-layout-page-actions .rose-dropdown-button-danger';
|
||||
const DIALOG_DELETE_BTN_SELECTOR = '.rose-dialog .rose-button-primary';
|
||||
const DIALOG_CANCEL_BTN_SELECTOR = '.rose-dialog .rose-button-secondary';
|
||||
const ERROR_MSG_SELECTOR = '.rose-notification-body';
|
||||
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div:first-child button';
|
||||
const DELETE_ACTION_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] ul li:last-child button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -78,7 +81,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
assert.strictEqual(getAuthMethodCount(), authMethodsCount - 1);
|
||||
});
|
||||
@@ -89,7 +93,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
assert.strictEqual(getAuthMethodCount(), authMethodsCount - 1);
|
||||
});
|
||||
@@ -109,7 +114,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await a11yAudit();
|
||||
|
||||
assert.dom(ERROR_MSG_SELECTOR).hasText('Oops.');
|
||||
@@ -131,7 +137,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await a11yAudit();
|
||||
|
||||
assert.dom(ERROR_MSG_SELECTOR).hasText('Oops.');
|
||||
@@ -145,8 +152,9 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
assert.dom(DELETE_DROPDOWN_SELECTOR).doesNotExist();
|
||||
assert.dom(DELETE_ACTION_SELECTOR).doesNotExist();
|
||||
});
|
||||
|
||||
test('cannot delete an ldap auth method without proper authorization', async function (assert) {
|
||||
@@ -158,8 +166,9 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
assert.dom(DELETE_DROPDOWN_SELECTOR).doesNotExist();
|
||||
assert.dom(DELETE_ACTION_SELECTOR).doesNotExist();
|
||||
});
|
||||
|
||||
test('user can accept delete auth method via dialog', async function (assert) {
|
||||
@@ -169,7 +178,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(DIALOG_DELETE_BTN_SELECTOR);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.authMethods);
|
||||
@@ -184,7 +194,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(DIALOG_DELETE_BTN_SELECTOR);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.authMethods);
|
||||
@@ -198,7 +209,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(DIALOG_CANCEL_BTN_SELECTOR);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.authMethod);
|
||||
@@ -213,7 +225,8 @@ module('Acceptance | auth-methods | delete', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(DELETE_DROPDOWN_SELECTOR);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
await click(DIALOG_CANCEL_BTN_SELECTOR);
|
||||
|
||||
assert.strictEqual(currentURL(), urls.ldapAuthMethod);
|
||||
|
||||
@@ -30,6 +30,8 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
const DESC_INPUT_SELECTOR = '[name="description"]';
|
||||
const ERROR_MSG_SELECTOR = '.rose-notification-body';
|
||||
const FIELD_ERROR_TEXT_SELECTOR = '.hds-form-error__message';
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -85,8 +87,9 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
const managedGroupsCount = getManagedGroupCount();
|
||||
const name = 'Managed group name';
|
||||
await visit(urls.authMethod);
|
||||
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(`[href="${urls.newManagedGroup}"]`);
|
||||
|
||||
await fillIn(NAME_INPUT_SELECTOR, name);
|
||||
await fillIn(DESC_INPUT_SELECTOR, 'description');
|
||||
await click(SAVE_BTN_SELECTOR);
|
||||
@@ -101,6 +104,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
const managedGroupsCount = getManagedGroupCount();
|
||||
const name = 'Managed group name';
|
||||
await visit(urls.ldapAuthMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
await click(`[href="${urls.newLdapManagedGroup}"]`);
|
||||
await fillIn(NAME_INPUT_SELECTOR, name);
|
||||
@@ -154,6 +158,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
test('User can cancel a new managed group creation', async function (assert) {
|
||||
const managedGroupsCount = getManagedGroupCount();
|
||||
await visit(urls.authMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
await click(`[href="${urls.newManagedGroup}"]`);
|
||||
await fillIn(NAME_INPUT_SELECTOR, 'Managed group name');
|
||||
@@ -166,6 +171,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
test('User can cancel a new ldap managed group creation', async function (assert) {
|
||||
const managedGroupsCount = getManagedGroupCount();
|
||||
await visit(urls.ldapAuthMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
await click(`[href="${urls.newLdapManagedGroup}"]`);
|
||||
await fillIn(NAME_INPUT_SELECTOR, 'Managed group name');
|
||||
@@ -196,6 +202,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
);
|
||||
});
|
||||
await visit(urls.authMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
await click(`[href="${urls.newManagedGroup}"]`);
|
||||
await fillIn(NAME_INPUT_SELECTOR, 'new managed group');
|
||||
@@ -227,6 +234,7 @@ module('Acceptance | managed-groups | create', function (hooks) {
|
||||
);
|
||||
});
|
||||
await visit(urls.ldapAuthMethod);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
await click(`[href="${urls.newLdapManagedGroup}"]`);
|
||||
await fillIn(NAME_INPUT_SELECTOR, 'new managed group');
|
||||
|
||||
@@ -20,6 +20,8 @@ module('Acceptance | managed-groups | list', function (hooks) {
|
||||
setupIndexedDb(hooks);
|
||||
|
||||
let featuresService;
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-auth-methods-dropdown] div button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -157,6 +159,7 @@ module('Acceptance | managed-groups | list', function (hooks) {
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.authMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
assert.dom(`[href="${urls.managedGroups}"]`).exists();
|
||||
assert.dom(`[href="${urls.newManagedGroup}"]`).exists();
|
||||
@@ -168,8 +171,8 @@ module('Acceptance | managed-groups | list', function (hooks) {
|
||||
'create',
|
||||
];
|
||||
await visit(urls.authMethods);
|
||||
|
||||
await click(`[href="${urls.ldapAuthMethod}"]`);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
|
||||
assert.dom(`[href="${urls.ldapManagedGroups}"]`).exists();
|
||||
assert.dom(`[href="${urls.newLdapManagedGroup}"]`).exists();
|
||||
|
||||
Reference in new issue
Block a user