@@ -19,7 +19,8 @@ function delay() {
19
19
} ) ;
20
20
}
21
21
22
- function waitForModeBar ( ) {
22
+ // updating the camera requires some waiting
23
+ function waitForCamera ( ) {
23
24
return new Promise ( function ( resolve ) {
24
25
setTimeout ( resolve , 200 ) ;
25
26
} ) ;
@@ -836,7 +837,7 @@ describe('Test gl2d plots', function() {
836
837
expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( originalX , precision ) ;
837
838
expect ( gd . layout . yaxis . range ) . toBeCloseToArray ( originalY , precision ) ;
838
839
} )
839
- . then ( waitForModeBar )
840
+ . then ( waitForCamera )
840
841
. then ( function ( ) {
841
842
gd . on ( 'plotly_relayout' , relayoutCallback ) ;
842
843
@@ -879,7 +880,7 @@ describe('Test gl2d plots', function() {
879
880
expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( originalX , precision ) ;
880
881
expect ( gd . layout . yaxis . range ) . toBeCloseToArray ( originalY , precision ) ;
881
882
} )
882
- . then ( waitForModeBar )
883
+ . then ( waitForCamera )
883
884
. then ( function ( ) {
884
885
// callback count expectation: X and back; Y and back; XY and back
885
886
expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 6 ) ;
@@ -1373,15 +1374,11 @@ describe('Test gl3d annotations', function() {
1373
1374
1374
1375
// more robust (especially on CI) than update camera via mouse events
1375
1376
function updateCamera ( x , y , z ) {
1376
- return new Promise ( function ( resolve ) {
1377
- var scene = gd . _fullLayout . scene . _scene ;
1378
- var camera = scene . getCamera ( ) ;
1379
-
1380
- camera . eye = { x : x , y : y , z : z } ;
1381
- scene . setCamera ( camera ) ;
1377
+ var scene = gd . _fullLayout . scene . _scene ;
1378
+ var camera = scene . getCamera ( ) ;
1382
1379
1383
- setTimeout ( resolve , 100 ) ;
1384
- } ) ;
1380
+ camera . eye = { x : x , y : y , z : z } ;
1381
+ scene . setCamera ( camera ) ;
1385
1382
}
1386
1383
1387
1384
it ( 'should move with camera' , function ( done ) {
@@ -1410,11 +1407,13 @@ describe('Test gl3d annotations', function() {
1410
1407
1411
1408
return updateCamera ( 1.5 , 2.5 , 1.5 ) ;
1412
1409
} )
1410
+ . then ( waitForCamera )
1413
1411
. then ( function ( ) {
1414
1412
assertAnnotationsXY ( [ [ 340 , 187 ] , [ 341 , 142 ] , [ 325 , 221 ] ] , 'after camera update' ) ;
1415
1413
1416
1414
return updateCamera ( 2.1 , 0.1 , 0.9 ) ;
1417
1415
} )
1416
+ . then ( waitForCamera )
1418
1417
. then ( function ( ) {
1419
1418
assertAnnotationsXY ( [ [ 262 , 199 ] , [ 257 , 135 ] , [ 325 , 233 ] ] , 'base 0' ) ;
1420
1419
} )
0 commit comments