vault/ui/tests/integration/components/secrets-engine-mount-config-test.js
Dan Rivera 008835ba36
UI: Surface plugin version & cleanup utils (#31001)
* surface plugin version & removing mountable-auth-methods.js

* UI: Removing mountable-secret-engines.js (#30950)

* first pass, removing all related imports

* fix usage

* fix category

* fix typos

* fix more tests

* fix more tests pt2

* attempting WIF const removal

* fix wif tests, removing config consts

* fixing tests

* please

* removing fallback

* cleanup

* fix type ent test

* remove isaddon

* Revert "remove isaddon"

This reverts commit ee114197b7299711e35e3c8e5aca9694063726eb.

* adding tab click

* update case

* fix case, rename to isOnlyMountable

* fix backend form

* more test fix

* adding changelog

* pr comments

* renaming params, adding requiresADP

* updates

* updates and pr comments

* perhaps update the test
2025-06-19 15:10:09 -04:00

78 lines
2.9 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { GENERAL } from 'vault/tests/helpers/general-selectors';
import SecretsEngineResource from 'vault/resources/secrets/engine';
const selectors = {
toggle: '[data-test-mount-config-toggle]',
field: '[data-test-mount-config-field]',
};
module('Integration | Component | secrets-engine-mount-config', function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.secretsEngine = new SecretsEngineResource({
path: 'ldap-test/',
type: 'ldap',
accessor: 'ldap_7e838627',
local: false,
sealWrap: true,
config: {
id: 'foo',
defaultLeaseTtl: 0,
maxLeaseTtl: 10000,
},
});
});
test('it should toggle config fields visibility', async function (assert) {
await render(hbs`<SecretsEngineMountConfig @secretsEngine={{this.secretsEngine}} />`);
assert
.dom(selectors.toggle)
.hasText('Show mount configuration', 'Correct toggle copy renders when closed');
assert.dom(selectors.field).doesNotExist('Mount config fields are hidden');
await click(selectors.toggle);
assert.dom(selectors.toggle).hasText('Hide mount configuration', 'Correct toggle copy renders when open');
assert.dom(selectors.field).exists('Mount config fields are visible');
});
test('it should render correct config fields', async function (assert) {
await render(hbs`<SecretsEngineMountConfig @secretsEngine={{this.secretsEngine}} />`);
await click(selectors.toggle);
assert
.dom(GENERAL.infoRowValue('Secret engine type'))
.hasText(this.secretsEngine.engineType, 'Secret engine type renders');
assert.dom(GENERAL.infoRowValue('Path')).hasText(this.secretsEngine.path, 'Path renders');
assert.dom(GENERAL.infoRowValue('Accessor')).hasText(this.secretsEngine.accessor, 'Accessor renders');
assert.dom(GENERAL.infoRowValue('Local')).includesText('No', 'Local renders');
assert.dom(GENERAL.infoRowValue('Seal wrap')).includesText('Yes', 'Seal wrap renders');
assert.dom(GENERAL.infoRowValue('Default Lease TTL')).includesText('0', 'Default Lease TTL renders');
assert
.dom(GENERAL.infoRowValue('Max Lease TTL'))
.includesText('2 hours 46 minutes 40 seconds', 'Max Lease TTL renders');
});
test('it should yield block for additional fields', async function (assert) {
await render(hbs`
<SecretsEngineMountConfig @secretsEngine={{this.secretsEngine}}>
<span data-test-yield>It Yields!</span>
</SecretsEngineMountConfig>
`);
await click(selectors.toggle);
assert.dom('[data-test-yield]').hasText('It Yields!', 'Component yields block for additional fields');
});
});