open-vault/ui/tests/integration/components/pki/page/pki-role-details-test.js
claire bontempo db1d3bc519
ui: add capabilities to pki key model (#18412)
* add capabilities to pki key model

* move key list from route into component

* rename test file

* rename test file

* add tests

* pass capabilities directly to key list componente

* add test for key list component

* rename test files

* remove href assertion
2022-12-16 22:13:59 +00:00

60 lines
2 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupEngine } from 'ember-engines/test-support';
import { SELECTORS } from 'vault/tests/helpers/pki/page/pki-role-details';
module('Integration | Component | pki role details page', function (hooks) {
setupRenderingTest(hooks);
setupEngine(hooks, 'pki');
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.model = this.store.createRecord('pki/role', {
name: 'Foobar',
backend: 'pki',
noStore: false,
keyUsage: [],
extKeyUsage: ['bar', 'baz'],
ttl: 600,
});
});
test('it should render the page component', async function (assert) {
assert.expect(5);
await render(
hbs`
<Page::PkiRoleDetails @role={{this.model}} />
`,
{ owner: this.engine }
);
assert.dom(SELECTORS.issuerLabel).hasText('Issuer', 'Label is');
assert.dom(SELECTORS.keyUsageValue).hasText('None', 'Key usage shows none when array is empty');
assert
.dom(SELECTORS.extKeyUsageValue)
.hasText('bar, baz,', 'Key usage shows comma-joined values when array has items');
assert.dom(SELECTORS.noStoreValue).containsText('Yes', 'noStore shows opposite of what the value is');
assert.dom(SELECTORS.customTtlValue).containsText('10m', 'TTL shown as duration');
});
test('it should render the notAfter date if present', async function (assert) {
assert.expect(1);
this.model = this.store.createRecord('pki/role', {
name: 'Foobar',
backend: 'pki',
noStore: false,
keyUsage: [],
extKeyUsage: ['bar', 'baz'],
notAfter: '2030-05-04T12:00:00.000Z',
});
await render(
hbs`
<Page::PkiRoleDetails @role={{this.model}} />
`,
{ owner: this.engine }
);
assert.dom(SELECTORS.customTtlValue).containsText('May', 'Formats the notAfter date instead of TTL');
});
});