Skip to content

Commit 446123c

Browse files
authored
Merge pull request #5340 from plotly/ensure-return-promise
Return and handle promises in tests
2 parents acdab44 + 5a3110a commit 446123c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3053
-2159
lines changed

.circleci/test.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set +o pipefail
66

77
ROOT=$(dirname $0)/..
88
EXIT_STATE=0
9-
MAX_AUTO_RETRY=5
9+
MAX_AUTO_RETRY=0
1010

1111
log () {
1212
echo -e "\n$1"
@@ -55,6 +55,7 @@ case $1 in
5555

5656
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --limit=5 --tag=gl | circleci tests split))
5757
for s in ${SHARDS[@]}; do
58+
MAX_AUTO_RETRY=1
5859
retry npm run test-jasmine -- "$s" --tags=gl --skip-tags=noCI --doNotFailOnEmptyTestSuite
5960
done
6061

@@ -67,6 +68,7 @@ case $1 in
6768
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --limit=1 --tag=flaky | circleci tests split))
6869

6970
for s in ${SHARDS[@]}; do
71+
MAX_AUTO_RETRY=5
7072
retry npm run test-jasmine -- "$s" --tags=flaky --skip-tags=noCI
7173
done
7274

@@ -80,6 +82,7 @@ case $1 in
8082
;;
8183

8284
image2)
85+
MAX_AUTO_RETRY=5
8386
retry npm run test-image -- --just-flaky
8487
npm run test-export || EXIT_STATE=$?
8588
exit $EXIT_STATE

test/jasmine/tests/animate_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ describe('Animating multiple axes', function() {
719719
destroyGraphDiv();
720720
});
721721

722-
it('@flaky updates ranges of secondary axes', function(done) {
722+
it('updates ranges of secondary axes', function(done) {
723723
Plotly.plot(gd, [
724724
{y: [1, 2, 3]},
725725
{y: [1, 2, 3], yaxis: 'y2'}
@@ -750,7 +750,7 @@ describe('Animating multiple axes', function() {
750750
.then(done);
751751
});
752752

753-
it('@flaky updates ranges of secondary axes (date + category case)', function(done) {
753+
it('updates ranges of secondary axes (date + category case)', function(done) {
754754
Plotly.plot(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'}

test/jasmine/tests/annotations_test.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,13 @@ describe('annotations relayout', function() {
187187
expect(typeof MathJax).toBe('undefined');
188188
mockLayout.annotations[14].text = '$x+y+z$';
189189

190-
Plotly.plot(gd, mockData, mockLayout).then(done);
191-
192-
spyOn(Loggers, 'warn');
190+
Plotly.plot(gd, mockData, mockLayout)
191+
.then(function() {
192+
spyOn(Loggers, 'warn');
193193

194-
Plotly.setPlotConfig({queueLength: 3});
194+
return Plotly.setPlotConfig({queueLength: 3});
195+
})
196+
.then(done);
195197
});
196198

197199
afterEach(function() {
@@ -327,7 +329,8 @@ describe('annotations relayout', function() {
327329

328330
assertText(0, 'left top');
329331

330-
Plotly.relayout(gd, 'annotations[0].text', 'hello').then(function() {
332+
Plotly.relayout(gd, 'annotations[0].text', 'hello')
333+
.then(function() {
331334
assertText(0, 'hello');
332335

333336
return Plotly.relayout(gd, 'annotations[0].text', null);
@@ -427,11 +430,15 @@ describe('annotations relayout', function() {
427430
{'annotations[0]': 'not an object'},
428431
{'annotations[100]': {text: 'bad index'}}
429432
].forEach(function(update) {
430-
it('warns on ambiguous combinations and invalid values: ' + JSON.stringify(update), function() {
431-
Plotly.relayout(gd, update);
432-
expect(Loggers.warn).toHaveBeenCalled();
433-
// we could test the results here, but they're ambiguous and/or undefined so why bother?
434-
// the important thing is the developer is warned that something went wrong.
433+
it('warns on ambiguous combinations and invalid values: ' + JSON.stringify(update), function(done) {
434+
Plotly.relayout(gd, update)
435+
.then(function() {
436+
expect(Loggers.warn).toHaveBeenCalled();
437+
// we could test the results here, but they're ambiguous and/or undefined so why bother?
438+
// the important thing is the developer is warned that something went wrong.
439+
})
440+
.catch(failTest)
441+
.then(done);
435442
});
436443
});
437444

test/jasmine/tests/axes_test.js

+157-88
Large diffs are not rendered by default.

test/jasmine/tests/calcdata_test.js

+561-444
Large diffs are not rendered by default.

test/jasmine/tests/carpet_test.js

+6
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ describe('scattercarpet hover labels', function() {
724724
[200, 200], fig,
725725
[['a: 0.200', 'b: 3.500', 'y: 2.900'], 'a = 0.2']
726726
)
727+
.catch(failTest)
727728
.then(done);
728729
});
729730

@@ -736,6 +737,7 @@ describe('scattercarpet hover labels', function() {
736737
[200, 200], fig,
737738
[['a: 0.200', 'b: 3.500', 'y: 2.900', 'D'], 'a = 0.2']
738739
)
740+
.catch(failTest)
739741
.then(done);
740742
});
741743

@@ -747,6 +749,7 @@ describe('scattercarpet hover labels', function() {
747749
[200, 200], fig,
748750
[['a: 0.200', 'y: 2.900'], null]
749751
)
752+
.catch(failTest)
750753
.then(done);
751754
});
752755

@@ -758,6 +761,7 @@ describe('scattercarpet hover labels', function() {
758761
[200, 200], fig,
759762
[['b: 3.500', 'y: 2.900'], null]
760763
)
764+
.catch(failTest)
761765
.then(done);
762766
});
763767

@@ -769,6 +773,7 @@ describe('scattercarpet hover labels', function() {
769773
[200, 200], fig,
770774
[['f(0.2, 3.5) = 2.900'], 'scattercarpet #5']
771775
)
776+
.catch(failTest)
772777
.then(done);
773778
});
774779

@@ -780,6 +785,7 @@ describe('scattercarpet hover labels', function() {
780785
[200, 200], fig,
781786
[['f(0.2, 3.5) = 3.0'], 'pt #3']
782787
)
788+
.catch(failTest)
783789
.then(done);
784790
});
785791
});

test/jasmine/tests/cartesian_interact_test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describe('zoom box element', function() {
3232
mockCopy.layout.dragmode = 'zoom';
3333

3434
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
35-
.catch(failTest)
3635
.then(done);
3736
});
3837

@@ -974,7 +973,7 @@ describe('axis zoom/pan and main plot zoom', function() {
974973
var yr0 = [-0.211, 3.211];
975974

976975
var specs = [{
977-
desc: 'zoombox on xy',
976+
desc: '@flaky zoombox on xy',
978977
drag: ['xy', 'nsew', 30, 30],
979978
exp: [
980979
[['xaxis', 'xaxis2', 'xaxis3'], [1.457, 2.328]],
@@ -2338,7 +2337,7 @@ describe('Event data:', function() {
23382337
expect('marker.colorbar.tickvals' in pt).toBe(false, 'marker.colorbar.tickvals');
23392338
expect('marker.colorbar.ticktext' in pt).toBe(false, 'marker.colorbar.ticktext');
23402339
})
2341-
.catch(fail)
2340+
.catch(failTest)
23422341
.then(done);
23432342
});
23442343

@@ -2366,7 +2365,7 @@ describe('Event data:', function() {
23662365
expect('marker.colorbar.tickvals' in pt).toBe(false, 'marker.colorbar.tickvals');
23672366
expect('marker.colorbar.ticktext' in pt).toBe(false, 'marker.colorbar.ticktext');
23682367
})
2369-
.catch(fail)
2368+
.catch(failTest)
23702369
.then(done);
23712370
});
23722371
});

test/jasmine/tests/choropleth_test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ describe('Test choropleth hover:', function() {
205205
fig,
206206
['RUS\n10', 'trace 1']
207207
)
208+
.catch(failTest)
208209
.then(done);
209210
});
210211
});
@@ -220,6 +221,7 @@ describe('Test choropleth hover:', function() {
220221
fig,
221222
['tpl 10', 'x']
222223
)
224+
.catch(failTest)
223225
.then(done);
224226
});
225227
});
@@ -236,6 +238,7 @@ describe('Test choropleth hover:', function() {
236238
fig,
237239
['tExT', null]
238240
)
241+
.catch(failTest)
239242
.then(done);
240243
});
241244
});
@@ -252,6 +255,7 @@ describe('Test choropleth hover:', function() {
252255
fig,
253256
['-text-', null]
254257
)
258+
.catch(failTest)
255259
.then(done);
256260
});
257261
});
@@ -269,6 +273,7 @@ describe('Test choropleth hover:', function() {
269273
fig,
270274
['-text-', null]
271275
)
276+
.catch(failTest)
272277
.then(done);
273278
});
274279
});
@@ -295,6 +300,7 @@ describe('Test choropleth hover:', function() {
295300
fontFamily: 'Roboto'
296301
}
297302
)
303+
.catch(failTest)
298304
.then(done);
299305
});
300306
});
@@ -310,6 +316,7 @@ describe('Test choropleth hover:', function() {
310316
fig,
311317
['RUS', 'trace 1']
312318
)
319+
.catch(failTest)
313320
.then(done);
314321
});
315322
});
@@ -330,15 +337,19 @@ describe('Test choropleth hover:', function() {
330337

331338
[false, true].forEach(function(hasCssTransform) {
332339
it('- base case (truncate z decimals), hasCssTransform: ' + hasCssTransform, function(done) {
333-
run(hasCssTransform, pos, base(), exp).then(done);
340+
run(hasCssTransform, pos, base(), exp)
341+
.catch(failTest)
342+
.then(done);
334343
});
335344
});
336345

337346
[false, true].forEach(function(hasCssTransform) {
338347
it('- hovertemplate case (same z truncation), hasCssTransform: ' + hasCssTransform, function(done) {
339348
var fig = base();
340349
fig.hovertemplate = '%{z}<extra>%{location}</extra>';
341-
run(hasCssTransform, pos, fig, exp).then(done);
350+
run(hasCssTransform, pos, fig, exp)
351+
.catch(failTest)
352+
.then(done);
342353
});
343354
});
344355
});
@@ -350,7 +361,9 @@ describe('Test choropleth hover:', function() {
350361
fig.data[0].hovertemplate = '%{properties.name}<extra>%{ct[0]:.1f} | %{ct[1]:.1f}</extra>';
351362
fig.layout.geo.projection = {scale: 20};
352363

353-
run(hasCssTransform, [300, 200], fig, ['New York', '-75.1 | 42.6']).then(done);
364+
run(hasCssTransform, [300, 200], fig, ['New York', '-75.1 | 42.6'])
365+
.catch(failTest)
366+
.then(done);
354367
});
355368
});
356369
});

test/jasmine/tests/choroplethmapbox_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ describe('Test choroplethmapbox convert:', function() {
516516
});
517517
});
518518

519-
describe('@noCI Test choroplethmapbox hover:', function() {
519+
describe('Test choroplethmapbox hover:', function() {
520520
var gd;
521521

522522
afterEach(function(done) {
@@ -653,7 +653,7 @@ describe('@noCI Test choroplethmapbox hover:', function() {
653653
});
654654
});
655655

656-
describe('@noCI Test choroplethmapbox interactions:', function() {
656+
describe('Test choroplethmapbox interactions:', function() {
657657
var gd;
658658

659659
var geojson = {

0 commit comments

Comments
 (0)