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:
WadiandCameron Perera authored and GitHub committed 2024-08-26 14:30:57 -05:00
1 parent ce2649272f
commit c38ba294cc
7 files changed
+78 -50

No files matched your search

@@ -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);