2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2021-11-08 21:29:00 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
2023-04-12 16:18:46 +00:00
|
|
|
import { render } from '@ember/test-helpers';
|
2021-11-08 21:29:00 +00:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
|
|
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
|
|
|
import mirageToModels from 'vault/tests/helpers/mirage-to-models';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Integration | Component | secret-list-header', function (hooks) {
|
2021-11-08 21:29:00 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
setupMirage(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it should render version badge for kv and generic engine types', async function (assert) {
|
2021-11-08 21:29:00 +00:00
|
|
|
const backends = supportedSecretBackends();
|
|
|
|
assert.expect(backends.length);
|
|
|
|
|
|
|
|
this.server.post('/sys/capabilities-self', () => {});
|
|
|
|
|
2022-11-09 23:15:31 +00:00
|
|
|
for (const type of backends) {
|
2021-11-08 21:29:00 +00:00
|
|
|
const data = this.server.create('secret-engine', 2, { type });
|
|
|
|
this.model = mirageToModels(data);
|
|
|
|
await render(hbs`
|
|
|
|
<SecretListHeader
|
|
|
|
@model={{this.model}}
|
|
|
|
/>
|
|
|
|
`);
|
|
|
|
const selector = '[data-test-kv-version-badge]';
|
2023-01-20 20:02:13 +00:00
|
|
|
|
2021-11-08 21:29:00 +00:00
|
|
|
if (['kv', 'generic'].includes(type)) {
|
|
|
|
assert
|
|
|
|
.dom(selector)
|
|
|
|
.hasText(
|
2022-10-18 15:46:02 +00:00
|
|
|
`Version ${this.model.version || 1}`,
|
2021-11-08 21:29:00 +00:00
|
|
|
`Badge renders with correct version for ${type} engine type`
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
assert.dom(selector).doesNotExist(`Version badge does not render for ${type} engine type`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|