refactor: 💅 Use common selector ALERT_TOAST_BODY across test suite (#2692)

* replace with alert toast body, replace with this.server.schema

* revert changes to db,schema

* use common selector, alert toast body

* replace ERROR_MSG_SELECTOR with common selector ALERT_TOAST_BODY
This commit is contained in:
Lauren authored and GitHub committed 2025-02-13 15:54:40 -05:00
1 parent 20c4bbcee2
commit f12ae90aba
45 files changed
+124 -138

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 { TYPE_AUTH_METHOD_LDAP } from 'api/models/auth-method';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | users | accounts', function (hooks) {
setupApplicationTest(hooks);
@@ -24,8 +25,6 @@ module('Acceptance | users | accounts', function (hooks) {
'[data-test-manage-user-dropdown] ul li:first-child a';
const MANAGE_DROPDOWN_SELECTOR =
'[data-test-manage-user-dropdown] button:first-child';
const ERROR_MSG_SELECTOR =
'[data-test-toast-notification] .hds-alert__description';
const TABLE_ROWS_SELECTOR = 'tbody tr';
const CHECKBOX_SELECTOR = 'tbody label';
const SUBMIT_BTN_SELECTOR = 'form [type="submit"]';
@@ -162,7 +161,7 @@ module('Acceptance | users | accounts', function (hooks) {
assert.dom(TABLE_ROWS_SELECTOR).exists({ count: accountsCount });
await click(ACCOUNTS_ACTION_SELECTOR);
await click(REMOVE_ACTION_SELECTOR);
assert.dom(ERROR_MSG_SELECTOR).isVisible();
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
});
test('visiting account add accounts', async function (assert) {
@@ -296,6 +295,6 @@ module('Acceptance | users | accounts', function (hooks) {
await visit(urls.addAccounts);
await click(CHECKBOX_SELECTOR);
await click(SUBMIT_BTN_SELECTOR);
assert.dom(ERROR_MSG_SELECTOR).isVisible();
assert.dom(commonSelectors.ALERT_TOAST_BODY).isVisible();
});
});
@@ -10,6 +10,7 @@ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | users | create', function (hooks) {
setupApplicationTest(hooks);
@@ -135,7 +136,7 @@ module('Acceptance | users | create', function (hooks) {
assert.strictEqual(getUsersCount(), usersCount);
assert
.dom('[data-test-toast-notification] .hds-alert__description')
.dom(commonSelectors.ALERT_TOAST_BODY)
.hasText('The request was invalid.');
assert.dom('[data-test-error-message-name]').hasText('Name is required.');
});
@@ -85,7 +85,7 @@ module('Acceptance | users | delete', function (hooks) {
await click(commonSelectors.MODAL_WARNING_CONFIRM_BTN);
assert
.dom('[data-test-toast-notification] .hds-alert__description')
.dom(commonSelectors.ALERT_TOAST_BODY)
.hasText('Deleted successfully.');
assert.strictEqual(this.server.db.users.length, usersCount - 1);
assert.strictEqual(currentURL(), urls.users);
@@ -123,8 +123,6 @@ module('Acceptance | users | delete', function (hooks) {
await click(`[href="${urls.user}"]`);
await click(MANAGE_DROPDOWN_SELECTOR);
await click(DELETE_ACTION_SELECTOR);
assert
.dom('[data-test-toast-notification] .hds-alert__description')
.hasText('Oops.');
assert.dom(commonSelectors.ALERT_TOAST_BODY).hasText('Oops.');
});
});
@@ -113,7 +113,7 @@ module('Acceptance | users | update', function (hooks) {
await click('[type="submit"]');
assert
.dom('[data-test-toast-notification] .hds-alert__description')
.dom(commonSelectors.ALERT_TOAST_BODY)
.hasText('The request was invalid.');
assert.dom('[data-test-error-message-name]').hasText('Name is required.');
});