@@ -8,6 +8,8 @@ import { setupRenderingTest } from 'ember-qunit';
8
8
import {
9
9
click ,
10
10
render ,
11
+ rerender ,
12
+ triggerKeyEvent ,
11
13
resetOnerror ,
12
14
setupOnerror ,
13
15
settled ,
@@ -138,11 +140,33 @@ module('Integration | Component | hds/modal/index', function (hooks) {
138
140
assert . dom ( '#test-modal' ) . isNotVisible ( ) ;
139
141
} ) ;
140
142
test ( 'it should not close the modal when `@isDismissDisabled` is `true`' , async function ( assert ) {
143
+ this . set ( 'isDismissDisabled' , true ) ;
141
144
await render (
142
- hbs `<Hds::Modal @isDismissDisabled={{true}} id="test-modal" as |M|><M.Header>Title</M.Header></Hds::Modal>`
145
+ hbs `<Hds::Modal @isDismissDisabled={{this.isDismissDisabled}} id="test-modal" as |M|>
146
+ <M.Header>Title</M.Header>
147
+ <M.Footer as |F|>
148
+ <Hds::Button id="cancel-button" type="button" @text="Cancel" @color="secondary" {{on "click" F.close}} />
149
+ </M.Footer>
150
+ </Hds::Modal>`
143
151
) ;
152
+ // top right dismiss button
144
153
await click ( 'button.hds-modal__dismiss' ) ;
145
- assert . dom ( '#test-modal' ) . exists ( ) ;
154
+ assert . dom ( '#test-modal' ) . isVisible ( ) ;
155
+ // cancel button with yielded "close" callback
156
+ await click ( '#cancel-button' ) ;
157
+ assert . dom ( '#test-modal' ) . isVisible ( ) ;
158
+ // click on overlay
159
+ await click ( '.hds-modal__overlay' ) ;
160
+ assert . dom ( '#test-modal' ) . isVisible ( ) ;
161
+ // "esc" key
162
+ await triggerKeyEvent ( '.hds-modal' , 'keydown' , 'Escape' ) ;
163
+ assert . dom ( '#test-modal' ) . isVisible ( ) ;
164
+
165
+ // now let's check that the state is reset and it can be closed
166
+ this . set ( 'isDismissDisabled' , false ) ;
167
+ await rerender ( ) ;
168
+ await click ( 'button.hds-modal__dismiss' ) ;
169
+ assert . dom ( '#test-modal' ) . isNotVisible ( ) ;
146
170
} ) ;
147
171
148
172
// ACCESSIBILITY
0 commit comments