github.com/hernad/nomad@v1.6.112/ui/tests/integration/components/das/dismissed-test.js (about)

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