@@ -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' , ( ) => {
@@ -69,21 +71,37 @@ describe('Testing the feature selection', () => {
6971 }
7072 }
7173
72- function goToMapViewWithFeatureSelection ( featureInfoPosition = null ) {
74+ function goToMapViewWithFeatureSelection (
75+ featureInfoPosition = null ,
76+ featureCoordinates = null
77+ ) {
7378 const params = {
7479 layers : `${ standardLayer } @features=1:2:3:4:5:6:7:8:9:10` ,
7580 }
81+ if ( featureCoordinates ) {
82+ addFeatureIdentificationIntercepts ( featureCoordinates )
83+ }
7684 if ( featureInfoPosition ) {
7785 params . featureInfo = featureInfoPosition
7886 }
79- cy . goToMapView ( params )
87+ cy . goToMapView (
88+ params ,
89+ true ,
90+ { } ,
91+ {
92+ addFeatureIdentificationIntercepts : ( ) => {
93+ addFeatureIdentificationIntercepts ( featureCoordinates )
94+ } ,
95+ }
96+ )
8097 }
8198
8299 it ( 'Adds pre-selected features and place the tooltip according to URL param on a narrow width screen' , ( ) => {
83100 cy . log ( 'When featureInfo is not specified, we should have no tooltip visible' )
84101 goToMapViewWithFeatureSelection ( )
85102 checkFeatures ( )
86103 checkFeatureInfoPosition ( FeatureInfoPositions . NONE )
104+
87105 // --------------------------------- WIDTH < 400 pixels ---------------------------------------
88106 cy . log (
89107 'When using a viewport with width inferior to 400 pixels, we should always go to infobox when featureInfo is not None.'
@@ -97,6 +115,31 @@ describe('Testing the feature selection', () => {
97115 checkFeatures ( )
98116 checkFeatureInfoPosition ( FeatureInfoPositions . BOTTOMPANEL )
99117 } )
118+ it ( 'Centers correctly the map when pre-selected features are present' , ( ) => {
119+ cy . log ( 'We ensure that when no center is defined, we are on the center of the extent' )
120+ const preDefinedCenter = [ 2671500 , 1190000 ]
121+
122+ goToMapViewWithFeatureSelection ( FeatureInfoPositions . NONE , preDefinedCenter )
123+
124+ cy . readStoreValue ( 'state.position.center' ) . should ( ( storeCenter ) => {
125+ expect ( storeCenter . length ) . to . eq ( 2 )
126+ expect ( storeCenter [ 0 ] ) . to . to . approximately ( preDefinedCenter [ 0 ] , 0.01 )
127+ expect ( storeCenter [ 1 ] ) . to . to . approximately ( preDefinedCenter [ 1 ] , 0.01 )
128+ } )
129+
130+ cy . log (
131+ 'We ensure that when a center is defined, we are on that center on application startup'
132+ )
133+ cy . goToMapView ( {
134+ layers : `${ standardLayer } @features=1:2:3:4:5:6:7:8:9:10` ,
135+ center : `${ preDefinedCenter . join ( ',' ) } ` ,
136+ } )
137+ cy . readStoreValue ( 'state.position.center' ) . should ( ( storeCenter ) => {
138+ expect ( storeCenter . length ) . to . eq ( 2 )
139+ expect ( storeCenter [ 0 ] ) . to . to . approximately ( preDefinedCenter [ 0 ] , 0.01 )
140+ expect ( storeCenter [ 1 ] ) . to . to . approximately ( preDefinedCenter [ 1 ] , 0.01 )
141+ } )
142+ } )
100143 it . skip ( 'Adds pre-selected features and place the tooltip according to URL param on a bigger screen' , ( ) => {
101144 // currently, this breaks on the CI, but works perfectly fine locally. It sets the featureInfo param
102145 // to 'bottomPanel', when it should be set to 'default'.
@@ -179,7 +222,7 @@ describe('Testing the feature selection', () => {
179222 } )
180223 // ------------------------------------------------------------------------------------------------
181224 cy . log ( 'Check that after a reload, features remain selected' )
182- cy . reload ( )
225+ cy . reload ( ) // ISSUE HERE : WE DON'T GET THE FEATURE, BUT IT WORKS ON SITE
183226 cy . wait ( `@featureDetail_${ expectedFeatureIds [ 1 ] } ` )
184227 cy . url ( ) . should ( ( url ) => {
185228 new URLSearchParams ( url . split ( 'map' ) [ 1 ] )
0 commit comments