@@ -948,10 +948,15 @@ describe('@noCI, mapbox plots', function() {
948948 layout : {
949949 mapbox : {
950950 layers : [ {
951+ 'sourcetype' : 'raster' ,
952+ 'source' : [ 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png' ] ,
953+ 'below' : 'traces' ,
954+ } , {
951955 'sourcetype' : 'image' ,
952956 'coordinates' : coords ,
953- 'source' : source
954- } ]
957+ 'source' : source ,
958+ 'below' : 'traces' ,
959+ } ] ,
955960 }
956961 }
957962 } ;
@@ -970,7 +975,7 @@ describe('@noCI, mapbox plots', function() {
970975 Plotly . react ( gd , makeFigure ( redImage ) ) . then ( function ( ) {
971976 var mapbox = gd . _fullLayout . mapbox . _subplot ;
972977 map = mapbox . map ;
973- layerSource = map . getSource ( mapbox . layerList [ 0 ] . idSource ) ;
978+ layerSource = map . getSource ( mapbox . layerList [ 1 ] . idSource ) ;
974979
975980 spyOn ( layerSource , 'updateImage' ) . and . callThrough ( ) ;
976981 spyOn ( map , 'removeSource' ) . and . callThrough ( ) ;
@@ -981,6 +986,23 @@ describe('@noCI, mapbox plots', function() {
981986 { url : greenImage , coordinates : coords }
982987 ) ;
983988 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 ) ;
9841006 } )
9851007 . catch ( failTest )
9861008 . then ( done ) ;
0 commit comments