-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathedit-grants-test.js
More file actions
79 lines (64 loc) · 2.2 KB
/
edit-grants-test.js
File metadata and controls
79 lines (64 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { visit, click, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'admin/tests/helpers';
import * as selectors from './selectors';
import { setRunOptions } from 'ember-a11y-testing/test-support';
module('Acceptance | roles/edit grants', function (hooks) {
setupApplicationTest(hooks);
const instances = {
scopes: {
global: null,
},
role: null,
};
const urls = {
role: null,
editGrants: null,
};
hooks.beforeEach(async function () {
instances.scopes.global = this.server.schema.scopes.find('global');
instances.role = this.server.create('role', {
scope: instances.scopes.global,
});
urls.role = `/scopes/global/roles/${instances.role.id}`;
urls.editGrants = `${urls.role}/edit-grants`;
});
test('can navigate to edit grants for roles with proper authorization', async function (assert) {
setRunOptions({
rules: {
'color-contrast': {
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2026-02-27
enabled: false,
},
},
});
await visit(urls.role);
assert.true(instances.role.authorized_actions.includes('set-grants'));
await click(selectors.MANAGE_DROPDOWN_ROLES);
await click(selectors.MANAGE_DROPDOWN_EDIT_GRANTS);
assert.strictEqual(currentURL(), urls.editGrants);
});
test('cannot navigate to edit grants for roles without proper authorization', async function (assert) {
setRunOptions({
rules: {
'color-contrast': {
// [ember-a11y-ignore]: axe rule "color-contrast" automatically ignored on 2026-02-27
enabled: false,
},
},
});
instances.role.authorized_actions =
instances.role.authorized_actions.filter(
(action) => action !== 'set-grants',
);
await visit(urls.role);
assert.false(instances.role.authorized_actions.includes('set-grants'));
await click(selectors.MANAGE_DROPDOWN_ROLES);
assert.dom(selectors.MANAGE_DROPDOWN_EDIT_GRANTS).doesNotExist();
assert.strictEqual(currentURL(), urls.role);
});
});