22
33import { moveGutter , checkSplitDirAndSizes } from '../support/splitUtils'
44
5+ function checkEventCount ( { dragStartCount, dragEndCount, gutterClickCount, gutterDblClickCount, transitionEndCount } ) {
6+ if ( dragStartCount !== undefined ) {
7+ cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , dragStartCount )
8+ }
9+ if ( dragEndCount !== undefined ) {
10+ cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , dragEndCount )
11+ }
12+ if ( gutterClickCount !== undefined ) {
13+ cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , gutterClickCount )
14+ }
15+ if ( gutterDblClickCount !== undefined ) {
16+ cy . get ( '.logs ul li' ) . filter ( '.gutterDblClick' ) . should ( 'have.length' , gutterDblClickCount )
17+ }
18+ if ( transitionEndCount !== undefined ) {
19+ cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , transitionEndCount )
20+ }
21+ }
22+
523context ( 'Gutter click example page tests' , ( ) => {
624 const W = 1070
725 const H = 300
@@ -53,8 +71,8 @@ context('Gutter click example page tests', () => {
5371 it ( 'Mix gutter click and dragging' , ( ) => {
5472 // Try move gutter event if disabled
5573 moveGutter ( '.as-split-gutter' , 0 , - 100 , 0 )
74+ // gutterClick should be fired same as normal click event since dragging is disabled.
5675 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 262.5 , 525 , 262.5 ] )
57- cy . get ( '.logs ul li' ) . should ( 'have.length' , 0 )
5876
5977 // Enable gutters
6078 cy . get ( '.btns button' ) . eq ( 1 ) . click ( )
@@ -64,61 +82,65 @@ context('Gutter click example page tests', () => {
6482 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 162.5 , 625 , 262.5 ] )
6583 cy . wait ( 10 )
6684
67- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 1 )
68- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 1 )
85+ checkEventCount ( { dragStartCount : 1 , dragEndCount : 1 , gutterClickCount : 0 , transitionEndCount : 0 } )
6986
7087 // Click gutter1 to close area1
7188 cy . get ( '.as-split-gutter' ) . eq ( 0 ) . click ( )
7289 cy . wait ( 2000 )
7390 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 0 , 787.5 , 262.5 ] )
7491 cy . wait ( 10 )
7592
76- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 2 )
77- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 1 )
78- cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , 1 )
79- cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , 1 )
93+ checkEventCount ( { dragStartCount : 1 , dragEndCount : 1 , gutterClickCount : 1 , transitionEndCount : 1 } )
8094
8195 // Click gutter2 to close area3
8296 cy . get ( '.as-split-gutter' ) . eq ( 1 ) . click ( )
8397 cy . wait ( 2000 )
8498 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 0 , 1050 , 0 ] )
8599 cy . wait ( 10 )
86100
87- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 3 )
88- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 1 )
89- cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , 2 )
90- cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , 2 )
101+ checkEventCount ( { dragStartCount : 1 , dragEndCount : 1 , gutterClickCount : 2 , transitionEndCount : 2 } )
91102
92103 // Move gutter2 to enlarge area3
93104 moveGutter ( '.as-split-gutter' , 1 , - 20 , 0 )
94105 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 0 , 1030 , 20 ] )
95106
96- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 4 )
97- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 2 )
98- cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , 2 )
99- cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , 2 )
107+ checkEventCount ( { dragStartCount : 2 , dragEndCount : 2 , gutterClickCount : 2 , transitionEndCount : 2 } )
100108
101109 // Click gutter2 to close area3
102110 cy . get ( '.as-split-gutter' ) . eq ( 1 ) . click ( )
103111 cy . wait ( 2000 )
104112 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 0 , 1050 , 0 ] )
105113 cy . wait ( 10 )
106114
107- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 5 )
108- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 2 )
109- cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , 3 )
110- cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , 3 )
115+ checkEventCount ( { dragStartCount : 2 , dragEndCount : 2 , gutterClickCount : 3 , transitionEndCount : 3 } )
111116
112117 // Click gutter1 to display area1
113118 cy . get ( '.as-split-gutter' ) . eq ( 0 ) . click ( )
114119 cy . wait ( 2000 )
115120 checkSplitDirAndSizes ( '.split-example > as-split' , 'horizontal' , W , H , GUTTER , [ 262.5 , 787.5 , 0 ] )
116121 cy . wait ( 10 )
117122
118- cy . get ( '.logs ul li' ) . filter ( '.dragStart' ) . should ( 'have.length' , 6 )
119- cy . get ( '.logs ul li' ) . filter ( '.dragEnd' ) . should ( 'have.length' , 2 )
120- cy . get ( '.logs ul li' ) . filter ( '.gutterClick' ) . should ( 'have.length' , 4 )
121- cy . get ( '.logs ul li' ) . filter ( '.transitionEnd' ) . should ( 'have.length' , 4 )
123+ checkEventCount ( { dragStartCount : 2 , dragEndCount : 2 , gutterClickCount : 4 , transitionEndCount : 4 } )
124+
125+ // It should fire Click Event on mouseup if the mouse cursor is not moved.
126+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mousedown' , { which : 1 , clientX : 0 , clientY : 0 } )
127+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mousemove' , { which : 1 , clientX : 0 , clientY : 0 } )
128+ cy . wait ( 10 )
129+ checkEventCount ( { dragStartCount : 2 , dragEndCount : 2 , gutterClickCount : 4 , transitionEndCount : 4 } )
130+
131+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mouseup' , { which : 1 , clientX : 0 , clientY : 0 } )
132+ cy . wait ( 2000 )
133+ checkEventCount ( { dragStartCount : 2 , dragEndCount : 2 , gutterClickCount : 5 , transitionEndCount : 5 } )
134+
135+ // It should fire dragStart and should not fire Click Event on mousemove if the mouse cursor is moved.
136+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mousedown' , { which : 1 , clientX : 0 , clientY : 0 } )
137+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mousemove' , { which : 1 , clientX : 1 , clientY : 0 } )
138+ cy . wait ( 10 )
139+ checkEventCount ( { dragStartCount : 3 , dragEndCount : 2 , gutterClickCount : 5 , transitionEndCount : 5 } )
140+
141+ cy . get ( '.as-split-gutter' ) . eq ( 0 ) . trigger ( 'mouseup' , { which : 1 , clientX : 0 , clientY : 0 } )
142+ cy . wait ( 20 )
143+ checkEventCount ( { dragStartCount : 3 , dragEndCount : 3 , gutterClickCount : 5 , transitionEndCount : 5 } )
122144 } )
123145
124146 it ( 'Test double click event' , ( ) => {
0 commit comments