1
1
import { expect } from '@esm-bundle/chai' ;
2
2
import { click , fixtureSync , listenOnce , mousedown , nextFrame } from '@vaadin/testing-helpers' ;
3
+ import { sendKeys } from '@web/test-runner-commands' ;
3
4
import sinon from 'sinon' ;
4
5
import {
5
6
fire ,
@@ -252,6 +253,73 @@ describe('multi selection column', () => {
252
253
expect ( grid . selectedItems ) . to . eql ( [ ] ) ;
253
254
} ) ;
254
255
256
+ it ( 'should add the item to selectedItems on selection column cell Space key' , async ( ) => {
257
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
258
+ cell . focus ( ) ;
259
+ await sendKeys ( { press : 'Space' } ) ;
260
+
261
+ expect ( grid . selectedItems ) . to . eql ( [ grid . items [ 1 ] ] ) ;
262
+ } ) ;
263
+
264
+ it ( 'should remove the item from selectedItems on selection column cell Space key' , async ( ) => {
265
+ grid . selectItem ( grid . items [ 1 ] ) ;
266
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
267
+
268
+ cell . focus ( ) ;
269
+ await sendKeys ( { press : 'Space' } ) ;
270
+
271
+ expect ( grid . selectedItems ) . to . eql ( [ ] ) ;
272
+ } ) ;
273
+
274
+ it ( 'should add the item to selectedItems on selection column cell Space key when autoSelect is false' , async ( ) => {
275
+ selectionColumn . autoSelect = false ;
276
+
277
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
278
+ cell . focus ( ) ;
279
+ await sendKeys ( { press : 'Space' } ) ;
280
+
281
+ expect ( grid . selectedItems ) . to . eql ( [ grid . items [ 1 ] ] ) ;
282
+ } ) ;
283
+
284
+ it ( 'should remove the item from selectedItems on selection column cell Space key when autoSelect is false' , async ( ) => {
285
+ selectionColumn . autoSelect = false ;
286
+
287
+ grid . selectItem ( grid . items [ 1 ] ) ;
288
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
289
+ cell . focus ( ) ;
290
+ await sendKeys ( { press : 'Space' } ) ;
291
+
292
+ expect ( grid . selectedItems ) . to . eql ( [ ] ) ;
293
+ } ) ;
294
+
295
+ it ( 'should add the item to selectedItems on selection column checkbox Space key' , async ( ) => {
296
+ selectionColumn . autoSelect = false ;
297
+
298
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
299
+ cell . focus ( ) ;
300
+
301
+ // Enter interaction mode to focus checkbox
302
+ await sendKeys ( { press : 'Enter' } ) ;
303
+ await sendKeys ( { press : 'Space' } ) ;
304
+
305
+ expect ( grid . selectedItems ) . to . eql ( [ grid . items [ 1 ] ] ) ;
306
+ } ) ;
307
+
308
+ it ( 'should remove the item from selectedItems on selection column checkbox Space key' , async ( ) => {
309
+ selectionColumn . autoSelect = false ;
310
+
311
+ grid . selectItem ( grid . items [ 1 ] ) ;
312
+
313
+ const cell = getRowCells ( rows [ 1 ] ) [ 0 ] ;
314
+ cell . focus ( ) ;
315
+
316
+ // Enter interaction mode to focus checkbox
317
+ await sendKeys ( { press : 'Enter' } ) ;
318
+ await sendKeys ( { press : 'Space' } ) ;
319
+
320
+ expect ( grid . selectedItems ) . to . eql ( [ ] ) ;
321
+ } ) ;
322
+
255
323
it ( 'should have bound the body checkbox to selected items' , ( ) => {
256
324
const selectCheckbox = firstBodyCheckbox ;
257
325
@@ -274,6 +342,21 @@ describe('multi selection column', () => {
274
342
expect ( selectionColumn . selectAll ) . to . be . true ;
275
343
} ) ;
276
344
345
+ it ( 'should set selectAll on header cell Space key' , async ( ) => {
346
+ const headerCell = getRowCells ( headerRows [ 1 ] ) [ 0 ] ;
347
+ headerCell . focus ( ) ;
348
+ await sendKeys ( { press : 'Space' } ) ;
349
+ expect ( selectionColumn . selectAll ) . to . be . true ;
350
+ } ) ;
351
+
352
+ it ( 'should set selectAll on header cell checkbox Space key' , async ( ) => {
353
+ const headerCell = getRowCells ( headerRows [ 1 ] ) [ 0 ] ;
354
+ headerCell . focus ( ) ;
355
+ await sendKeys ( { press : 'Enter' } ) ;
356
+ await sendKeys ( { press : 'Space' } ) ;
357
+ expect ( selectionColumn . selectAll ) . to . be . true ;
358
+ } ) ;
359
+
277
360
it ( 'should select all items when select all is set' , ( ) => {
278
361
selectionColumn . selectAll = true ;
279
362
0 commit comments