Icu 14834 remove duplicate selectors and use common selectors instead (#2436)

* refactor: 💡 update SAVE_BTN usage

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

* refactor: 💡 update CANCEL_BTN usage

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

* refactor: 💡 update EDIT_BTN usage

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

* refactor: 💡 update FIELD_NAME & FIELD_NAME_VALUE usage

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-14834
This commit is contained in:
Cameron Perera authored and GitHub committed 2024-08-15 09:24:21 -05:00
1 parent 69da1fa04c
commit 9e668e8467
3 files changed
+48 -52

No files matched your search

@@ -11,6 +11,7 @@ import a11yAudit from 'ember-a11y-testing/test-support/audit';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import * as selectors from './selectors';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | storage-buckets | create', function (hooks) {
setupApplicationTest(hooks);
@@ -54,7 +55,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await select(selectors.FIELD_SCOPE, 'global');
assert.dom(selectors.FIELD_BUCKET_NAME).isNotDisabled();
@@ -62,12 +63,12 @@ module('Acceptance | storage-buckets | create', function (hooks) {
assert.dom(selectors.FIELD_BUCKET_NAME).doesNotHaveAttribute('readOnly');
assert.dom(selectors.FIELD_BUCKET_PREFIX).doesNotHaveAttribute('readOnly');
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
const storageBucket = this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.scopeId, 'global');
assert.strictEqual(getStorageBucketCount(), storageBucketCount + 1);
});
@@ -77,7 +78,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await select(selectors.FIELD_SCOPE, instances.scopes.org.id);
assert.dom(selectors.FIELD_BUCKET_NAME).isNotDisabled();
@@ -85,13 +86,13 @@ module('Acceptance | storage-buckets | create', function (hooks) {
assert.dom(selectors.FIELD_BUCKET_NAME).doesNotHaveAttribute('readOnly');
assert.dom(selectors.FIELD_BUCKET_PREFIX).doesNotHaveAttribute('readOnly');
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
const storageBucket = this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
assert.dom(selectors.TOAST).hasText(selectors.TOAST_SUCCESSFULL_VALUE);
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.scopeId, instances.scopes.org.id);
assert.strictEqual(getStorageBucketCount(), storageBucketCount + 1);
});
@@ -104,7 +105,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await click(`[href="${urls.newStorageBucket}"]`);
// Fill the form
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await click(selectors.FIELD_PLUGIN_TYPE_MINIO);
await select(selectors.FIELD_SCOPE, instances.scopes.org.id);
await fillIn(
@@ -117,14 +118,14 @@ module('Acceptance | storage-buckets | create', function (hooks) {
);
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
// Assertions
const storageBucket = this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
assert.dom(selectors.TOAST).hasText(selectors.TOAST_SUCCESSFULL_VALUE);
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
assert.strictEqual(
storageBucket.attributes.endpoint_url,
selectors.FIELD_ENDPOINT_URL_VALUE,
@@ -140,7 +141,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
// There are 2 credential types
assert
@@ -150,12 +151,12 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await click(selectors.FIELD_DYNAMIC_CREDENTIAL);
await fillIn(selectors.FIELD_ROLE_ARN, selectors.FIELD_ROLE_ARN_VALUE);
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
const storageBucket = this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
//for dynamic credentials, there should be no secret field
assert.notOk(storageBucket.secret);
assert.strictEqual(getStorageBucketCount(), storageBucketCount + 1);
@@ -166,7 +167,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
assert
.dom(`${selectors.GROUP_CREDENTIAL_TYPE} .hds-form-radio-card`)
.exists({ count: 2 });
@@ -175,13 +176,13 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
const storageBucket = this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
//for static credentials, role_arn should be null
assert.strictEqual(storageBucket.attributes.role_arn, null);
assert.strictEqual(getStorageBucketCount(), storageBucketCount + 1);
@@ -195,7 +196,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await click(`[href="${urls.newStorageBucket}"]`);
// Fill the form
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await click(selectors.FIELD_PLUGIN_TYPE_MINIO);
await fillIn(
selectors.FIELD_ENDPOINT_URL,
@@ -208,15 +209,15 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
// Retrieve recently created SB
const storageBucket = await this.server.schema.storageBuckets.findBy({
name: selectors.FIELD_NAME_VALUE,
name: commonSelectors.FIELD_NAME_VALUE,
});
// Assertions
assert.strictEqual(storageBucket.name, selectors.FIELD_NAME_VALUE);
assert.strictEqual(storageBucket.name, commonSelectors.FIELD_NAME_VALUE);
assert.strictEqual(
storageBucket.attributes.endpoint_url,
selectors.FIELD_ENDPOINT_URL_VALUE,
@@ -232,9 +233,9 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await click(selectors.CANCEL_BTN);
await click(commonSelectors.CANCEL_BTN);
assert.strictEqual(currentURL(), urls.storageBuckets);
assert.strictEqual(getStorageBucketCount(), storageBucketCount);
@@ -263,7 +264,7 @@ module('Acceptance | storage-buckets | create', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.newStorageBucket}"]`);
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
await a11yAudit();
assert.dom(selectors.TOAST).hasText('The request was invalid.');
@@ -3,14 +3,6 @@
* SPDX-License-Identifier: BUSL-1.1
*/
// START TODO: Remove common selectors from storage-bucket specific selectors
export const SAVE_BTN = '[type=submit]';
export const CANCEL_BTN = '.rose-form-actions [type=button]';
export const EDIT_BTN = '.rose-form-actions [type=button]';
export const FIELD_NAME = '[name=name]';
export const FIELD_NAME_VALUE = 'Random name';
// END TODO: Remove common selectors from storage-bucket specific selectors
export const FIELD_SCOPE = '[name=scope]';
export const FIELD_PLUGIN_TYPE = '[name=plugin_type]';
export const FIELD_PLUGIN_TYPE_MINIO = '[value=minio]'; // Provider
@@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import * as selectors from './selectors';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | storage-buckets | update', function (hooks) {
setupApplicationTest(hooks);
@@ -53,15 +54,17 @@ module('Acceptance | storage-buckets | update', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.storageBucket}"]`);
await click(selectors.EDIT_BTN, 'Click edit mode');
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await click(selectors.SAVE_BTN, 'Click save');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await click(commonSelectors.SAVE_BTN, 'Click save');
assert.dom(`[href="${urls.storageBucket}"]`).isVisible();
assert.dom(selectors.FIELD_NAME).hasValue(selectors.FIELD_NAME_VALUE);
assert
.dom(commonSelectors.FIELD_NAME)
.hasValue(commonSelectors.FIELD_NAME_VALUE);
assert.strictEqual(
instances.storageBucket.name,
selectors.FIELD_NAME_VALUE,
commonSelectors.FIELD_NAME_VALUE,
);
});
@@ -70,11 +73,11 @@ module('Acceptance | storage-buckets | update', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.storageBucket}"]`);
await click(selectors.EDIT_BTN, 'Click edit mode');
await fillIn(selectors.FIELD_NAME, selectors.FIELD_NAME_VALUE);
await click(selectors.CANCEL_BTN, 'Click cancel');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
await click(commonSelectors.CANCEL_BTN, 'Click cancel');
assert.dom(selectors.FIELD_NAME).hasValue(`${name}`);
assert.dom(commonSelectors.FIELD_NAME).hasValue(`${name}`);
assert.strictEqual(instances.storageBucket.name, name);
});
@@ -88,7 +91,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
assert.dom(selectors.FIELD_ACCESS_KEY_EDIT_BTN).isDisabled();
assert.dom(selectors.FIELD_SECRET_KEY_EDIT_BTN).isDisabled();
await click(selectors.EDIT_BTN, 'Click edit mode');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
assert.dom(selectors.FIELD_ACCESS_KEY_EDIT_BTN).isEnabled();
assert.dom(selectors.FIELD_SECRET_KEY_EDIT_BTN).isEnabled();
@@ -104,7 +107,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
await fillIn(selectors.FIELD_ACCESS_KEY, selectors.FIELD_ACCESS_KEY_VALUE);
await fillIn(selectors.FIELD_SECRET_KEY, selectors.FIELD_SECRET_KEY_VALUE);
await click(selectors.SAVE_BTN, 'Click save');
await click(commonSelectors.SAVE_BTN, 'Click save');
assert.dom(selectors.FIELD_ACCESS_KEY_EDIT_BTN).isDisabled();
assert.dom(selectors.FIELD_SECRET_KEY_EDIT_BTN).isDisabled();
@@ -117,7 +120,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
await visit(urls.storageBuckets);
await click(`[href="${urls.storageBucket}"]`);
await click(selectors.EDIT_BTN, 'Click edit mode');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
await click(selectors.FIELD_ACCESS_KEY_EDIT_BTN);
await click(selectors.FIELD_SECRET_KEY_EDIT_BTN);
@@ -127,7 +130,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
await click(selectors.FIELD_ACCESS_KEY_EDIT_BTN, 'Click cancel button');
await click(selectors.FIELD_SECRET_KEY_EDIT_BTN, 'Click cancel button');
await click(selectors.SAVE_BTN, 'Click save');
await click(commonSelectors.SAVE_BTN, 'Click save');
assert.dom(selectors.FIELD_ACCESS_KEY_EDIT_BTN).isDisabled();
assert.dom(selectors.FIELD_SECRET_KEY_EDIT_BTN).isDisabled();
@@ -163,9 +166,9 @@ module('Acceptance | storage-buckets | update', function (hooks) {
});
await click(`[href="${urls.storageBucket}"]`);
await click(selectors.EDIT_BTN, 'Activate edit mode');
await click(commonSelectors.EDIT_BTN, 'Activate edit mode');
await fillIn(selectors.FIELD_WORKER_FILTER, 'random string');
await click(selectors.SAVE_BTN);
await click(commonSelectors.SAVE_BTN);
assert.dom(selectors.TOAST).hasText('The request was invalid.');
assert
@@ -184,7 +187,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
assert.dom(selectors.FIELD_BUCKET_NAME).isDisabled();
assert.dom(selectors.FIELD_BUCKET_PREFIX).isDisabled();
await click(selectors.EDIT_BTN, 'Click edit mode');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
assert.dom(selectors.FIELD_SCOPE).doesNotExist();
assert.dom(selectors.FIELD_PLUGIN_TYPE).isDisabled();
@@ -203,7 +206,7 @@ module('Acceptance | storage-buckets | update', function (hooks) {
assert.dom(selectors.FIELD_BUCKET_NAME).isDisabled();
await click(selectors.EDIT_BTN, 'Click edit mode');
await click(commonSelectors.EDIT_BTN, 'Click edit mode');
assert.dom(selectors.FIELD_SCOPE).doesNotExist();
assert.dom(selectors.FIELD_PLUGIN_TYPE).isDisabled();