vault/ui/tests/integration/components/policy-example-test.js
Melanie Sumner ce639f84b9
Bug: fixed cases where CodeMirror textarea inputs did not have associated labels (#26263)
* fixes cases where inputs did not have associated labels

* add changelog entry

* update form-field test now that json editor has label

* remove label-related TODOs from other tests

---------

Co-authored-by: Noelle Daley <noelledaley@users.noreply.github.com>
2024-04-05 08:49:42 -05:00

99 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setRunOptions } from 'ember-a11y-testing/test-support';
const SELECTORS = {
policyText: '[data-test-modal-title]',
policyDescription: (type) => `[data-test-example-modal-text=${type}]`,
jsonText: '[data-test-component="code-mirror-modifier"]',
informationLink: '[data-test-example-modal-information-link]',
};
module('Integration | Component | policy-example', function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
setRunOptions({
rules: {
// failing on .CodeMirror-scroll
'scrollable-region-focusable': { enabled: false },
},
});
});
test('it renders the correct paragraph for ACL policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="acl"
/>
`);
assert
.dom(SELECTORS.policyDescription('acl'))
.hasText(
'ACL Policies are written in Hashicorp Configuration Language ( HCL ) or JSON and describe which paths in Vault a user or machine is allowed to access. Here is an example policy:'
);
});
test('it renders the correct paragraph for RGP policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="rgp"
/>
`);
assert
.dom(SELECTORS.policyDescription('rgp'))
.hasText(
'Role Governing Policies (RGPs) are tied to client tokens or identities which is similar to ACL policies . They use Sentinel as a language framework to enable fine-grained policy decisions.'
);
});
test('it renders the correct paragraph for EGP policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="egp"
/>
`);
assert
.dom(SELECTORS.policyDescription('egp'))
.hasText(
`Endpoint Governing Policies (EGPs) are tied to particular paths (e.g. aws/creds/ ) instead of tokens. They use Sentinel as a language to access properties of the incoming requests.`
);
});
test('it renders the correct JSON editor text for ACL policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="acl"
/>
`);
assert.dom(SELECTORS.jsonText).includesText(`# Grant 'create', 'read' , 'update', and list permission`);
});
test('it renders the correct JSON editor text for RGP policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="rgp"
/>
`);
assert
.dom(SELECTORS.jsonText)
.includesText(`# Import strings library that exposes common string operations`);
});
test('it renders the correct JSON editor text for EGP policy', async function (assert) {
await render(hbs`
<PolicyExample
@policyType="egp"
/>
`);
assert.dom(SELECTORS.jsonText).includesText(`# Expect requests to only happen during work days (Monday`);
});
});