diff --git a/ui/admin/app/components/form/role/index.hbs b/ui/admin/app/components/form/role/index.hbs
index b5af5bd80..7d3758fe3 100644
--- a/ui/admin/app/components/form/role/index.hbs
+++ b/ui/admin/app/components/form/role/index.hbs
@@ -26,7 +26,7 @@
{{#if @model.errors.name}}
{{#each @model.errors.name as |error|}}
- {{error.message}}
+ {{error.message}}
{{/each}}
{{/if}}
diff --git a/ui/admin/app/components/roles/role/actions/index.hbs b/ui/admin/app/components/roles/role/actions/index.hbs
index 3f1aa3f0d..b9ac239b8 100644
--- a/ui/admin/app/components/roles/role/actions/index.hbs
+++ b/ui/admin/app/components/roles/role/actions/index.hbs
@@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
}}
-
+
{{#if (can 'addPrincipals role' @model)}}
item !== 'delete');
await visit(urls.role);
- assert.notOk(
- find('.rose-layout-page-actions .rose-dropdown-button-danger'),
- );
+
+ await click(selectors.MANAGE_DROPDOWN_ROLES);
+
+ assert.dom(selectors.MANAGE_DROPDOWN_ROLES_REMOVE).doesNotExist();
});
test('errors are displayed when delete project fails', async function (assert) {
@@ -90,8 +89,10 @@ module('Acceptance | roles | delete', function (hooks) {
);
});
await visit(urls.role);
- await click(MANAGE_DROPDOWN_SELECTOR);
- await click(DELETE_DROPDOWN_SELECTOR);
+
+ await click(selectors.MANAGE_DROPDOWN_ROLES);
+ await click(selectors.MANAGE_DROPDOWN_ROLES_REMOVE);
+
assert.dom(commonSelectors.ALERT_TOAST_BODY).hasText('Oops.');
});
});
diff --git a/ui/admin/tests/acceptance/roles/read-test.js b/ui/admin/tests/acceptance/roles/read-test.js
index 085d55192..34db697c7 100644
--- a/ui/admin/tests/acceptance/roles/read-test.js
+++ b/ui/admin/tests/acceptance/roles/read-test.js
@@ -4,12 +4,13 @@
*/
import { module, test } from 'qunit';
-import { visit, currentURL, click, find } from '@ember/test-helpers';
+import { visit, currentURL, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
import a11yAudit from 'ember-a11y-testing/test-support/audit';
import { authenticateSession } from 'ember-simple-auth/test-support';
+import * as commonSelectors from 'admin/tests/helpers/selectors';
module('Acceptance | roles | read', function (hooks) {
setupApplicationTest(hooks);
@@ -61,16 +62,17 @@ module('Acceptance | roles | read', function (hooks) {
test('visiting roles', async function (assert) {
await visit(urls.roles);
await a11yAudit();
+
assert.strictEqual(currentURL(), urls.roles);
});
test('can navigate to a role form', async function (assert) {
await visit(urls.orgScope);
- await click(`[href="${urls.roles}"]`);
-
- await click('main tbody .hds-table__tr:nth-child(1) a');
+ await click(commonSelectors.HREF(urls.roles));
+ await click(commonSelectors.TABLE_RESOURCE_LINK(urls.role));
await a11yAudit();
+
assert.strictEqual(currentURL(), urls.role);
});
@@ -78,7 +80,8 @@ module('Acceptance | roles | read', function (hooks) {
instances.role.authorized_actions =
instances.role.authorized_actions.filter((item) => item !== 'read');
await visit(urls.roles);
- assert.notOk(find('main tbody .hds-table__tr:nth-child(1) a'));
+
+ assert.dom(commonSelectors.TABLE_RESOURCE_LINK(urls.role)).doesNotExist();
});
test('can navigate to a roles and fetches scopes correctly', async function (assert) {
@@ -89,8 +92,10 @@ module('Acceptance | roles | read', function (hooks) {
});
await visit(urls.roles);
- await click('main tbody .hds-table__tr:nth-child(1) a');
+
+ await click(commonSelectors.TABLE_RESOURCE_LINK(urls.role));
await a11yAudit();
+
assert.strictEqual(currentURL(), urls.role);
});
diff --git a/ui/admin/tests/acceptance/roles/selectors.js b/ui/admin/tests/acceptance/roles/selectors.js
index b64cfb836..4dbdc3fcb 100644
--- a/ui/admin/tests/acceptance/roles/selectors.js
+++ b/ui/admin/tests/acceptance/roles/selectors.js
@@ -4,3 +4,11 @@
*/
export const NEW_ROLE_BTN = '[data-test-new-role-button]';
+
+export const MANAGE_DROPDOWN_ROLES = '[data-test-manage-roles-dropdown] button';
+export const MANAGE_DROPDOWN_ROLES_PRINCIPALS =
+ '[data-test-manage-dropdown-principals]';
+export const MANAGE_DROPDOWN_ROLES_SCOPES =
+ '[data-test-manage-dropdown-scopes]';
+export const MANAGE_DROPDOWN_ROLES_REMOVE =
+ '[data-test-manage-roles-dropdown] div:last-child button';
diff --git a/ui/admin/tests/acceptance/roles/update-test.js b/ui/admin/tests/acceptance/roles/update-test.js
index 75aa5f0c5..9ce99e8cb 100644
--- a/ui/admin/tests/acceptance/roles/update-test.js
+++ b/ui/admin/tests/acceptance/roles/update-test.js
@@ -4,7 +4,7 @@
*/
import { module, test } from 'qunit';
-import { visit, currentURL, click, fillIn, find } from '@ember/test-helpers';
+import { visit, currentURL, click, fillIn } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
@@ -24,7 +24,6 @@ module('Acceptance | roles | update', function (hooks) {
role: null,
};
const urls = {
- orgScope: null,
roles: null,
role: null,
newRole: null,
@@ -58,29 +57,42 @@ module('Acceptance | roles | update', function (hooks) {
test('can save changes to an existing role', async function (assert) {
await visit(urls.role);
- await click('form [type="button"]', 'Activate edit mode');
- await fillIn('[name="name"]', 'Updated admin role');
- await click('.rose-form-actions [type="submit"]');
+
+ await click(commonSelectors.EDIT_BTN);
+ await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
+ await click(commonSelectors.SAVE_BTN);
+
assert.strictEqual(currentURL(), urls.role);
- assert.strictEqual(this.server.db.roles[0].name, 'Updated admin role');
+ assert.strictEqual(
+ this.server.schema.roles.all().models[0].name,
+ commonSelectors.FIELD_NAME_VALUE,
+ );
});
test('cannot make changes to an existing role without proper authorization', async function (assert) {
instances.role.authorized_actions =
instances.role.authorized_actions.filter((item) => item !== 'update');
await visit(urls.role);
- assert.notOk(find('.rose-layout-page-actions .rose-button-secondary'));
+
+ assert.dom(commonSelectors.EDIT_BTN).doesNotExist();
});
test('can cancel changes to an existing role', async function (assert) {
await visit(urls.role);
- await click('form [type="button"]', 'Activate edit mode');
- await fillIn('[name="name"]', 'Updated admin role');
- await click('.rose-form-actions [type="button"]');
- assert.notEqual(find('[name="name"]').value, 'Updated admin role');
+
+ await click(commonSelectors.EDIT_BTN);
+ await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
+ await click(commonSelectors.CANCEL_BTN);
+
+ assert.notEqual(
+ this.server.schema.roles.all().models[0].name,
+ commonSelectors.FIELD_NAME_VALUE,
+ );
});
test('saving an existing role with invalid fields displays error messages', async function (assert) {
+ const errorMessage = 'Error in provided request.';
+ const errorDescription = 'Must be all lowercase.';
this.server.patch('/roles/:id', () => {
return new Response(
400,
@@ -88,12 +100,12 @@ module('Acceptance | roles | update', function (hooks) {
{
status: 400,
code: 'invalid_argument',
- message: 'The request was invalid.',
+ message: errorMessage,
details: {
request_fields: [
{
name: 'name',
- description: 'Name is required.',
+ description: errorDescription,
},
],
},
@@ -101,16 +113,11 @@ module('Acceptance | roles | update', function (hooks) {
);
});
await visit(urls.role);
- await click('form [type="button"]', 'Activate edit mode');
- await fillIn('[name="name"]', 'random string');
- await click('[type="submit"]');
- assert
- .dom(commonSelectors.ALERT_TOAST_BODY)
- .hasText('The request was invalid.');
- assert.strictEqual(
- find('.hds-form-error__message').textContent.trim(),
- 'Name is required.',
- 'Displays field-level errors.',
- );
+ await click(commonSelectors.EDIT_BTN);
+ await fillIn(commonSelectors.FIELD_NAME, commonSelectors.FIELD_NAME_VALUE);
+ await click(commonSelectors.SAVE_BTN);
+
+ assert.dom(commonSelectors.ALERT_TOAST_BODY).hasText(errorMessage);
+ assert.dom(commonSelectors.FIELD_NAME_ERROR).hasText(errorDescription);
});
});