Skip to content

Commit d49f0ad

Browse files
committed
test sort transform event data using hover only
- hover and click when invoked programmatically back-to-back don't behave well. - this test case makes assertions on the event data (i.e. gd._hoverdata) which is the same for hover and click - use `delete gd._lastHoverTime` to 🔪 that annoying wait promise
1 parent 6cc5ffd commit d49f0ad

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

test/jasmine/tests/transform_sort_test.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ describe('Test sort transform interactions:', function() {
258258
.then(done);
259259
});
260260

261-
it('does not preserve hover/click `pointNumber` value', function(done) {
261+
it('does not preserve event data `pointNumber` value', function(done) {
262262
var gd = createGraphDiv();
263263

264264
function getPxPos(gd, id) {
@@ -275,6 +275,7 @@ describe('Test sort transform interactions:', function() {
275275
function hover(gd, id) {
276276
return new Promise(function(resolve) {
277277
gd.once('plotly_hover', function(eventData) {
278+
delete gd._lastHoverTime;
278279
resolve(eventData);
279280
});
280281

@@ -283,25 +284,6 @@ describe('Test sort transform interactions:', function() {
283284
});
284285
}
285286

286-
function click(gd, id) {
287-
return new Promise(function(resolve) {
288-
gd.once('plotly_click', function(eventData) {
289-
resolve(eventData);
290-
});
291-
292-
var pos = getPxPos(gd, id);
293-
mouseEvent('mousemove', pos[0], pos[1]);
294-
mouseEvent('mousedown', pos[0], pos[1]);
295-
mouseEvent('mouseup', pos[0], pos[1]);
296-
});
297-
}
298-
299-
function wait() {
300-
return new Promise(function(resolve) {
301-
setTimeout(resolve, 100);
302-
});
303-
}
304-
305287
function assertPt(eventData, x, y, pointNumber, id) {
306288
var pt = eventData.points[0];
307289

@@ -334,21 +316,18 @@ describe('Test sort transform interactions:', function() {
334316
.then(function(eventData) {
335317
assertPt(eventData, 0, 1, 3, 'D');
336318
})
337-
.then(wait)
338-
.then(function() { return click(gd, 'G'); })
319+
.then(function() { return hover(gd, 'G'); })
339320
.then(function(eventData) {
340321
assertPt(eventData, 1, 1, 6, 'G');
341322
})
342-
.then(wait)
343323
.then(function() {
344324
return Plotly.restyle(gd, 'transforms[0].enabled', true);
345325
})
346326
.then(function() { return hover(gd, 'D'); })
347327
.then(function(eventData) {
348328
assertPt(eventData, 0, 1, 1, 'D');
349329
})
350-
.then(wait)
351-
.then(function() { return click(gd, 'G'); })
330+
.then(function() { return hover(gd, 'G'); })
352331
.then(function(eventData) {
353332
assertPt(eventData, 1, 1, 5, 'G');
354333
})
@@ -359,8 +338,7 @@ describe('Test sort transform interactions:', function() {
359338
.then(function(eventData) {
360339
assertPt(eventData, 0, 1, 1, 'D');
361340
})
362-
.then(wait)
363-
.then(function() { return click(gd, 'G'); })
341+
.then(function() { return hover(gd, 'G'); })
364342
.then(function(eventData) {
365343
assertPt(eventData, 1, 1, 5, 'G');
366344
})

0 commit comments

Comments
 (0)