vault/ui/tests/integration/components/console/ui-panel-test.js
Matthew Irish aee6566bb6
UI - no jquery (#6768)
* 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
2019-06-20 08:37:27 -05:00

87 lines
3.0 KiB
JavaScript

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { create } from 'ember-cli-page-object';
import uiPanel from 'vault/tests/pages/components/console/ui-panel';
import hbs from 'htmlbars-inline-precompile';
const component = create(uiPanel);
module('Integration | Component | console/ui panel', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
await render(hbs`{{console/ui-panel}}`);
assert.ok(component.hasInput);
});
test('it clears console input on enter', async function(assert) {
await render(hbs`{{console/ui-panel}}`);
await component.runCommands('list this/thing/here');
assert.equal(component.consoleInputValue, '', 'empties input field on enter');
});
test('it clears the log when using clear command', async function(assert) {
await render(hbs`{{console/ui-panel}}`);
await component.runCommands(['list this/thing/here', 'list this/other/thing', 'read another/thing']);
assert.notEqual(component.logOutput, '', 'there is output in the log');
await component.runCommands('clear');
await component.up();
assert.equal(component.logOutput, '', 'clears the output log');
assert.equal(
component.consoleInputValue,
'clear',
'populates console input with previous command on up after enter'
);
});
test('it adds command to history on enter', async function(assert) {
await render(hbs`{{console/ui-panel}}`);
await component.runCommands('list this/thing/here');
await component.up();
assert.equal(
component.consoleInputValue,
'list this/thing/here',
'populates console input with previous command on up after enter'
);
await component.down();
assert.equal(component.consoleInputValue, '', 'populates console input with next command on down');
});
test('it cycles through history with more than one command', async function(assert) {
await render(hbs`{{console/ui-panel}}`);
await component.runCommands(['list this/thing/here', 'read that/thing/there', 'qwerty']);
await component.up();
assert.equal(
component.consoleInputValue,
'qwerty',
'populates console input with previous command on up after enter'
);
await component.up();
assert.equal(
component.consoleInputValue,
'read that/thing/there',
'populates console input with previous command on up'
);
await component.up();
assert.equal(
component.consoleInputValue,
'list this/thing/here',
'populates console input with previous command on up'
);
await component.up();
assert.equal(
component.consoleInputValue,
'qwerty',
'populates console input with initial command if cycled through all previous commands'
);
await component.down();
assert.equal(
component.consoleInputValue,
'',
'clears console input if down pressed after history is on most recent command'
);
});
});