@@ -948,10 +948,15 @@ describe('@noCI, mapbox plots', function() {
948
948
layout : {
949
949
mapbox : {
950
950
layers : [ {
951
+ 'sourcetype' : 'raster' ,
952
+ 'source' : [ 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png' ] ,
953
+ 'below' : 'traces' ,
954
+ } , {
951
955
'sourcetype' : 'image' ,
952
956
'coordinates' : coords ,
953
- 'source' : source
954
- } ]
957
+ 'source' : source ,
958
+ 'below' : 'traces' ,
959
+ } ] ,
955
960
}
956
961
}
957
962
} ;
@@ -970,7 +975,7 @@ describe('@noCI, mapbox plots', function() {
970
975
Plotly . react ( gd , makeFigure ( redImage ) ) . then ( function ( ) {
971
976
var mapbox = gd . _fullLayout . mapbox . _subplot ;
972
977
map = mapbox . map ;
973
- layerSource = map . getSource ( mapbox . layerList [ 0 ] . idSource ) ;
978
+ layerSource = map . getSource ( mapbox . layerList [ 1 ] . idSource ) ;
974
979
975
980
spyOn ( layerSource , 'updateImage' ) . and . callThrough ( ) ;
976
981
spyOn ( map , 'removeSource' ) . and . callThrough ( ) ;
@@ -981,6 +986,23 @@ describe('@noCI, mapbox plots', function() {
981
986
{ url : greenImage , coordinates : coords }
982
987
) ;
983
988
expect ( map . removeSource ) . not . toHaveBeenCalled ( ) ;
989
+
990
+ // Check order of layers
991
+ var mapbox = gd . _fullLayout . mapbox . _subplot ;
992
+ var mapboxLayers = mapbox . getMapLayers ( ) ;
993
+ var plotlyjsLayers = mapbox . layerList ;
994
+
995
+ var indexLower = mapboxLayers . findIndex ( function ( layer ) {
996
+ return layer . id === 'plotly-layout-layer-' + plotlyjsLayers [ 0 ] . uid ;
997
+ } ) ;
998
+
999
+ var indexUpper = mapboxLayers . findIndex ( function ( layer ) {
1000
+ return layer . id === 'plotly-layout-layer-' + plotlyjsLayers [ 1 ] . uid ;
1001
+ } ) ;
1002
+
1003
+ expect ( indexLower ) . toBeGreaterThan ( - 1 ) ;
1004
+ expect ( indexUpper ) . toBeGreaterThan ( 0 ) ;
1005
+ expect ( indexUpper ) . toBe ( indexLower + 1 ) ;
984
1006
} )
985
1007
. catch ( failTest )
986
1008
. then ( done ) ;
0 commit comments