test: 💍 Refactor host list test selectors (#2629)
* test: 💍 Refactor host list test selectors
This commit is contained in:
1 parent
9a11925216
commit
343e1d2193
3 files changed
+25
-12
No files matched your search
@@ -98,14 +98,22 @@ module('Acceptance | host-catalogs | hosts | create', function (hooks) {
|
||||
|
||||
assert.dom(commonSelectors.HREF(urls.newHost)).doesNotExist();
|
||||
});
|
||||
|
||||
test('Users can navigate to new host route with proper authorization', async function (assert) {
|
||||
await visit(urls.hosts);
|
||||
|
||||
assert.ok(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'create',
|
||||
),
|
||||
);
|
||||
assert.dom(selectors.MANAGE_DROPDOWN_HOST_CATALOG).exists();
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_CATALOG);
|
||||
assert
|
||||
.dom(selectors.MANAGE_DROPDOWN_HOST_CATALOG_NEW_HOST)
|
||||
.hasAttribute('href', urls.newHost);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_CATALOG_NEW_HOST);
|
||||
assert.strictEqual(currentURL(), urls.newHost);
|
||||
});
|
||||
|
||||
test('Users cannot navigate to new host route without proper authorization', async function (assert) {
|
||||
|
||||
@@ -4,20 +4,17 @@
|
||||
*/
|
||||
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, find, click } from '@ember/test-helpers';
|
||||
import { visit, click, currentURL } from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'admin/tests/helpers';
|
||||
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
|
||||
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 | list', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
setupMirage(hooks);
|
||||
|
||||
const MANAGE_DROPDOWN_SELECTOR =
|
||||
'[data-test-manage-host-catalogs-dropdown] button:first-child';
|
||||
const NEW_HOST_SELECTOR =
|
||||
'[data-test-manage-host-catalogs-dropdown] div ul li a';
|
||||
|
||||
const instances = {
|
||||
scopes: {
|
||||
global: null,
|
||||
@@ -69,33 +66,39 @@ module('Acceptance | host-catalogs | hosts | list', function (hooks) {
|
||||
urls.newHost = `${urls.hosts}/new`;
|
||||
await authenticateSession({});
|
||||
});
|
||||
|
||||
test('Users can navigate to hosts with proper authorization', async function (assert) {
|
||||
await visit(urls.hostCatalog);
|
||||
|
||||
assert.ok(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'list',
|
||||
),
|
||||
);
|
||||
assert.dom(MANAGE_DROPDOWN_SELECTOR);
|
||||
assert.ok(find(`[href="${urls.hosts}"]`));
|
||||
|
||||
assert.dom(selectors.MANAGE_DROPDOWN_HOST_CATALOG).isVisible();
|
||||
assert.dom(commonSelectors.HREF(urls.hosts)).isVisible();
|
||||
});
|
||||
|
||||
test('User cannot navigate to index without either list or create actions', async function (assert) {
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = [];
|
||||
await visit(urls.hostCatalog);
|
||||
|
||||
assert.notOk(
|
||||
instances.hostCatalog.authorized_collection_actions.hosts.includes(
|
||||
'list',
|
||||
),
|
||||
);
|
||||
assert.notOk(find(`[href="${urls.hosts}"]`));
|
||||
assert.dom(commonSelectors.HREF(urls.hosts)).doesNotExist();
|
||||
});
|
||||
|
||||
test('User can navigate to index with only create action', async function (assert) {
|
||||
instances.hostCatalog.authorized_collection_actions.hosts = ['create'];
|
||||
await visit(urls.hostCatalog);
|
||||
assert.ok(find(`[href="${urls.hosts}"]`));
|
||||
await click(MANAGE_DROPDOWN_SELECTOR);
|
||||
assert.dom(NEW_HOST_SELECTOR).hasAttribute('href', urls.newHost);
|
||||
|
||||
assert.dom(commonSelectors.HREF(urls.hosts)).isVisible();
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_CATALOG);
|
||||
await click(selectors.MANAGE_DROPDOWN_HOST_CATALOG_NEW_HOST);
|
||||
assert.strictEqual(currentURL(), urls.newHost);
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
export const MANAGE_DROPDOWN_HOST_CATALOG =
|
||||
'[data-test-manage-host-catalogs-dropdown] button:first-child';
|
||||
export const MANAGE_DROPDOWN_HOST_CATALOG_NEW_HOST =
|
||||
'[data-test-manage-host-catalogs-dropdown] ul li:first-child a';
|
||||
export const MANAGE_DROPDOWN_HOST =
|
||||
'[data-test-manage-hosts-dropdown] button:first-child';
|
||||
export const MANAGE_DROPDOWN_HOST_DELETE =
|
||||
|
||||
Reference in new issue
Block a user