Icu 15481 groups read and list test (#2551)

* refactor: 💡 test selectors in read and list groups
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-11-06 15:13:17 -08:00
1 parent dbda8c5674
commit a32cc13171
2 files changed
+20 -13

No files matched your search

+15 -11
View File
@@ -14,6 +14,7 @@ import {
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | groups | list', function (hooks) {
setupApplicationTest(hooks);
@@ -71,41 +72,44 @@ module('Acceptance | groups | list', function (hooks) {
),
);
assert.dom(`[href="${urls.groups}"]`).isVisible();
assert.dom(commonSelectors.HREF(urls.groups)).isVisible();
});
test('User cannot navigate to index without either list or create actions', async function (assert) {
instances.scopes.org.authorized_collection_actions.groups = [];
await visit(urls.orgScope);
assert.notOk(
instances.scopes.org.authorized_collection_actions.groups.includes(
'list',
),
);
assert.dom(`[href="${urls.groups}"]`).doesNotExist();
assert.dom(commonSelectors.HREF(urls.groups)).doesNotExist();
});
test('User can navigate to index with only create action', async function (assert) {
instances.scopes.org.authorized_collection_actions.groups = ['create'];
await visit(urls.orgScope);
assert.dom(`[href="${urls.groups}"]`).isVisible();
assert.dom(commonSelectors.HREF(urls.groups)).isVisible();
});
test('user can search for a specific group by id', async function (assert) {
await visit(urls.orgScope);
await click(`[href="${urls.groups}"]`);
await click(commonSelectors.HREF(urls.groups));
assert.dom(`[href="${urls.group1}"]`).exists();
assert.dom(`[href="${urls.group2}"]`).exists();
assert.dom(commonSelectors.HREF(urls.group1)).exists();
assert.dom(commonSelectors.HREF(urls.group2)).exists();
await fillIn(SEARCH_INPUT_SELECTOR, instances.group1.id);
await waitUntil(() => findAll(`[href="${urls.group2}"]`).length === 0);
await waitUntil(
() => findAll(commonSelectors.HREF(urls.group2)).length === 0,
);
assert.dom(`[href="${urls.group1}"]`).exists();
assert.dom(`[href="${urls.group2}"]`).doesNotExist();
assert.dom(commonSelectors.HREF(urls.group1)).exists();
assert.dom(commonSelectors.HREF(urls.group2)).doesNotExist();
});
test('user can search for groups and get no results', async function (assert) {
@@ -119,8 +123,8 @@ module('Acceptance | groups | list', function (hooks) {
await fillIn(SEARCH_INPUT_SELECTOR, 'fake group that does not exist');
await waitUntil(() => findAll(NO_RESULTS_MSG_SELECTOR).length === 1);
assert.dom(`[href="${urls.group1}"]`).doesNotExist();
assert.dom(`[href="${urls.group2}"]`).doesNotExist();
assert.dom(commonSelectors.HREF(urls.group1)).doesNotExist();
assert.dom(commonSelectors.HREF(urls.group2)).doesNotExist();
assert.dom(NO_RESULTS_MSG_SELECTOR).includesText('No results found');
});
});
@@ -4,7 +4,7 @@
*/
import { module, test } from 'qunit';
import { visit, currentURL, find } from '@ember/test-helpers';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
@@ -14,6 +14,7 @@ import {
//currentSession,
//invalidateSession,
} from 'ember-simple-auth/test-support';
import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | groups | read', function (hooks) {
setupApplicationTest(hooks);
@@ -50,6 +51,7 @@ module('Acceptance | groups | read', function (hooks) {
test('visiting a group', async function (assert) {
await visit(urls.newGroup);
await a11yAudit();
assert.strictEqual(currentURL(), urls.newGroup);
});
@@ -58,7 +60,8 @@ module('Acceptance | groups | read', function (hooks) {
instances.group.authorized_actions =
instances.group.authorized_actions.filter((item) => item !== 'read');
await visit(urls.group);
assert.notOk(find('main tbody .rose-table-header-cell:nth-child(1) a'));
assert.dom(commonSelectors.TABLE_FIRST_ROW_RESOURCE_LINK).doesNotExist();
});
test('users can navigate to group and incorrect url autocorrects', async function (assert) {