@@ -5,6 +5,7 @@ import '../vaadin-dashboard.js';
5
5
import { isSafari } from '@vaadin/component-base/src/browser-utils.js' ;
6
6
import type { Dashboard , DashboardItem } from '../vaadin-dashboard.js' ;
7
7
import {
8
+ describeBidirectional ,
8
9
expectLayout ,
9
10
fireResizeEnd ,
10
11
fireResizeOver ,
@@ -51,89 +52,91 @@ describe('dashboard - widget resizing', () => {
51
52
} ) ;
52
53
53
54
describe ( 'mouse drag' , ( ) => {
54
- it ( 'should resize a widget while dragging (start -> end)' , async ( ) => {
55
- // Start dragging the first widget resize handle
56
- fireResizeStart ( getElementFromCell ( dashboard , 0 , 0 ) ! ) ;
57
- await nextFrame ( ) ;
55
+ describeBidirectional ( 'horizontal' , ( ) => {
56
+ it ( 'should resize a widget while dragging (start -> end)' , async ( ) => {
57
+ // Start dragging the first widget resize handle
58
+ fireResizeStart ( getElementFromCell ( dashboard , 0 , 0 ) ! ) ;
59
+ await nextFrame ( ) ;
58
60
59
- // Drag over the end edge of the second one
60
- fireResizeOver ( getElementFromCell ( dashboard , 0 , 1 ) ! , 'end' ) ;
61
- await nextFrame ( ) ;
61
+ // Drag over the end edge of the second one
62
+ fireResizeOver ( getElementFromCell ( dashboard , 0 , 1 ) ! , 'end' ) ;
63
+ await nextFrame ( ) ;
62
64
63
- fireResizeEnd ( dashboard ) ;
64
- await nextFrame ( ) ;
65
+ fireResizeEnd ( dashboard ) ;
66
+ await nextFrame ( ) ;
65
67
66
- // Expect the widgets to be reordered
67
- // prettier-ignore
68
- expectLayout ( dashboard , [
69
- [ 0 , 0 ] ,
70
- [ 1 ] ,
71
- ] ) ;
72
- } ) ;
68
+ // Expect the widgets to be reordered
69
+ // prettier-ignore
70
+ expectLayout ( dashboard , [
71
+ [ 0 , 0 ] ,
72
+ [ 1 ] ,
73
+ ] ) ;
74
+ } ) ;
73
75
74
- it ( 'should not resize if dragged barely over another widget (start -> end)' , async ( ) => {
75
- fireResizeStart ( getElementFromCell ( dashboard , 0 , 0 ) ! ) ;
76
- await nextFrame ( ) ;
76
+ it ( 'should not resize if dragged barely over another widget (start -> end)' , async ( ) => {
77
+ fireResizeStart ( getElementFromCell ( dashboard , 0 , 0 ) ! ) ;
78
+ await nextFrame ( ) ;
77
79
78
- fireResizeOver ( getElementFromCell ( dashboard , 0 , 1 ) ! , 'start' ) ;
79
- await nextFrame ( ) ;
80
+ fireResizeOver ( getElementFromCell ( dashboard , 0 , 1 ) ! , 'start' ) ;
81
+ await nextFrame ( ) ;
80
82
81
- fireResizeEnd ( dashboard ) ;
82
- await nextFrame ( ) ;
83
+ fireResizeEnd ( dashboard ) ;
84
+ await nextFrame ( ) ;
83
85
84
- // prettier-ignore
85
- expectLayout ( dashboard , [
86
- [ 0 , 1 ] ,
87
- ] ) ;
88
- } ) ;
86
+ // prettier-ignore
87
+ expectLayout ( dashboard , [
88
+ [ 0 , 1 ] ,
89
+ ] ) ;
90
+ } ) ;
89
91
90
- it ( 'should resize a widget while dragging (end -> start)' , async ( ) => {
91
- dashboard . items = [ { id : 0 , colspan : 2 } , { id : 1 } ] ;
92
- await nextFrame ( ) ;
93
- // prettier-ignore
94
- expectLayout ( dashboard , [
95
- [ 0 , 0 ] ,
96
- [ 1 ] ,
97
- ] ) ;
92
+ it ( 'should resize a widget while dragging (end -> start)' , async ( ) => {
93
+ dashboard . items = [ { id : 0 , colspan : 2 } , { id : 1 } ] ;
94
+ await nextFrame ( ) ;
95
+ // prettier-ignore
96
+ expectLayout ( dashboard , [
97
+ [ 0 , 0 ] ,
98
+ [ 1 ] ,
99
+ ] ) ;
98
100
99
- fireResizeStart ( getElementFromCell ( dashboard , 0 , 1 ) ! ) ;
100
- await nextFrame ( ) ;
101
+ fireResizeStart ( getElementFromCell ( dashboard , 0 , 1 ) ! ) ;
102
+ await nextFrame ( ) ;
101
103
102
- fireResizeOver ( getElementFromCell ( dashboard , 0 , 0 ) ! , 'start' ) ;
103
- await nextFrame ( ) ;
104
+ fireResizeOver ( getElementFromCell ( dashboard , 0 , 0 ) ! , 'start' ) ;
105
+ await nextFrame ( ) ;
104
106
105
- fireResizeEnd ( dashboard ) ;
106
- await nextFrame ( ) ;
107
+ fireResizeEnd ( dashboard ) ;
108
+ await nextFrame ( ) ;
107
109
108
- // prettier-ignore
109
- expectLayout ( dashboard , [
110
- [ 0 , 1 ] ,
111
- ] ) ;
112
- } ) ;
110
+ // prettier-ignore
111
+ expectLayout ( dashboard , [
112
+ [ 0 , 1 ] ,
113
+ ] ) ;
114
+ } ) ;
113
115
114
- it ( 'should not resize if dragged barely over another widget (end -> start)' , async ( ) => {
115
- dashboard . items = [ { id : 0 , colspan : 2 } , { id : 1 } ] ;
116
- await nextFrame ( ) ;
117
- // prettier-ignore
118
- expectLayout ( dashboard , [
119
- [ 0 , 0 ] ,
120
- [ 1 ] ,
121
- ] ) ;
116
+ it ( 'should not resize if dragged barely over another widget (end -> start)' , async ( ) => {
117
+ dashboard . items = [ { id : 0 , colspan : 2 } , { id : 1 } ] ;
118
+ await nextFrame ( ) ;
119
+ // prettier-ignore
120
+ expectLayout ( dashboard , [
121
+ [ 0 , 0 ] ,
122
+ [ 1 ] ,
123
+ ] ) ;
122
124
123
- fireResizeStart ( getElementFromCell ( dashboard , 0 , 1 ) ! ) ;
124
- await nextFrame ( ) ;
125
+ fireResizeStart ( getElementFromCell ( dashboard , 0 , 1 ) ! ) ;
126
+ await nextFrame ( ) ;
125
127
126
- fireResizeOver ( getElementFromCell ( dashboard , 0 , 0 ) ! , 'end' ) ;
127
- await nextFrame ( ) ;
128
+ fireResizeOver ( getElementFromCell ( dashboard , 0 , 0 ) ! , 'end' ) ;
129
+ await nextFrame ( ) ;
128
130
129
- fireResizeEnd ( dashboard ) ;
130
- await nextFrame ( ) ;
131
+ fireResizeEnd ( dashboard ) ;
132
+ await nextFrame ( ) ;
131
133
132
- // prettier-ignore
133
- expectLayout ( dashboard , [
134
- [ 0 , 0 ] ,
135
- [ 1 ] ,
136
- ] ) ;
134
+ // prettier-ignore
135
+ expectLayout ( dashboard , [
136
+ [ 0 , 0 ] ,
137
+ [ 1 ] ,
138
+ ] ) ;
139
+ } ) ;
137
140
} ) ;
138
141
139
142
it ( 'should resize a widget while dragging (top -> bottom)' , async ( ) => {
0 commit comments