Skip to content

Commit ab2a0a2

Browse files
dyetpinard
authored andcommitted
Fix gl2d_click & gl_plot_interact tests
1 parent 58cb8f4 commit ab2a0a2

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

src/lib/str2rgbarray.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
'use strict';
1111

12-
var rgba = require('color-rgba');
12+
var rgba = require('color-normalize');
1313

1414
function str2RgbaArray(color) {
15-
var colorOut = rgba(color);
16-
return colorOut.length ? colorOut : [0, 0, 0, 1];
15+
if(!color) return [0, 0, 0, 1];
16+
return rgba(color);
1717
}
1818

1919
module.exports = str2RgbaArray;

src/traces/scattergl/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,9 @@ ScatterGl.selectPoints = function select(searchInfo, polygon) {
11461146
trace = cd[0].trace,
11471147
stash = cd[0].t,
11481148
x = stash.x,
1149-
y = stash.y;
1149+
y = stash.y,
1150+
rawx = stash.rawx,
1151+
rawy = stash.rawy;
11501152

11511153
var scene = stash.scene;
11521154

@@ -1165,8 +1167,8 @@ ScatterGl.selectPoints = function select(searchInfo, polygon) {
11651167
els.push(i);
11661168
selection.push({
11671169
pointNumber: i,
1168-
x: x[i],
1169-
y: y[i]
1170+
x: rawx ? rawx[i] : x[i],
1171+
y: rawy ? rawy[i] : y[i]
11701172
});
11711173
}
11721174
else {

test/jasmine/tests/gl2d_click_test.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ describe('Test hover and click interactions', function() {
358358
y: 18,
359359
curveNumber: 2,
360360
pointNumber: 0,
361-
bgcolor: 'rgb(44, 160, 44)',
362-
bordercolor: 'rgb(255, 255, 255)',
361+
bgcolor: 'rgb(255, 127, 14)',
362+
bordercolor: 'rgb(68, 68, 68)',
363363
fontSize: 13,
364364
fontFamily: 'Arial',
365-
fontColor: 'rgb(255, 255, 255)'
365+
fontColor: 'rgb(68, 68, 68)'
366366
}, {
367367
msg: 'scattergl after visibility restyle'
368368
});
@@ -406,11 +406,11 @@ describe('Test hover and click interactions', function() {
406406
y: 18,
407407
curveNumber: 2,
408408
pointNumber: 0,
409-
bgcolor: 'rgb(44, 160, 44)',
410-
bordercolor: 'rgb(255, 255, 255)',
409+
bgcolor: 'rgb(255, 127, 14)',
410+
bordercolor: 'rgb(68, 68, 68)',
411411
fontSize: 13,
412412
fontFamily: 'Arial',
413-
fontColor: 'rgb(255, 255, 255)'
413+
fontColor: 'rgb(68, 68, 68)'
414414
}, {
415415
msg: 'scattergl fancy after visibility restyle'
416416
});
@@ -465,9 +465,10 @@ describe('@noCI Test gl2d lasso/select:', function() {
465465
});
466466

467467
var gd;
468-
var selectPath = [[103, 193], [113, 193]];
468+
var selectPath = [[98, 193], [108, 193]];
469+
var selectPath2 = [[118, 193], [128, 193]];
469470
var lassoPath = [[316, 171], [318, 239], [335, 243], [328, 169]];
470-
var lassoPath2 = [[93, 193], [143, 193], [143, 500], [93, 500], [93, 193]];
471+
var lassoPath2 = [[98, 193], [108, 193], [108, 500], [98, 500], [98, 193]];
471472

472473
afterEach(function() {
473474
Plotly.purge(gd);
@@ -522,6 +523,7 @@ describe('@noCI Test gl2d lasso/select:', function() {
522523

523524
return select(selectPath);
524525
})
526+
.then(delay(100))
525527
.then(function(eventData) {
526528
assertEventData(eventData, {
527529
points: [
@@ -546,6 +548,7 @@ describe('@noCI Test gl2d lasso/select:', function() {
546548
.then(function() {
547549
return select(lassoPath2);
548550
})
551+
.then(delay(100))
549552
.then(function(eventData) {
550553
assertEventData(eventData, {
551554
points: [
@@ -567,8 +570,9 @@ describe('@noCI Test gl2d lasso/select:', function() {
567570
Plotly.plot(gd, _mock)
568571
.then(delay(100))
569572
.then(function() {
570-
return select(selectPath);
573+
return select(selectPath2);
571574
})
575+
.then(delay(100))
572576
.then(function(eventData) {
573577
assertEventData(eventData, {
574578
points: [{x: 0.004, y: 12.5}]

test/jasmine/tests/gl_plot_interact_test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,10 @@ describe('Test gl2d plots', function() {
861861
var relayoutCallback = jasmine.createSpy('relayoutCallback');
862862

863863
var originalX = [-0.3037383177570093, 5.303738317757009];
864-
var originalY = [-0.5532219548705213, 6.191112269783224];
865-
var newX = [-0.5373831775700935, 5.070093457943925];
866-
var newY = [-1.7575673521301185, 4.986766872523626];
867-
var precision = 5;
864+
var originalY = [-0.5, 6.1];
865+
var newX = [-0.5, 5];
866+
var newY = [-1.7, 4.95];
867+
var precision = 1;
868868

869869
Plotly.plot(gd, _mock)
870870
.then(delay(20))
@@ -952,7 +952,7 @@ describe('Test gl2d plots', function() {
952952
return Plotly.restyle(gd, 'visible', 'legendonly');
953953
})
954954
.then(function() {
955-
expect(readPixel(gd.querySelector('.gl-canvas-context'), 108, 100)[0]).toBe(0);
955+
expect(gd.querySelector('.gl-canvas-context')).toBe(null);
956956

957957
return Plotly.restyle(gd, 'visible', true);
958958
})
@@ -962,7 +962,7 @@ describe('Test gl2d plots', function() {
962962
return Plotly.restyle(gd, 'visible', false);
963963
})
964964
.then(function() {
965-
expect(gd.querySelector('.gl-canvas-context')).not.toBe(null);
965+
expect(gd.querySelector('.gl-canvas-context')).toBe(null);
966966

967967
return Plotly.restyle(gd, 'visible', true);
968968
})
@@ -1087,8 +1087,8 @@ describe('Test gl2d plots', function() {
10871087
});
10881088
})
10891089
.then(function() {
1090-
expect(gd.layout.xaxis.range).toBeCloseToArray([-8.091954022988505, 24.091954022988503], 3);
1091-
expect(gd.layout.yaxis.range).toBeCloseToArray([-0.04597701149425282, 16.04597701149425], 3);
1090+
expect(gd.layout.xaxis.range).toBeCloseToArray([-7.6, 23.6], 1);
1091+
expect(gd.layout.yaxis.range).toBeCloseToArray([0.2, 15.8], 1);
10921092
})
10931093
.catch(fail)
10941094
.then(done);
@@ -1360,8 +1360,8 @@ describe('Test gl2d interactions', function() {
13601360
var ann = d3.select('g.annotation-text-g').select('g');
13611361
var translate = Drawing.getTranslate(ann);
13621362

1363-
expect(translate.x).toBeWithin(xy[0], 3.5);
1364-
expect(translate.y).toBeWithin(xy[1], 3.5);
1363+
expect(translate.x).toBeWithin(xy[0], 4.5);
1364+
expect(translate.y).toBeWithin(xy[1], 4.5);
13651365
}
13661366

13671367
Plotly.plot(gd, [{

0 commit comments

Comments
 (0)