Skip to content

Commit 352f4e4

Browse files
authored
Merge pull request #5482 from plotly/label-flaky-tests
Label flaky tests and add early returns in setTimeout functions to bypass undefined fullLayouts
2 parents 7d3c8d3 + 85ad874 commit 352f4e4

File tree

8 files changed

+43
-42
lines changed

8 files changed

+43
-42
lines changed

src/components/legend/draw.js

+1
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
369369

370370
if(numClicks === 1) {
371371
legend._clickTimeout = setTimeout(function() {
372+
if(!gd._fullLayout) return;
372373
handleClick(legendItem, gd, numClicks);
373374
}, gd._context.doubleClickDelay);
374375
} else if(numClicks === 2) {

src/plots/cartesian/dragbox.js

+1
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
535535
// then replot after a delay to make sure
536536
// no more scrolling is coming
537537
redrawTimer = setTimeout(function() {
538+
if(!gd._fullLayout) return;
538539
scrollViewBox = [0, 0, pw, ph];
539540
dragTail();
540541
}, REDRAWDELAY);

src/plots/plots.js

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ plots.redrawText = function(gd) {
5151

5252
return new Promise(function(resolve) {
5353
setTimeout(function() {
54+
if(!gd._fullLayout) return;
5455
Registry.getComponentMethod('annotations', 'draw')(gd);
5556
Registry.getComponentMethod('legend', 'draw')(gd);
5657
Registry.getComponentMethod('colorbar', 'draw')(gd);
@@ -2720,6 +2721,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay
27202721
}
27212722

27222723
function transitionAxes() {
2724+
if(!gd._fullLayout) return;
27232725
for(var j = 0; j < basePlotModules.length; j++) {
27242726
if(basePlotModules[j].transitionAxes) {
27252727
basePlotModules[j].transitionAxes(gd, axEdits, axisTransitionOpts, makeCallback);
@@ -2728,6 +2730,7 @@ plots.transitionFromReact = function(gd, restyleFlags, relayoutFlags, oldFullLay
27282730
}
27292731

27302732
function transitionTraces() {
2733+
if(!gd._fullLayout) return;
27312734
for(var j = 0; j < basePlotModules.length; j++) {
27322735
basePlotModules[j].plot(gd, transitionedTraces, traceTransitionOpts, makeCallback);
27332736
}

test/jasmine/tests/animate_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ describe('Animating multiple axes', function() {
750750
.then(done, done.fail);
751751
});
752752

753-
it('updates ranges of secondary axes (date + category case)', function(done) {
753+
it('@flaky updates ranges of secondary axes (date + category case)', function(done) {
754754
Plotly.newPlot(gd, [
755755
{x: ['2018-01-01', '2019-01-01', '2020-01-01'], y: [1, 2, 3]},
756756
{x: ['a', 'b', 'c'], y: [1, 2, 3], xaxis: 'x2', yaxis: 'y2'}
@@ -950,7 +950,7 @@ describe('animating scatter traces', function() {
950950
}).then(done, done.fail);
951951
});
952952

953-
it('should animate axis ranges using the less number of steps', function(done) {
953+
it('@flaky should animate axis ranges using the less number of steps', function(done) {
954954
// sanity-check that scatter points and bars are still there
955955
function _assertNodeCnt() {
956956
var gd3 = d3Select(gd);

test/jasmine/tests/cartesian_interact_test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ describe('axis zoom/pan and main plot zoom', function() {
960960
var yr0 = [-0.211, 3.211];
961961

962962
var specs = [{
963-
desc: '@flaky zoombox on xy',
963+
desc: 'zoombox on xy',
964964
drag: ['xy', 'nsew', 30, 30],
965965
exp: [
966966
[['xaxis', 'xaxis2', 'xaxis3'], [1.457, 2.328]],
@@ -1094,7 +1094,7 @@ describe('axis zoom/pan and main plot zoom', function() {
10941094
var msg = 'after ' + s.desc;
10951095
var msg2 = ['after dblclick on subplot', s.dblclickSubplot, msg].join(' ');
10961096

1097-
it(s.desc, function(done) {
1097+
it('@flaky ' + s.desc, function(done) {
10981098
makePlot(data, layout, s).then(function() {
10991099
assertRanges('base', [
11001100
[['xaxis', 'xaxis2', 'xaxis3'], xr0],
@@ -1194,7 +1194,7 @@ describe('axis zoom/pan and main plot zoom', function() {
11941194
specs.forEach(function(s) {
11951195
var msg = 'after ' + s.desc;
11961196

1197-
it(s.desc, function(done) {
1197+
it('@flaky ' + s.desc, function(done) {
11981198
makePlot(data, layout, s).then(function() {
11991199
assertRanges('base', [
12001200
[['xaxis'], xr0],
@@ -1331,7 +1331,7 @@ describe('axis zoom/pan and main plot zoom', function() {
13311331
specs.forEach(function(s) {
13321332
var msg = 'after ' + s.desc;
13331333

1334-
it(s.desc, function(done) {
1334+
it('@flaky ' + s.desc, function(done) {
13351335
makePlot(data, layout, s).then(function() {
13361336
assertRanges('base', [
13371337
[['yaxis', 'xaxis2'], rm0],
@@ -1412,7 +1412,7 @@ describe('axis zoom/pan and main plot zoom', function() {
14121412
var msg2 = ['after dblclick on subplot', s.dblclickSubplot, msg].join(' ');
14131413
var spmatch = s.dblclickSubplot.match(constants.SUBPLOT_PATTERN);
14141414

1415-
it(s.desc, function(done) {
1415+
it('@flaky ' + s.desc, function(done) {
14161416
makePlot(data, layout, s).then(function() {
14171417
assertRanges('base', [
14181418
[['xaxis', 'yaxis'], rng0.xy],

test/jasmine/tests/select_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ describe('Test select box and lasso in general:', function() {
14201420
.then(done, done.fail);
14211421
});
14221422

1423-
it('should cleanly clear and restart selections on double click when add/subtract mode on', function(done) {
1423+
it('@flaky should cleanly clear and restart selections on double click when add/subtract mode on', function(done) {
14241424
var gd = createGraphDiv();
14251425
var fig = Lib.extendDeep({}, require('@mocks/0.json'));
14261426

@@ -2456,7 +2456,7 @@ describe('Test select box and lasso per trace:', function() {
24562456
});
24572457

24582458
[false].forEach(function(hasCssTransform) {
2459-
it('should work for bar traces, hasCssTransform: ' + hasCssTransform, function(done) {
2459+
it('@flaky should work for bar traces, hasCssTransform: ' + hasCssTransform, function(done) {
24602460
var assertPoints = makeAssertPoints(['curveNumber', 'x', 'y']);
24612461
var assertSelectedPoints = makeAssertSelectedPoints();
24622462
var assertRanges = makeAssertRanges();

test/jasmine/tests/splom_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ describe('Test splom select:', function() {
18251825
.then(done, done.fail);
18261826
});
18271827

1828-
it('should be able to select and then clear using API', function(done) {
1828+
it('@gl should be able to select and then clear using API', function(done) {
18291829
function _assert(msg, exp) {
18301830
return function() {
18311831
var uid = gd._fullData[0].uid;

test/jasmine/tests/transition_test.js

+28-32
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
1212
var delay = require('../assets/delay');
1313
var mock = require('@mocks/animation');
1414

15-
function runTests(transitionDuration) {
16-
describe('Plots.transition (duration = ' + transitionDuration + ')', function() {
17-
'use strict';
15+
describe('Plots.transition', function() {
16+
'use strict';
1817

19-
var gd;
18+
var gd;
2019

21-
beforeEach(function(done) {
22-
gd = createGraphDiv();
20+
beforeEach(function(done) {
21+
gd = createGraphDiv();
2322

24-
var mockCopy = Lib.extendDeep({}, mock);
23+
var mockCopy = Lib.extendDeep({}, mock);
2524

26-
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout).then(done);
27-
});
25+
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout).then(done);
26+
});
2827

29-
afterEach(function() {
30-
Plotly.purge(gd);
31-
destroyGraphDiv();
32-
});
28+
afterEach(function() {
29+
Plotly.purge(gd);
30+
destroyGraphDiv();
31+
});
3332

34-
it('resolves only once the transition has completed', function(done) {
33+
// Run the whole set of tests twice: once with zero duration and once with
34+
// nonzero duration since the behavior should be identical, but there's a
35+
// very real possibility of race conditions or other timing issues.
36+
//
37+
// And of course, remember to put the async loop in a closure:
38+
[0, 20].forEach(function(transitionDuration) {
39+
it('with duration:' + transitionDuration + ', resolves only once the transition has completed', function(done) {
3540
var t1 = Date.now();
3641
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
3742

@@ -42,7 +47,7 @@ function runTests(transitionDuration) {
4247
}).then(done, done.fail);
4348
});
4449

45-
it('emits plotly_transitioning on transition start', function(done) {
50+
it('with duration:' + transitionDuration + ', emits plotly_transitioning on transition start', function(done) {
4651
var beginTransitionCnt = 0;
4752
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
4853

@@ -55,7 +60,7 @@ function runTests(transitionDuration) {
5560
}).then(done, done.fail);
5661
});
5762

58-
it('emits plotly_transitioned on transition end', function(done) {
63+
it('with duration:' + transitionDuration + ', emits plotly_transitioned on transition end', function(done) {
5964
var trEndCnt = 0;
6065
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
6166

@@ -68,7 +73,7 @@ function runTests(transitionDuration) {
6873
}).then(done, done.fail);
6974
});
7075

71-
it('transitions an annotation', function(done) {
76+
it('with duration:' + transitionDuration + ', transitions an annotation', function(done) {
7277
function annotationPosition() {
7378
var g = gd._fullLayout._infolayer.select('.annotation').select('.annotation-text-g');
7479
var bBox = g.node().getBoundingClientRect();
@@ -96,7 +101,7 @@ function runTests(transitionDuration) {
96101
}).then(done, done.fail);
97102
});
98103

99-
it('transitions an image', function(done) {
104+
it('with duration:' + transitionDuration + ', transitions an image', function(done) {
100105
var jsLogo = 'https://images.plot.ly/language-icons/api-home/js-logo.png';
101106
var pythonLogo = 'https://images.plot.ly/language-icons/api-home/python-logo.png';
102107

@@ -131,7 +136,7 @@ function runTests(transitionDuration) {
131136
}).then(done, done.fail);
132137
});
133138

134-
it('transitions a shape', function(done) {
139+
it('with duration:' + transitionDuration + ', transitions a shape', function(done) {
135140
function getPath() {
136141
return gd._fullLayout._shapeUpperLayer.select('path').node();
137142
}
@@ -189,7 +194,7 @@ function runTests(transitionDuration) {
189194
});
190195

191196

192-
it('transitions a transform', function(done) {
197+
it('with duration:' + transitionDuration + ', transitions a transform', function(done) {
193198
Plotly.restyle(gd, {
194199
'transforms[0]': {
195200
enabled: true,
@@ -226,7 +231,7 @@ function runTests(transitionDuration) {
226231

227232
// This doesn't really test anything that the above tests don't cover, but it combines
228233
// the behavior and attempts to ensure chaining and events happen in the correct order.
229-
it('transitions may be chained', function(done) {
234+
it('with duration:' + transitionDuration + ', transitions may be chained', function(done) {
230235
var currentlyRunning = 0;
231236
var beginCnt = 0;
232237
var endCnt = 0;
@@ -258,17 +263,8 @@ function runTests(transitionDuration) {
258263
.then(done, done.fail);
259264
});
260265
});
261-
}
266+
});
262267

263-
for(var i = 0; i < 2; i++) {
264-
var duration = i * 20;
265-
// Run the whole set of tests twice: once with zero duration and once with
266-
// nonzero duration since the behavior should be identical, but there's a
267-
// very real possibility of race conditions or other timing issues.
268-
//
269-
// And of course, remember to put the async loop in a closure:
270-
runTests(duration);
271-
}
272268

273269
describe('Plotly.react transitions:', function() {
274270
var gd;
@@ -844,7 +840,7 @@ describe('Plotly.react transitions:', function() {
844840
.then(done, done.fail);
845841
});
846842

847-
it('should not transition layout when axis auto-ranged value do not changed', function(done) {
843+
it('@flaky should not transition layout when axis auto-ranged value do not changed', function(done) {
848844
var data = [{y: [1, 2, 1]}];
849845
var layout = {transition: {duration: 10}};
850846

0 commit comments

Comments
 (0)