757afb4de9
* add no-jquery rule and move event listeners to ember-concurrency tasks * remove unnecessary onchange and handleKeyDown actions * add element.closest polyfill and convert linked-block to use native dom apis * update pretender, fetch, page-object, add optional-features, remove ember/jquery * turn off jquery inclusion * remove jQuery.isPlainObject usage * violatedDirective isn't always formatted the same * use fetch and the ember-fetch adapter mixin * move to fetch and lowercase headers for pretender * display non-ember-data errors * use new async fn test style and lowercase headers in auth service test * setContext is not necessary with the new style tests and ember-cli-page-object - it actually triggers jquery usage * update ember-fetch, ember-cli-pretender * wait for permissions check * lowercase header name in auth test * refactor transit tests to one test per key type * simplify pollCluster helper * stop flakey tests by prefering the native fetch * avoid uncaught TransitionAborted error by navigating directly to unseal * unset model on controller after unloading it because controllers are singletons * update yarn.lock
102 lines
3.1 KiB
JavaScript
102 lines
3.1 KiB
JavaScript
import { resolve } from 'rsvp';
|
|
import { module, test } from 'qunit';
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
import { render } from '@ember/test-helpers';
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
import { create } from 'ember-cli-page-object';
|
|
import configPki from '../../pages/components/config-pki';
|
|
|
|
const component = create(configPki);
|
|
|
|
module('Integration | Component | config pki', function(hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
hooks.beforeEach(function() {
|
|
this.owner.lookup('service:flash-messages').registerTypes(['success']);
|
|
});
|
|
|
|
const config = function(saveFn) {
|
|
return {
|
|
save: saveFn,
|
|
rollbackAttributes: () => {},
|
|
tidyAttrs: [
|
|
{
|
|
type: 'boolean',
|
|
name: 'tidyCertStore',
|
|
},
|
|
{
|
|
type: 'string',
|
|
name: 'anotherAttr',
|
|
},
|
|
],
|
|
crlAttrs: [
|
|
{
|
|
type: 'string',
|
|
name: 'crl',
|
|
},
|
|
],
|
|
urlsAttrs: [
|
|
{
|
|
type: 'string',
|
|
name: 'urls',
|
|
},
|
|
],
|
|
};
|
|
};
|
|
|
|
const setupAndRender = async function(context, section = 'tidy') {
|
|
context.set('config', config());
|
|
context.set('section', section);
|
|
await context.render(hbs`{{config-pki section=section config=config}}`);
|
|
};
|
|
|
|
test('it renders tidy section', async function(assert) {
|
|
await setupAndRender(this);
|
|
assert.ok(component.text.startsWith('You can tidy up the backend'));
|
|
assert.notOk(component.hasTitle, 'No title for tidy section');
|
|
assert.equal(component.fields.length, 2);
|
|
assert.ok(component.fields.objectAt(0).labelText, 'Tidy cert store');
|
|
assert.ok(component.fields.objectAt(1).labelText, 'Another attr');
|
|
});
|
|
|
|
test('it renders crl section', async function(assert) {
|
|
await setupAndRender(this, 'crl');
|
|
assert.ok(component.hasTitle, 'renders the title');
|
|
assert.equal(component.title, 'Certificate Revocation List (CRL) config');
|
|
assert.ok(component.text.startsWith('Set the duration for which the generated CRL'));
|
|
assert.equal(component.fields.length, 1);
|
|
assert.ok(component.fields.objectAt(0).labelText, 'Crl');
|
|
});
|
|
|
|
test('it renders urls section', async function(assert) {
|
|
await setupAndRender(this, 'urls');
|
|
assert.notOk(component.hasTitle, 'No title for urls section');
|
|
assert.equal(component.fields.length, 1);
|
|
assert.ok(component.fields.objectAt(0).labelText, 'urls');
|
|
});
|
|
|
|
test('it calls save with the correct arguments', async function(assert) {
|
|
assert.expect(3);
|
|
const section = 'tidy';
|
|
this.set('onRefresh', () => {
|
|
assert.ok(true, 'refresh called');
|
|
});
|
|
this.set(
|
|
'config',
|
|
config(options => {
|
|
assert.equal(options.adapterOptions.method, section, 'method passed to save');
|
|
assert.deepEqual(
|
|
options.adapterOptions.fields,
|
|
['tidyCertStore', 'anotherAttr'],
|
|
'fields passed to save'
|
|
);
|
|
return resolve();
|
|
})
|
|
);
|
|
this.set('section', section);
|
|
await render(hbs`{{config-pki section=section config=config onRefresh=onRefresh}}`);
|
|
|
|
component.submit();
|
|
});
|
|
});
|