open-nomad/ui/tests/integration/components/das/dismissed-test.js

48 lines
1.6 KiB
JavaScript
Raw Normal View History

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { click, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
import sinon from 'sinon';
2021-12-28 14:45:20 +00:00
module('Integration | Component | das/dismissed', function (hooks) {
setupRenderingTest(hooks);
2021-12-28 14:45:20 +00:00
hooks.beforeEach(function () {
window.localStorage.clear();
});
2021-12-28 14:45:20 +00:00
test('it renders the dismissal interstitial with a button to proceed and an option to never show again and proceeds manually', async function (assert) {
const proceedSpy = sinon.spy();
this.set('proceedSpy', proceedSpy);
await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`);
await componentA11yAudit(this.element, assert);
await click('input[type=checkbox]');
await click('[data-test-understood]');
assert.ok(proceedSpy.calledWith({ manuallyDismissed: true }));
2021-12-28 16:08:12 +00:00
assert.equal(
window.localStorage.getItem('nomadRecommendationDismssalUnderstood'),
'true'
);
});
2021-12-28 14:45:20 +00:00
test('it renders the dismissal interstitial with no button when the option to never show again has been chosen and proceeds automatically', async function (assert) {
window.localStorage.setItem('nomadRecommendationDismssalUnderstood', true);
const proceedSpy = sinon.spy();
this.set('proceedSpy', proceedSpy);
await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`);
assert.dom('[data-test-understood]').doesNotExist();
await componentA11yAudit(this.element, assert);
assert.ok(proceedSpy.calledWith({ manuallyDismissed: false }));
});
});