Skip to content

Commit 88e9993

Browse files
committed
Fix testing click-to-select is inactive if clickmode is 'event' [1852]
- Wait until 'plotly_click' event is fired before checking that no point has been selected.
1 parent 05b50b9 commit 88e9993

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

test/jasmine/tests/select_test.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function assertSelectionNodes(cornerCnt, outlineCnt, _msg) {
5454
}
5555

5656
var selectingCnt, selectingData, selectedCnt, selectedData, deselectCnt, doubleClickData;
57-
var selectedPromise, deselectPromise;
57+
var selectedPromise, deselectPromise, clickedPromise;
5858

5959
function resetEvents(gd) {
6060
selectingCnt = 0;
@@ -98,6 +98,12 @@ function resetEvents(gd) {
9898
resolve();
9999
});
100100
});
101+
102+
clickedPromise = new Promise(function(resolve) {
103+
gd.on('plotly_click', function() {
104+
resolve();
105+
});
106+
});
101107
}
102108

103109
function assertEventCounts(selecting, selected, deselect, msg) {
@@ -557,10 +563,9 @@ describe('Click-to-select', function() {
557563
.then(function() {
558564
assertSelectionCleared();
559565
clickBox();
566+
return clickedPromise;
560567
})
561568
.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?
564569
assertSelectionCleared();
565570
})
566571
.catch(failTest)
@@ -572,13 +577,6 @@ describe('Click-to-select', function() {
572577
});
573578

574579
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']
582580
['select', 'lasso']
583581
.forEach(function(dragmode) {
584582
it('@flaky and dragmode is ' + dragmode, function(done) {
@@ -597,6 +595,24 @@ describe('Click-to-select', function() {
597595
});
598596
});
599597

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+
600616
describe('is supported by', function() {
601617

602618
// On loading mocks:

0 commit comments

Comments
 (0)