Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d617a1b

Browse files
authoredMay 13, 2019
Merge pull request #3859 from plotly/flaky-gl-ci-fixes
Reorganise gl tests for less flakiness
2 parents e26f8f4 + a27c519 commit d617a1b

16 files changed

+1782
-1844
lines changed
 

‎.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
docker:
5454
# need '-browsers' version to test in real (xvfb-wrapped) browsers
5555
- image: circleci/node:10.9.0-browsers
56-
parallelism: 2
56+
parallelism: 3
5757
working_directory: ~/plotly.js
5858
steps:
5959
- attach_workspace:

‎test/jasmine/tests/gl2d_scatterplot_contour_test.js renamed to ‎test/jasmine/tests/contourgl_test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
var Plotly = require('@lib/index');
42
var Lib = require('@src/lib');
53
var d3 = require('d3');
@@ -197,25 +195,25 @@ describe('contourgl plots', function() {
197195
makePlot(gd, mockCopy, done);
198196
});
199197

200-
it('render without raising an error (coloring: "lines")', function(done) {
198+
it('@gl render without raising an error (coloring: "lines")', function(done) {
201199
var mock = Lib.extendDeep({}, plotDataElliptical(0));
202200
mock.data[0].contours.coloring = 'lines'; // 'fill' is the default
203201
makePlot(gd, mock, done);
204202
});
205203

206-
it('render smooth, regular ellipses without raising an error (coloring: "fill")', function(done) {
204+
it('@gl render smooth, regular ellipses without raising an error (coloring: "fill")', function(done) {
207205
var mock = plotDataElliptical(0);
208206
makePlot(gd, mock, done);
209207
});
210208

211-
it('render ellipses with added noise without raising an error (coloring: "fill")', function(done) {
209+
it('@gl render ellipses with added noise without raising an error (coloring: "fill")', function(done) {
212210
var mock = plotDataElliptical(0.5);
213211
mock.data[0].contours.coloring = 'fill'; // 'fill' is the default
214212
mock.data[0].line = {smoothing: 0};
215213
makePlot(gd, mock, done);
216214
});
217215

218-
it('should update properly', function(done) {
216+
it('@gl should update properly', function(done) {
219217
var mock = plotDataElliptical(0);
220218
var scene2d;
221219

‎test/jasmine/tests/gl2d_date_axis_render_test.js

Lines changed: 0 additions & 105 deletions
This file was deleted.

‎test/jasmine/tests/gl2d_plot_interact_test.js

Lines changed: 73 additions & 749 deletions
Large diffs are not rendered by default.

‎test/jasmine/tests/gl3d_hover_click_test.js

Lines changed: 542 additions & 0 deletions
Large diffs are not rendered by default.

‎test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 72 additions & 715 deletions
Large diffs are not rendered by default.

‎test/jasmine/tests/gl3daxes_test.js

Lines changed: 0 additions & 110 deletions
This file was deleted.

‎test/jasmine/tests/gl3dlayout_test.js

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,115 @@ var createGraphDiv = require('../assets/create_graph_div');
88
var destroyGraphDiv = require('../assets/destroy_graph_div');
99
var failTest = require('../assets/fail_test');
1010

11+
describe('Test gl3d axes defaults', function() {
12+
'use strict';
13+
14+
var supplyLayoutDefaults = require('@src/plots/gl3d/layout/axis_defaults');
15+
16+
describe('supplyLayoutDefaults supplies defaults', function() {
17+
var layoutIn,
18+
layoutOut;
19+
20+
var options = {
21+
font: 'Open Sans',
22+
scene: {id: 'scene'},
23+
data: [{x: [], y: []}],
24+
bgColor: '#fff',
25+
fullLayout: {_dfltTitle: {x: 'xxx', y: 'yyy', colorbar: 'cbbb'}}
26+
};
27+
28+
beforeEach(function() {
29+
layoutOut = {};
30+
});
31+
32+
it('should define specific default set with empty initial layout', function() {
33+
layoutIn = {};
34+
35+
var expected = {
36+
'xaxis': {
37+
'showline': false,
38+
'showgrid': true,
39+
'gridcolor': 'rgb(204, 204, 204)',
40+
'gridwidth': 1,
41+
'showspikes': true,
42+
'spikesides': true,
43+
'spikethickness': 2,
44+
'spikecolor': '#444',
45+
'showbackground': false,
46+
'showaxeslabels': true
47+
},
48+
'yaxis': {
49+
'showline': false,
50+
'showgrid': true,
51+
'gridcolor': 'rgb(204, 204, 204)',
52+
'gridwidth': 1,
53+
'showspikes': true,
54+
'spikesides': true,
55+
'spikethickness': 2,
56+
'spikecolor': '#444',
57+
'showbackground': false,
58+
'showaxeslabels': true
59+
},
60+
'zaxis': {
61+
'showline': false,
62+
'showgrid': true,
63+
'gridcolor': 'rgb(204, 204, 204)',
64+
'gridwidth': 1,
65+
'showspikes': true,
66+
'spikesides': true,
67+
'spikethickness': 2,
68+
'spikecolor': '#444',
69+
'showbackground': false,
70+
'showaxeslabels': true
71+
}
72+
};
73+
74+
function checkKeys(validObject, testObject) {
75+
var keys = Object.keys(validObject);
76+
for(var i = 0; i < keys.length; i++) {
77+
var k = keys[i];
78+
expect(validObject[k]).toBe(testObject[k]);
79+
}
80+
return true;
81+
}
82+
83+
supplyLayoutDefaults(layoutIn, layoutOut, options);
84+
['xaxis', 'yaxis', 'zaxis'].forEach(function(axis) {
85+
checkKeys(expected[axis], layoutOut[axis]);
86+
});
87+
});
88+
89+
it('should inherit layout.calendar', function() {
90+
layoutIn = {
91+
xaxis: {type: 'date'},
92+
yaxis: {type: 'date'},
93+
zaxis: {type: 'date'}
94+
};
95+
options.calendar = 'taiwan';
96+
97+
supplyLayoutDefaults(layoutIn, layoutOut, options);
98+
99+
expect(layoutOut.xaxis.calendar).toBe('taiwan');
100+
expect(layoutOut.yaxis.calendar).toBe('taiwan');
101+
expect(layoutOut.zaxis.calendar).toBe('taiwan');
102+
});
103+
104+
it('should accept its own calendar', function() {
105+
layoutIn = {
106+
xaxis: {type: 'date', calendar: 'hebrew'},
107+
yaxis: {type: 'date', calendar: 'ummalqura'},
108+
zaxis: {type: 'date', calendar: 'discworld'}
109+
};
110+
options.calendar = 'taiwan';
111+
112+
supplyLayoutDefaults(layoutIn, layoutOut, options);
113+
114+
expect(layoutOut.xaxis.calendar).toBe('hebrew');
115+
expect(layoutOut.yaxis.calendar).toBe('ummalqura');
116+
expect(layoutOut.zaxis.calendar).toBe('discworld');
117+
});
118+
});
119+
});
11120

12121
describe('Test Gl3d layout defaults', function() {
13122
'use strict';
@@ -277,10 +386,10 @@ describe('Test Gl3d layout defaults', function() {
277386
describe('Gl3d layout edge cases', function() {
278387
var gd;
279388

280-
beforeEach(function() {gd = createGraphDiv(); });
389+
beforeEach(function() { gd = createGraphDiv(); });
281390
afterEach(destroyGraphDiv);
282391

283-
it('should handle auto aspect ratio correctly on data changes', function(done) {
392+
it('@gl should handle auto aspect ratio correctly on data changes', function(done) {
284393
Plotly.plot(gd, [{x: [1, 2], y: [1, 3], z: [1, 4], type: 'scatter3d'}])
285394
.then(function() {
286395
var aspect = gd.layout.scene.aspectratio;

‎test/jasmine/tests/gl_plot_interact_basic_test.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

‎test/jasmine/tests/mesh3d_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('Test mesh3d', function() {
99
describe('restyle', function() {
1010
afterEach(destroyGraphDiv);
1111

12-
it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
12+
it('@gl should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
1313
var gd = createGraphDiv();
1414

1515
function _assert(user, full) {

‎test/jasmine/tests/scatter3d_test.js

Lines changed: 225 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
var Scatter3D = require('@src/traces/scatter3d');
1+
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
33
var Color = require('@src/components/color');
44

5+
var Scatter3D = require('@src/traces/scatter3d');
6+
7+
var d3 = require('d3');
8+
var createGraphDiv = require('../assets/create_graph_div');
9+
var destroyGraphDiv = require('../assets/destroy_graph_div');
10+
var failTest = require('../assets/fail_test');
11+
var delay = require('../assets/delay');
12+
13+
function countCanvases() {
14+
return d3.selectAll('canvas').size();
15+
}
516

617
describe('Scatter3D defaults', function() {
718
'use strict';
@@ -89,3 +100,216 @@ describe('Scatter3D defaults', function() {
89100
expect(out.zcalendar).toBe('mayan');
90101
});
91102
});
103+
104+
describe('Test scatter3d interactions:', function() {
105+
var gd;
106+
107+
beforeEach(function() {
108+
gd = createGraphDiv();
109+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 6000;
110+
});
111+
112+
afterEach(function() {
113+
Plotly.purge(gd);
114+
destroyGraphDiv();
115+
});
116+
117+
// lines, markers, text, error bars and surfaces each
118+
// correspond to one glplot object
119+
var mock = require('@mocks/gl3d_marker-arrays.json');
120+
var mock2 = Lib.extendDeep({}, mock);
121+
mock2.data[0].mode = 'lines+markers+text';
122+
mock2.data[0].error_z = { value: 10 };
123+
mock2.data[0].surfaceaxis = 2;
124+
mock2.layout.showlegend = true;
125+
126+
it('@gl should be able to reversibly change trace type', function(done) {
127+
var _mock = Lib.extendDeep({}, mock2);
128+
var sceneLayout = { aspectratio: { x: 1, y: 1, z: 1 } };
129+
130+
Plotly.plot(gd, _mock)
131+
.then(delay(20))
132+
.then(function() {
133+
expect(countCanvases()).toEqual(1);
134+
expect(gd.layout.scene).toEqual(sceneLayout);
135+
expect(gd.layout.xaxis === undefined).toBe(true);
136+
expect(gd.layout.yaxis === undefined).toBe(true);
137+
expect(gd._fullLayout._has('gl3d')).toBe(true);
138+
expect(gd._fullLayout.scene._scene).toBeDefined();
139+
expect(gd._fullLayout.scene._scene.camera).toBeDefined(true);
140+
141+
return Plotly.restyle(gd, 'type', 'scatter');
142+
})
143+
.then(function() {
144+
expect(countCanvases()).toEqual(0);
145+
expect(gd.layout.scene).toEqual(sceneLayout);
146+
expect(gd.layout.xaxis).toBeDefined();
147+
expect(gd.layout.yaxis).toBeDefined();
148+
expect(gd._fullLayout._has('gl3d')).toBe(false);
149+
expect(gd._fullLayout.scene === undefined).toBe(true);
150+
151+
return Plotly.restyle(gd, 'type', 'scatter3d');
152+
})
153+
.then(function() {
154+
expect(countCanvases()).toEqual(1);
155+
expect(gd.layout.scene).toEqual(sceneLayout);
156+
expect(gd.layout.xaxis).toBeDefined();
157+
expect(gd.layout.yaxis).toBeDefined();
158+
expect(gd._fullLayout._has('gl3d')).toBe(true);
159+
expect(gd._fullLayout.scene._scene).toBeDefined();
160+
})
161+
.then(done);
162+
});
163+
164+
it('@gl should be able to delete the last trace', function(done) {
165+
var _mock = Lib.extendDeep({}, mock2);
166+
167+
Plotly.plot(gd, _mock)
168+
.then(delay(20))
169+
.then(function() {
170+
return Plotly.deleteTraces(gd, [0]);
171+
})
172+
.then(function() {
173+
expect(countCanvases()).toEqual(0);
174+
expect(gd._fullLayout._has('gl3d')).toBe(false);
175+
expect(gd._fullLayout.scene === undefined).toBe(true);
176+
})
177+
.then(done);
178+
});
179+
180+
it('@gl should be able to toggle visibility', function(done) {
181+
var _mock = Lib.extendDeep({}, mock2);
182+
_mock.data[0].x = [0, 1, 3];
183+
_mock.data[0].y = [0, 1, 2];
184+
_mock.data.push({
185+
type: 'surface',
186+
z: [[1, 2, 3], [1, 2, 3], [2, 1, 2]]
187+
}, {
188+
type: 'mesh3d',
189+
x: [0, 1, 2, 0], y: [0, 0, 1, 2], z: [0, 2, 0, 1],
190+
i: [0, 0, 0, 1], j: [1, 2, 3, 2], k: [2, 3, 1, 3]
191+
});
192+
193+
// scatter3d traces are made of 5 gl-vis objects,
194+
// surface and mesh3d are made of 1 gl-vis object each.
195+
var order0 = [0, 0, 0, 0, 0, 1, 2];
196+
197+
function assertObjects(expected) {
198+
var objects = gd._fullLayout.scene._scene.glplot.objects;
199+
var actual = objects.map(function(o) {
200+
return o._trace.data.index;
201+
});
202+
203+
expect(actual).toEqual(expected);
204+
}
205+
206+
Plotly.plot(gd, _mock)
207+
.then(delay(20))
208+
.then(function() {
209+
assertObjects(order0);
210+
211+
return Plotly.restyle(gd, 'visible', 'legendonly');
212+
})
213+
.then(function() {
214+
assertObjects([]);
215+
216+
return Plotly.restyle(gd, 'visible', true);
217+
})
218+
.then(function() {
219+
assertObjects(order0);
220+
221+
return Plotly.restyle(gd, 'visible', false, [0]);
222+
})
223+
.then(function() {
224+
assertObjects([1, 2]);
225+
226+
return Plotly.restyle(gd, 'visible', true, [0]);
227+
})
228+
.then(function() {
229+
assertObjects(order0);
230+
231+
return Plotly.restyle(gd, 'visible', 'legendonly', [1]);
232+
})
233+
.then(function() {
234+
assertObjects([0, 0, 0, 0, 0, 2]);
235+
236+
return Plotly.restyle(gd, 'visible', true, [1]);
237+
})
238+
.then(function() {
239+
assertObjects(order0);
240+
})
241+
.then(done);
242+
});
243+
244+
it('@gl should avoid passing blank texts to webgl', function(done) {
245+
function assertIsFilled(msg) {
246+
var fullLayout = gd._fullLayout;
247+
expect(fullLayout.scene._scene.glplot.objects[0].glyphBuffer.length).not.toBe(0, msg);
248+
}
249+
Plotly.plot(gd, [{
250+
type: 'scatter3d',
251+
mode: 'text',
252+
x: [1, 2, 3],
253+
y: [2, 3, 1],
254+
z: [3, 1, 2]
255+
}])
256+
.then(function() {
257+
assertIsFilled('not to be empty text');
258+
})
259+
.catch(failTest)
260+
.then(done);
261+
});
262+
263+
it('@gl should avoid passing empty lines to webgl', function(done) {
264+
var obj;
265+
266+
Plotly.plot(gd, [{
267+
type: 'scatter3d',
268+
mode: 'lines',
269+
x: [1],
270+
y: [2],
271+
z: [3]
272+
}])
273+
.then(function() {
274+
obj = gd._fullLayout.scene._scene.glplot.objects[0];
275+
spyOn(obj.vao, 'draw').and.callThrough();
276+
277+
expect(obj.vertexCount).toBe(0, '# of vertices');
278+
279+
return Plotly.restyle(gd, 'line.color', 'red');
280+
})
281+
.then(function() {
282+
expect(obj.vertexCount).toBe(0, '# of vertices');
283+
// calling this with no vertex causes WebGL warnings,
284+
// see https://github.com/plotly/plotly.js/issues/1976
285+
expect(obj.vao.draw).toHaveBeenCalledTimes(0);
286+
})
287+
.catch(failTest)
288+
.then(done);
289+
});
290+
291+
it('@gl should only accept texts for textposition otherwise textposition is set to middle center before passing to webgl', function(done) {
292+
Plotly.plot(gd, [{
293+
type: 'scatter3d',
294+
mode: 'markers+text+lines',
295+
x: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
296+
y: [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16],
297+
z: [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
298+
text: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'],
299+
textposition: ['left top', 'right top', 'left bottom', 'right bottom', null, undefined, true, false, [], {}, NaN, Infinity, 0, 1.2]
300+
}])
301+
.then(function() {
302+
var AllTextpositions = gd._fullData[0].textposition;
303+
304+
expect(AllTextpositions[0]).toBe('top left', 'is not top left');
305+
expect(AllTextpositions[1]).toBe('top right', 'is not top right');
306+
expect(AllTextpositions[2]).toBe('bottom left', 'is not bottom left');
307+
expect(AllTextpositions[3]).toBe('bottom right', 'is not bottom right');
308+
for(var i = 4; i < AllTextpositions.length; i++) {
309+
expect(AllTextpositions[i]).toBe('middle center', 'is not middle center');
310+
}
311+
})
312+
.catch(failTest)
313+
.then(done);
314+
});
315+
});

‎test/jasmine/tests/gl2d_double_click_test.js renamed to ‎test/jasmine/tests/scattergl_select_test.js

Lines changed: 160 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,49 @@ var createGraphDiv = require('../assets/create_graph_div');
66
var destroyGraphDiv = require('../assets/destroy_graph_div');
77
var failTest = require('../assets/fail_test.js');
88

9-
// cartesian click events events use the hover data
10-
// from the mousemove events and then simulate
11-
// a click event on mouseup
129
var doubleClick = require('../assets/double_click');
1310
var delay = require('../assets/delay');
1411
var mouseEvent = require('../assets/mouse_event');
1512
var readPixel = require('../assets/read_pixel');
1613

17-
// contourgl is not part of the dist plotly.js bundle initially
18-
Plotly.register([
19-
require('@lib/contourgl')
20-
]);
14+
function drag(gd, path) {
15+
var len = path.length;
16+
var el = d3.select(gd).select('rect.nsewdrag').node();
17+
var opts = {element: el};
2118

22-
describe('Test gl2d lasso/select:', function() {
23-
var mockFancy = require('@mocks/gl2d_14.json');
24-
delete mockFancy.layout.xaxis.autorange;
25-
delete mockFancy.layout.yaxis.autorange;
26-
mockFancy.layout.xaxis.range = [-2.951309064136961, 2.0954721318818916];
27-
mockFancy.layout.yaxis.range = [-0.9248866483012275, 1.3232607344525835];
19+
Lib.clearThrottle();
20+
mouseEvent('mousemove', path[0][0], path[0][1], opts);
21+
mouseEvent('mousedown', path[0][0], path[0][1], opts);
2822

29-
var mockFast = Lib.extendDeep({}, mockFancy, {
30-
data: [{mode: 'markers'}],
31-
layout: {
32-
xaxis: {
33-
type: 'linear',
34-
range: [-3.869222222222223, 73.55522222222223]
35-
},
36-
yaxis: {
37-
type: 'linear',
38-
range: [-0.7402222222222222, 17.144222222222222]
39-
}
40-
}
23+
path.slice(1, len).forEach(function(pt) {
24+
Lib.clearThrottle();
25+
mouseEvent('mousemove', pt[0], pt[1], opts);
4126
});
4227

28+
mouseEvent('mouseup', path[len - 1][0], path[len - 1][1], opts);
29+
}
30+
31+
function select(gd, path) {
32+
return new Promise(function(resolve, reject) {
33+
gd.once('plotly_selected', resolve);
34+
setTimeout(function() { reject('did not trigger *plotly_selected*');}, 200);
35+
drag(gd, path);
36+
});
37+
}
38+
39+
describe('Test gl2d lasso/select:', function() {
4340
var gd;
4441
var selectPath = [[98, 193], [108, 193]];
4542
var selectPath2 = [[118, 193], [128, 193]];
4643
var lassoPath = [[316, 171], [318, 239], [335, 243], [328, 169]];
4744
var lassoPath2 = [[98, 193], [108, 193], [108, 500], [98, 500], [98, 193]];
4845

49-
afterEach(function() {
46+
afterEach(function(done) {
5047
Plotly.purge(gd);
5148
destroyGraphDiv();
49+
setTimeout(done, 500);
5250
});
5351

54-
function drag(path) {
55-
var len = path.length;
56-
var el = d3.select(gd).select('rect.nsewdrag').node();
57-
var opts = {element: el};
58-
59-
Lib.clearThrottle();
60-
mouseEvent('mousemove', path[0][0], path[0][1], opts);
61-
mouseEvent('mousedown', path[0][0], path[0][1], opts);
62-
63-
path.slice(1, len).forEach(function(pt) {
64-
Lib.clearThrottle();
65-
mouseEvent('mousemove', pt[0], pt[1], opts);
66-
});
67-
68-
mouseEvent('mouseup', path[len - 1][0], path[len - 1][1], opts);
69-
}
70-
71-
function select(path) {
72-
return new Promise(function(resolve, reject) {
73-
gd.once('plotly_selected', resolve);
74-
setTimeout(function() { reject('did not trigger *plotly_selected*');}, 200);
75-
drag(path);
76-
});
77-
}
78-
7952
function assertEventData(actual, expected) {
8053
expect(actual.points.length).toBe(expected.points.length);
8154

@@ -88,6 +61,27 @@ describe('Test gl2d lasso/select:', function() {
8861
});
8962
}
9063

64+
var mockFancy = require('@mocks/gl2d_14.json');
65+
delete mockFancy.layout.xaxis.autorange;
66+
delete mockFancy.layout.yaxis.autorange;
67+
mockFancy.layout.xaxis.range = [-2.951309064136961, 2.0954721318818916];
68+
mockFancy.layout.yaxis.range = [-0.9248866483012275, 1.3232607344525835];
69+
70+
var mockFast = Lib.extendDeep({}, mockFancy, {
71+
data: [{mode: 'markers'}],
72+
layout: {
73+
xaxis: {
74+
type: 'linear',
75+
range: [-3.869222222222223, 73.55522222222223]
76+
},
77+
yaxis: {
78+
type: 'linear',
79+
range: [-0.7402222222222222, 17.144222222222222]
80+
}
81+
}
82+
});
83+
84+
9185
it('@gl should work under fast mode with *select* dragmode', function(done) {
9286
var _mock = Lib.extendDeep({}, mockFast);
9387
_mock.layout.dragmode = 'select';
@@ -98,7 +92,7 @@ describe('Test gl2d lasso/select:', function() {
9892
.then(function() {
9993
expect(gd._fullLayout._plots.xy._scene.select2d).not.toBe(undefined, 'scatter2d renderer');
10094

101-
return select(selectPath);
95+
return select(gd, selectPath);
10296
})
10397
.then(delay(20))
10498
.then(function(eventData) {
@@ -122,7 +116,7 @@ describe('Test gl2d lasso/select:', function() {
122116
Plotly.plot(gd, _mock)
123117
.then(delay(20))
124118
.then(function() {
125-
return select(lassoPath2);
119+
return select(gd, lassoPath2);
126120
})
127121
.then(delay(20))
128122
.then(function(eventData) {
@@ -146,7 +140,7 @@ describe('Test gl2d lasso/select:', function() {
146140
Plotly.plot(gd, _mock)
147141
.then(delay(20))
148142
.then(function() {
149-
return select(selectPath2);
143+
return select(gd, selectPath2);
150144
})
151145
.then(delay(20))
152146
.then(function(eventData) {
@@ -166,7 +160,7 @@ describe('Test gl2d lasso/select:', function() {
166160
Plotly.plot(gd, _mock)
167161
.then(delay(20))
168162
.then(function() {
169-
return select(lassoPath);
163+
return select(gd, lassoPath);
170164
})
171165
.then(function(eventData) {
172166
assertEventData(eventData, {
@@ -187,7 +181,7 @@ describe('Test gl2d lasso/select:', function() {
187181

188182
Plotly.plot(gd, fig)
189183
.then(delay(20))
190-
.then(function() { return select([[100, 100], [250, 250]]); })
184+
.then(function() { return select(gd, [[100, 100], [250, 250]]); })
191185
.then(function(eventData) {
192186
assertEventData(eventData, {
193187
points: [
@@ -227,7 +221,7 @@ describe('Test gl2d lasso/select:', function() {
227221
]
228222
});
229223
})
230-
.then(function() { return select([[100, 100], [250, 250]]); })
224+
.then(function() { return select(gd, [[100, 100], [250, 250]]); })
231225
.then(function(eventData) {
232226
assertEventData(eventData, {
233227
points: [{x: 1, y: 2}]
@@ -256,7 +250,7 @@ describe('Test gl2d lasso/select:', function() {
256250
.then(function() {
257251
return Plotly.restyle(gd, 'selected.textfont.color', 'red');
258252
})
259-
.then(function() { return select([[100, 100], [250, 250]]); })
253+
.then(function() { return select(gd, [[100, 100], [250, 250]]); })
260254
.then(function() {
261255
_assertGlTextOpts('after selection - with set selected.textfont.color', {
262256
rgba: [
@@ -317,7 +311,7 @@ describe('Test gl2d lasso/select:', function() {
317311
]
318312
});
319313
})
320-
.then(function() { return select([[100, 10], [250, 100]]); })
314+
.then(function() { return select(gd, [[100, 10], [250, 100]]); })
321315
.then(function(eventData) {
322316
assertEventData(eventData, {
323317
points: [{x: 1, y: 2}]
@@ -341,7 +335,7 @@ describe('Test gl2d lasso/select:', function() {
341335
.then(function() {
342336
return Plotly.restyle(gd, 'selected.textfont.color', 'red');
343337
})
344-
.then(function() { return select([[100, 10], [250, 100]]); })
338+
.then(function() { return select(gd, [[100, 10], [250, 100]]); })
345339
.then(function() {
346340
_assertGlTextOpts('after selection - with set selected.textfont.color', {
347341
rgba: [
@@ -362,10 +356,22 @@ describe('Test gl2d lasso/select:', function() {
362356
.catch(failTest)
363357
.then(done);
364358
});
359+
});
365360

366-
it('@gl should work after a width/height relayout', function(done) {
361+
describe('Test displayed selections:', function() {
362+
var gd;
363+
364+
beforeEach(function() {
367365
gd = createGraphDiv();
366+
});
367+
368+
afterEach(function(done) {
369+
Plotly.purge(gd);
370+
destroyGraphDiv();
371+
setTimeout(done, 500);
372+
});
368373

374+
it('@gl should work after a width/height relayout', function(done) {
369375
var w = 500;
370376
var h = 500;
371377
var w2 = 800;
@@ -396,7 +402,7 @@ describe('Test gl2d lasso/select:', function() {
396402
expect(readContext()).toBeGreaterThan(1e4, 'base context');
397403
expect(readFocus()).toBe(0, 'base focus');
398404
})
399-
.then(function() { return select([[pad, pad], [w - pad, h - pad]]); })
405+
.then(function() { return select(gd, [[pad, pad], [w - pad, h - pad]]); })
400406
.then(function() {
401407
expect(readContext()).toBe(0, 'select context');
402408
expect(readFocus()).toBeGreaterThan(1e4, 'select focus');
@@ -411,7 +417,7 @@ describe('Test gl2d lasso/select:', function() {
411417
expect(readContext()).toBeGreaterThan(1e4, 'update context');
412418
expect(readFocus()).toBe(0, 'update focus');
413419
})
414-
.then(function() { return select([[pad, pad], [w2 - pad, h2 - pad]]); })
420+
.then(function() { return select(gd, [[pad, pad], [w2 - pad, h2 - pad]]); })
415421
.then(function() {
416422
// make sure full w2/h2 context canvas is cleared!
417423
// from https://github.com/plotly/plotly.js/issues/2731<Paste>
@@ -422,6 +428,92 @@ describe('Test gl2d lasso/select:', function() {
422428
.then(done);
423429
});
424430

431+
it('@gl should display selection of big number of regular points', function(done) {
432+
// generate large number of points
433+
var x = [];
434+
var y = [];
435+
var n = 2e2;
436+
var N = n * n;
437+
for(var i = 0; i < N; i++) {
438+
x.push((i % n) / n);
439+
y.push(i / N);
440+
}
441+
442+
var mock = {
443+
data: [{
444+
x: x, y: y, type: 'scattergl', mode: 'markers'
445+
}],
446+
layout: {
447+
dragmode: 'select'
448+
}
449+
};
450+
451+
Plotly.plot(gd, mock)
452+
.then(select(gd, [[160, 100], [180, 100]]))
453+
.then(function() {
454+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
455+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 158, 100)[3]).not.toBe(0);
456+
expect(readPixel(gd.querySelector('.gl-canvas-focus'), 168, 100)[3]).not.toBe(0);
457+
})
458+
.catch(failTest)
459+
.then(done);
460+
});
461+
462+
it('@gl should display selection of big number of miscellaneous points', function(done) {
463+
var colorList = [
464+
'#006385', '#F06E75', '#90ed7d', '#f7a35c', '#8085e9',
465+
'#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1',
466+
'#5DA5DA', '#F06E75', '#F15854', '#B2912F', '#B276B2',
467+
'#DECF3F', '#FAA43A', '#4D4D4D', '#F17CB0', '#60BD68'
468+
];
469+
470+
// generate large number of points
471+
var x = [];
472+
var y = [];
473+
var n = 2e2;
474+
var N = n * n;
475+
var color = [];
476+
var symbol = [];
477+
var size = [];
478+
for(var i = 0; i < N; i++) {
479+
x.push((i % n) / n);
480+
y.push(i / N);
481+
color.push(colorList[i % colorList.length]);
482+
symbol.push('x');
483+
size.push(6);
484+
}
485+
486+
var mock = {
487+
data: [{
488+
x: x, y: y, type: 'scattergl', mode: 'markers',
489+
marker: {symbol: symbol, size: size, color: color}
490+
}],
491+
layout: {
492+
dragmode: 'select'
493+
}
494+
};
495+
496+
Plotly.plot(gd, mock)
497+
.then(select(gd, [[160, 100], [180, 100]]))
498+
.then(function() {
499+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 168, 100)[3]).toBe(0);
500+
expect(readPixel(gd.querySelector('.gl-canvas-context'), 158, 100)[3]).not.toBe(0);
501+
expect(readPixel(gd.querySelector('.gl-canvas-focus'), 168, 100)[3]).not.toBe(0);
502+
})
503+
.catch(failTest)
504+
.then(done);
505+
});
506+
});
507+
508+
describe('Test selections during funky scenarios', function() {
509+
var gd;
510+
511+
afterEach(function(done) {
512+
Plotly.purge(gd);
513+
destroyGraphDiv();
514+
setTimeout(done, 500);
515+
});
516+
425517
function grabScene() {
426518
return gd.calcdata[0][0].t._scene;
427519
}
@@ -514,7 +606,7 @@ describe('Test gl2d lasso/select:', function() {
514606
drawArgs: []
515607
});
516608
})
517-
.then(function() { return select([[20, 20], [480, 250]]); })
609+
.then(function() { return select(gd, [[20, 20], [480, 250]]); })
518610
.then(function() {
519611
var scene = grabScene();
520612
_assert('after select', {
@@ -556,7 +648,7 @@ describe('Test gl2d lasso/select:', function() {
556648
drawArgs: []
557649
});
558650
})
559-
.then(function() { return drag([[200, 200], [250, 250]]); })
651+
.then(function() { return drag(gd, [[200, 200], [250, 250]]); })
560652
.then(function() {
561653
var scene = grabScene();
562654
_assert('after pan', {
@@ -652,7 +744,7 @@ describe('Test gl2d lasso/select:', function() {
652744
drawArgs: []
653745
});
654746
})
655-
.then(function() { return select([[20, 20], [480, 250]]); })
747+
.then(function() { return select(gd, [[20, 20], [480, 250]]); })
656748
.then(function() { return doubleClick(250, 250); })
657749
.then(function() { return Plotly.relayout(gd, 'dragmode', 'pan'); })
658750
.then(function() { return Plotly.relayout(gd, 'dragmode', 'select'); })
@@ -738,7 +830,7 @@ describe('Test gl2d lasso/select:', function() {
738830
['select2d', [[[], []]]]
739831
]);
740832
})
741-
.then(function() { return select([[20, 20], [480, 250]]); })
833+
.then(function() { return select(gd, [[20, 20], [480, 250]]); })
742834
.then(function() {
743835
_assert('on selection', [
744836
['scatter2d', [[[0, 2], []]]],
@@ -791,7 +883,7 @@ describe('Test gl2d lasso/select:', function() {
791883
spyOn(scene.scatter2d, 'draw');
792884
spyOn(scene2.scatter2d, 'draw');
793885
})
794-
.then(function() { return select([[20, 20], [380, 250]]); })
886+
.then(function() { return select(gd, [[20, 20], [380, 250]]); })
795887
.then(function() {
796888
expect(scene.scatter2d.draw).toHaveBeenCalledTimes(1);
797889
expect(scene2.scatter2d.draw).toHaveBeenCalledTimes(1);

‎test/jasmine/tests/scattergl_test.js

Lines changed: 591 additions & 3 deletions
Large diffs are not rendered by default.

‎test/jasmine/tests/scatterpolargl_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('Test scatterpolargl hover:', function() {
108108
name: 'Trial 3'
109109
}]
110110
.forEach(function(specs) {
111-
it('should generate correct hover labels ' + specs.desc, function(done) {
111+
it('@gl should generate correct hover labels ' + specs.desc, function(done) {
112112
run(specs).catch(failTest).then(done);
113113
});
114114
});

‎test/jasmine/tests/volume_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ describe('Test volume', function() {
264264
destroyGraphDiv();
265265
});
266266

267-
it('should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
267+
it('@gl should clear *cauto* when restyle *cmin* and/or *cmax*', function(done) {
268268
function _assert(user, full) {
269269
var trace = gd.data[0];
270270
var fullTrace = gd._fullData[0];

0 commit comments

Comments
 (0)
Please sign in to comment.