2020-10-29 12:46:42 +00:00
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 ) {
2020-10-29 12:46:42 +00:00
setupRenderingTest ( hooks ) ;
2021-12-28 14:45:20 +00:00
hooks . beforeEach ( function ( ) {
2020-10-29 12:46:42 +00:00
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 ) {
2020-10-29 12:46:42 +00:00
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'
) ;
2020-10-29 12:46:42 +00:00
} ) ;
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 ) {
2020-10-29 12:46:42 +00:00
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 } ) ) ;
} ) ;
} ) ;