github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/tests/integration/components/das/dismissed-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupRenderingTest } from 'ember-qunit'; 3 import { click, render } from '@ember/test-helpers'; 4 import { hbs } from 'ember-cli-htmlbars'; 5 import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit'; 6 import sinon from 'sinon'; 7 8 module('Integration | Component | das/dismissed', function (hooks) { 9 setupRenderingTest(hooks); 10 11 hooks.beforeEach(function () { 12 window.localStorage.clear(); 13 }); 14 15 test('it renders the dismissal interstitial with a button to proceed and an option to never show again and proceeds manually', async function (assert) { 16 assert.expect(3); 17 18 const proceedSpy = sinon.spy(); 19 this.set('proceedSpy', proceedSpy); 20 21 await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`); 22 23 await componentA11yAudit(this.element, assert); 24 25 await click('input[type=checkbox]'); 26 await click('[data-test-understood]'); 27 28 assert.ok(proceedSpy.calledWith({ manuallyDismissed: true })); 29 assert.equal( 30 window.localStorage.getItem('nomadRecommendationDismssalUnderstood'), 31 'true' 32 ); 33 }); 34 35 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) { 36 assert.expect(3); 37 38 window.localStorage.setItem('nomadRecommendationDismssalUnderstood', true); 39 40 const proceedSpy = sinon.spy(); 41 this.set('proceedSpy', proceedSpy); 42 43 await render(hbs`<Das::Dismissed @proceed={{proceedSpy}} />`); 44 45 assert.dom('[data-test-understood]').doesNotExist(); 46 47 await componentA11yAudit(this.element, assert); 48 49 assert.ok(proceedSpy.calledWith({ manuallyDismissed: false })); 50 }); 51 });