vault/ui/tests/integration/components/kv/page/kv-page-secret-paths-test.js
claire bontempo 30da9aef46
UI: Build KV v2 overview page (#28106)
* move date-from-now helper to addon

* make overview cards consistent across engines

* make kv-paths-card component

* remove overview margin all together

* small styling changes for paths card

* small selector additions

* add overview card test

* add overview page and test

* add default timestamp format

* cleanup paths test

* fix dateFromNow import

* fix selectors, cleanup pki selectors

* and more selector cleanup

* make deactivated state single arg

* fix template and remove @isDeleted and @isDestroyed

* add test and hide badge unless deactivated

* address failings from changing selectors

* oops, not ready to show overview tab just yet!

* add deletionTime to currentSecret metadata getter
2024-08-16 14:40:23 -07:00

71 lines
2.2 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { setupEngine } from 'ember-engines/test-support';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { PAGE } from 'vault/tests/helpers/kv/kv-selectors';
module('Integration | Component | kv-v2 | Page::Secret::Paths', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'kv');
hooks.beforeEach(async function () {
this.backend = 'kv-engine';
this.path = 'my-secret';
this.canReadMetadata = true;
this.breadcrumbs = [
{ label: 'Secrets', route: 'secrets', linkExternal: true },
{ label: this.backend, route: 'list' },
{ label: this.path },
];
this.renderComponent = async () => {
await render(
hbs`
<Page::Secret::Paths
@path={{this.path}}
@backend={{this.backend}}
@breadcrumbs={{this.breadcrumbs}}
@canReadMetadata={{this.canReadMetadata}}
/>
`,
{ owner: this.engine }
);
};
});
test('it renders tabs', async function (assert) {
await this.renderComponent();
const tabs = ['Secret', 'Metadata', 'Paths', 'Version History'];
for (const tab of tabs) {
assert.dom(PAGE.secretTab(tab)).hasText(tab);
}
});
test('it hides version history when cannot READ metadata', async function (assert) {
this.canReadMetadata = false;
await this.renderComponent();
const tabs = ['Secret', 'Metadata', 'Paths'];
for (const tab of tabs) {
assert.dom(PAGE.secretTab(tab)).hasText(tab);
}
assert.dom(PAGE.secretTab('Version History')).doesNotExist();
});
test('it renders header', async function (assert) {
await this.renderComponent();
assert.dom(PAGE.breadcrumbs).hasText(`Secrets ${this.backend} ${this.path}`);
assert.dom(PAGE.title).hasText(this.path);
});
test('it renders commands which is the uncondensed version of KvPathsCard', async function (assert) {
await this.renderComponent();
assert.dom(PAGE.paths.codeSnippet('cli')).exists();
assert.dom(PAGE.paths.codeSnippet('api')).exists();
});
});