@@ -5,6 +5,8 @@ import proj4 from 'proj4'
55import { DEFAULT_FEATURE_COUNT_RECTANGLE_SELECTION } from '@/config/map.config'
66import { FeatureInfoPositions } from '@/store/modules/ui.store'
77
8+ import { addFeatureIdentificationIntercepts } from '../support/intercepts'
9+
810registerProj4 ( proj4 )
911
1012describe ( 'Testing the feature selection' , ( ) => {
@@ -84,6 +86,7 @@ describe('Testing the feature selection', () => {
8486 goToMapViewWithFeatureSelection ( )
8587 checkFeatures ( )
8688 checkFeatureInfoPosition ( FeatureInfoPositions . NONE )
89+
8790 // --------------------------------- WIDTH < 400 pixels ---------------------------------------
8891 cy . log (
8992 'When using a viewport with width inferior to 400 pixels, we should always go to infobox when featureInfo is not None.'
@@ -97,6 +100,42 @@ describe('Testing the feature selection', () => {
97100 checkFeatures ( )
98101 checkFeatureInfoPosition ( FeatureInfoPositions . BOTTOMPANEL )
99102 } )
103+ it ( 'Centers correctly the map when pre-selected features are present' , ( ) => {
104+ cy . log ( 'We ensure that when no center is defined, we are on the center of the extent' )
105+ const preDefinedCenter = [ 2671500 , 1190000 ]
106+
107+ // we override the interception to ensure the features are in a fixed position
108+ cy . goToMapView (
109+ {
110+ layers : `${ standardLayer } @features=1:2:3:4:5:6:7:8:9:10` ,
111+ } ,
112+ true ,
113+ { } ,
114+ {
115+ addFeatureIdentificationIntercepts : ( ) =>
116+ addFeatureIdentificationIntercepts ( preDefinedCenter ) ,
117+ }
118+ )
119+
120+ cy . readStoreValue ( 'state.position.center' ) . should ( ( storeCenter ) => {
121+ expect ( storeCenter . length ) . to . eq ( 2 )
122+ expect ( storeCenter [ 0 ] ) . to . to . approximately ( preDefinedCenter [ 0 ] , 0.01 )
123+ expect ( storeCenter [ 1 ] ) . to . to . approximately ( preDefinedCenter [ 1 ] , 0.01 )
124+ } )
125+
126+ cy . log (
127+ 'We ensure that when a center is defined, we are on that center on application startup'
128+ )
129+ cy . goToMapView ( {
130+ layers : `${ standardLayer } @features=1:2:3:4:5:6:7:8:9:10` ,
131+ center : `${ preDefinedCenter . join ( ',' ) } ` ,
132+ } )
133+ cy . readStoreValue ( 'state.position.center' ) . should ( ( storeCenter ) => {
134+ expect ( storeCenter . length ) . to . eq ( 2 )
135+ expect ( storeCenter [ 0 ] ) . to . to . approximately ( preDefinedCenter [ 0 ] , 0.01 )
136+ expect ( storeCenter [ 1 ] ) . to . to . approximately ( preDefinedCenter [ 1 ] , 0.01 )
137+ } )
138+ } )
100139 it . skip ( 'Adds pre-selected features and place the tooltip according to URL param on a bigger screen' , ( ) => {
101140 // currently, this breaks on the CI, but works perfectly fine locally. It sets the featureInfo param
102141 // to 'bottomPanel', when it should be set to 'default'.
0 commit comments