open-vault/ui/tests/integration/components/identity/item-details-test.js
Matthew Irish 757afb4de9
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

56 lines
1.9 KiB
JavaScript

import { resolve } from 'rsvp';
import EmberObject from '@ember/object';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import sinon from 'sinon';
import { create } from 'ember-cli-page-object';
import itemDetails from 'vault/tests/pages/components/identity/item-details';
const component = create(itemDetails);
module('Integration | Component | identity/item details', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function() {
this.owner.lookup('service:flash-messages').registerTypes(['success']);
});
test('it renders the disabled warning', async function(assert) {
let model = EmberObject.create({
save() {
return resolve();
},
disabled: true,
canEdit: true,
});
sinon.spy(model, 'save');
this.set('model', model);
await render(hbs`{{identity/item-details model=model}}`);
assert.dom('[data-test-disabled-warning]').exists();
await component.enable();
assert.ok(model.save.calledOnce, 'clicking enable calls model save');
});
test('it does not render the button if canEdit is false', async function(assert) {
let model = EmberObject.create({
disabled: true,
});
this.set('model', model);
await render(hbs`{{identity/item-details model=model}}`);
assert.dom('[data-test-disabled-warning]').exists('shows the warning banner');
assert.dom('[data-test-enable]').doesNotExist('does not show the enable button');
});
test('it does not render the banner when item is enabled', async function(assert) {
let model = EmberObject.create();
this.set('model', model);
await render(hbs`{{identity/item-details model=model}}`);
assert.dom('[data-test-disabled-warning]').doesNotExist('does not show the warning banner');
});
});