@@ -233,10 +233,32 @@ describe('reordering simple grid', () => {
233233 } ) ;
234234
235235 it ( 'should reorder multiple columns while dragging' , ( ) => {
236+ // Start column order [1, 2, 3, 4]
237+
238+ // Drag column 1 on top of column 2. Expected order [2, 1, 3, 4]
236239 dragOver ( headerContent [ 0 ] , headerContent [ 1 ] ) ;
240+ // Keep dragging the column all the way over to the last column. Expected order [2, 3, 4, 1]
237241 dragOver ( headerContent [ 0 ] , headerContent [ 3 ] ) ;
238242 flushGrid ( grid ) ;
239- expectVisualOrder ( grid , [ 2 , 4 , 3 , 1 ] ) ;
243+ expectVisualOrder ( grid , [ 2 , 3 , 4 , 1 ] ) ;
244+ } ) ;
245+
246+ it ( 'should shift columns in between when dragged as last' , ( ) => {
247+ // Start column order [1, 2, 3, 4]
248+
249+ // Drag column 2 all the way over to the last column. Expected order [1, 3, 4, 2]
250+ dragOver ( headerContent [ 1 ] , headerContent [ 3 ] ) ;
251+ flushGrid ( grid ) ;
252+ expectVisualOrder ( grid , [ 1 , 3 , 4 , 2 ] ) ;
253+ } ) ;
254+
255+ it ( 'should shift columns in between when dragged as first' , ( ) => {
256+ // Start column order [1, 2, 3, 4]
257+
258+ // Drag column 3 over the very first column. Expected order [3, 1, 2, 4]
259+ dragOver ( headerContent [ 2 ] , headerContent [ 0 ] ) ;
260+ flushGrid ( grid ) ;
261+ expectVisualOrder ( grid , [ 3 , 1 , 2 , 4 ] ) ;
240262 } ) ;
241263
242264 it ( 'should update first-column attribute' , ( ) => {
@@ -378,8 +400,8 @@ describe('reordering grid with columns groups', () => {
378400
379401 beforeEach ( async ( ) => {
380402 grid = fixtureSync ( `
381- <vaadin-grid style="width: 400px ; height: 200px;" size="1" column-reordering-allowed>
382- ${ [ 1 , 2 ] . map ( ( colgroup ) => {
403+ <vaadin-grid style="width: 800px ; height: 200px;" size="1" column-reordering-allowed>
404+ ${ [ 1 , 2 , 3 ] . map ( ( colgroup ) => {
383405 return `
384406 <vaadin-grid-column-group>
385407 <template class="header">${ colgroup } </template>
@@ -425,6 +447,20 @@ describe('reordering grid with columns groups', () => {
425447 expectVisualOrder ( grid , [ 21 , 22 , 11 , 12 ] ) ;
426448 } ) ;
427449
450+ it ( 'should reorder all the groups' , ( ) => {
451+ // Start order
452+ // [1, 2, 3 ] <- groups
453+ // [11, 12, 21, 22, 31, 32] <- columns
454+
455+ // Drag the first group over the last group
456+ dragAndDropOver ( getVisualHeaderCellContent ( grid , 0 , 0 ) , getVisualHeaderCellContent ( grid , 0 , 5 ) ) ;
457+
458+ // Expected order
459+ // [2, 3, 1 ] <- groups
460+ // [21, 22, 31, 32, 11, 12] <- columns
461+ expectVisualOrder ( grid , [ 21 , 22 , 31 , 32 , 11 , 12 ] ) ;
462+ } ) ;
463+
428464 it ( 'should allow dropping group over other groups column header' , ( ) => {
429465 dragAndDropOver ( getVisualHeaderCellContent ( grid , 0 , 0 ) , getVisualHeaderCellContent ( grid , 1 , 3 ) ) ;
430466 expectVisualOrder ( grid , [ 21 , 22 , 11 , 12 ] ) ;
0 commit comments