@@ -54,7 +54,7 @@ function assertSelectionNodes(cornerCnt, outlineCnt, _msg) {
54
54
}
55
55
56
56
var selectingCnt , selectingData , selectedCnt , selectedData , deselectCnt , doubleClickData ;
57
- var selectedPromise , deselectPromise ;
57
+ var selectedPromise , deselectPromise , clickedPromise ;
58
58
59
59
function resetEvents ( gd ) {
60
60
selectingCnt = 0 ;
@@ -98,6 +98,12 @@ function resetEvents(gd) {
98
98
resolve ( ) ;
99
99
} ) ;
100
100
} ) ;
101
+
102
+ clickedPromise = new Promise ( function ( resolve ) {
103
+ gd . on ( 'plotly_click' , function ( ) {
104
+ resolve ( ) ;
105
+ } ) ;
106
+ } ) ;
101
107
}
102
108
103
109
function assertEventCounts ( selecting , selected , deselect , msg ) {
@@ -557,10 +563,9 @@ describe('Click-to-select', function() {
557
563
. then ( function ( ) {
558
564
assertSelectionCleared ( ) ;
559
565
clickBox ( ) ;
566
+ return clickedPromise ;
560
567
} )
561
568
. then ( function ( ) {
562
- // TODO Be sure this is called "late enough" after clicking on box has been processed
563
- // Maybe plotly_click event would get fired after any selection events?
564
569
assertSelectionCleared ( ) ;
565
570
} )
566
571
. catch ( failTest )
@@ -572,13 +577,6 @@ describe('Click-to-select', function() {
572
577
} ) ;
573
578
574
579
describe ( 'is disabled when clickmode does not include \'select\'' , function ( ) {
575
- // TODO How to test for pan and zoom mode as well? Note, that
576
- // in lasso and select mode, plotly_selected was emitted upon a single
577
- // click although select-on-click wasn't supported. This behavior is kept
578
- // for compatibility reasons and as a side affect allows to write this test
579
- // for lasso and select. But in pan and zoom, how to be sure a click has been
580
- // processed by plotly.js?
581
- // ['pan', 'zoom', 'select', 'lasso']
582
580
[ 'select' , 'lasso' ]
583
581
. forEach ( function ( dragmode ) {
584
582
it ( '@flaky and dragmode is ' + dragmode , function ( done ) {
@@ -597,6 +595,24 @@ describe('Click-to-select', function() {
597
595
} ) ;
598
596
} ) ;
599
597
598
+ describe ( 'is disabled when clickmode does not include \'select\'' , function ( ) {
599
+ [ 'pan' , 'zoom' ]
600
+ . forEach ( function ( dragmode ) {
601
+ it ( '@flaky and dragmode is ' + dragmode , function ( done ) {
602
+ plotMock14 ( { clickmode : 'event' , dragmode : dragmode } )
603
+ . then ( function ( ) {
604
+ _immediateClickPt ( mock14Pts [ 1 ] ) ;
605
+ return clickedPromise ;
606
+ } )
607
+ . then ( function ( ) {
608
+ assertSelectionCleared ( ) ;
609
+ } )
610
+ . catch ( failTest )
611
+ . then ( done ) ;
612
+ } ) ;
613
+ } ) ;
614
+ } ) ;
615
+
600
616
describe ( 'is supported by' , function ( ) {
601
617
602
618
// On loading mocks:
0 commit comments