test: 💍 Refactor host delete test selectors (#2626)
Refactor host-catalog host delete acceptance test selectors
This commit is contained in:
1 parent
6d2f1dcbbf
commit
584e62cff3
3 files changed
+27
-22
No files matched your search
@@ -105,7 +105,7 @@ module('Acceptance | host-catalogs | hosts | create', function (hooks) {
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom(selectors.MANAGE_DROPDOWN).exists();
|
||||
assert.dom(selectors.MANAGE_DROPDOWN_HOST_CATALOG).exists();
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new host route without proper authorization', async function (assert) {
|
||||
|
||||
@@ -4,23 +4,21 @@
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find, click } from '@ember/test-helpers';
|
||||
import { visit, click } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
import { Response } from 'miragejs';
|
||||
import { resolve, reject } from 'rsvp';
|
||||
import sinon from 'sinon';
|
||||
import { authenticateSession } from 'ember-simple-auth/test-support';
|
||||
import * as selectors from './selectors';
|
||||
import * as commonSelectors from 'admin/tests/helpers/selectors';
|
||||
|
||||
module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
let getHostCount;
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-hosts-dropdown] button:first-child';
|
||||
const DELETE_ACTION_SELECTOR =
|
||||
'[data-test-manage-hosts-dropdown] ul li button';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
@@ -79,8 +77,9 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
test('can delete host', async function (assert) {
|
||||
const count = getHostCount();
|
||||
await visit(urls.host);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_DELETE);
|
||||
assert.strictEqual(getHostCount(), count - 1);
|
||||
});
|
||||
|
||||
@@ -88,9 +87,8 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
instances.host.authorized_actions =
|
||||
instances.host.authorized_actions.filter((item) => item !== 'delete');
|
||||
await visit(urls.host);
|
||||
assert.notOk(
|
||||
find('.rose-layout-page-actions .rose-dropdown-button-danger'),
|
||||
);
|
||||
|
||||
assert.dom(selectors.MANAGE_DROPDOWN_HOST).doesNotExist();
|
||||
});
|
||||
|
||||
test('can accept delete host via dialog', async function (assert) {
|
||||
@@ -99,8 +97,10 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
confirmService.confirm = sinon.fake.returns(resolve());
|
||||
const count = getHostCount();
|
||||
await visit(urls.host);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_DELETE);
|
||||
|
||||
assert.strictEqual(getHostCount(), count - 1);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
@@ -111,8 +111,10 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
confirmService.confirm = sinon.fake.returns(reject());
|
||||
const count = getHostCount();
|
||||
await visit(urls.host);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_DELETE);
|
||||
|
||||
assert.strictEqual(getHostCount(), count);
|
||||
assert.ok(confirmService.confirm.calledOnce);
|
||||
});
|
||||
@@ -130,10 +132,10 @@ module('Acceptance | host-catalogs | hosts | delete', function (hooks) {
|
||||
);
|
||||
});
|
||||
await visit(urls.host);
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
await click(DELETE_ACTION_SELECTOR);
|
||||
assert
|
||||
.dom('[data-test-toast-notification] .hds-alert__description')
|
||||
.hasText('Oops.');
|
||||
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_DELETE);
|
||||
|
||||
assert.dom(commonSelectors.ALERT_TOAST_BODY).hasText('Oops.');
|
||||
});
|
||||
});
|
||||
@@ -3,9 +3,12 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
export const MANAGE_DROPDOWN =
|
||||
export const MANAGE_DROPDOWN_HOST_CATALOG =
|
||||
'[data-test-manage-host-catalogs-dropdown] button:first-child';
|
||||
|
||||
export const MANAGE_DROPDOWN_HOST =
|
||||
'[data-test-manage-hosts-dropdown] button:first-child';
|
||||
export const MANAGE_DROPDOWN_HOST_DELETE =
|
||||
'[data-test-manage-hosts-dropdown] ul li button';
|
||||
export const FIELD_ADDRESS = '[name=address]';
|
||||
export const FIELD_ADDRESS_VALUE = 'New address';
|
||||
export const FIELD_ADDRESS_ERROR = '[data-test-error-message-address]';
|
||||
Reference in new issue
Block a user