@@ -712,3 +712,210 @@ test.describe('Drag and drop design with relations', () => {
712712
713713 } ) ;
714714} ) ;
715+
716+ test . describe ( 'Group popup by layers @readonly' , ( ) => {
717+
718+ [ 'dock' , 'map' , 'minidock' ] . forEach ( ( popupLocation ) => {
719+ test ( `popup on ${ popupLocation } ` , async ( { page } ) => {
720+ if ( popupLocation != 'minidock' ) {
721+ await page . route ( '**/service/getProjectConfig*' , async route => {
722+ const response = await route . fetch ( ) ;
723+ const json = await response . json ( ) ;
724+ json . options [ 'popupLocation' ] = popupLocation ;
725+ await route . fulfill ( { response, json } ) ;
726+ } ) ;
727+ }
728+
729+ const project = new ProjectPage ( page , `popup_grouped_by_layer${ popupLocation == 'minidock' ? '_minidock' : '' } ` ) ;
730+ await project . open ( ) ;
731+ await project . closeLeftDock ( ) ;
732+
733+ // Remove catching GetProjectConfig
734+ if ( popupLocation != 'minidock' ) {
735+ await page . unroute ( '**/service/getProjectConfig*' ) ;
736+ }
737+ let getFeatureInfoPromise = project . waitForGetFeatureInfoRequest ( ) ;
738+ await project . clickOnMap ( 417 , 289 ) ;
739+ let getFeatureInfoRequest = await getFeatureInfoPromise ;
740+ let getFeatureInfoResponse = await getFeatureInfoRequest . response ( ) ;
741+ responseExpect ( getFeatureInfoResponse ) . toBeHtml ( ) ;
742+ await page . waitForTimeout ( 500 ) ;
743+
744+ const loc = await page . evaluate ( 'lizMap.config.options.popupLocation' ) ;
745+ await expect ( loc ) . toBe ( popupLocation ) ;
746+
747+ // check grouped layers
748+ let groups = await project . checkGroupPopupByLayersGroups ( [
749+ {
750+ name : 'single_wms_points' ,
751+ count : 4
752+ } ,
753+ {
754+ name : 'single_wms_lines' ,
755+ count : 1
756+ } ,
757+ {
758+ name : 'single_wms_baselayer' ,
759+ count : 1
760+ } ,
761+ ] ) ;
762+
763+ // check first layer
764+ await groups . nth ( 0 ) . click ( ) ;
765+ await project . checkGroupPopupByLayersFeatures ( 1 , 1 , '1/4' , 2 ) ;
766+ let features = await project . getPopupSingleFeatures ( true ) ;
767+ await expect ( features ) . toHaveCount ( 6 ) ;
768+
769+ await expect ( features . nth ( 0 ) ) . toBeVisible ( ) ;
770+ await expect ( features . nth ( 0 ) . locator ( '.lizmapPopupTitle' ) ) . toHaveText ( 'single_wms_points' ) ;
771+ await expect ( features . nth ( 1 ) ) . not . toBeVisible ( ) ;
772+ await expect ( features . nth ( 2 ) ) . not . toBeVisible ( ) ;
773+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
774+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
775+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
776+
777+ // switch feature
778+ await project . groupPopupByLayersSwitchFeature ( ) ;
779+
780+ await project . checkGroupPopupByLayersFeatures ( 1 , 1 , '2/4' , 2 ) ;
781+
782+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
783+ await expect ( features . nth ( 1 ) ) . toBeVisible ( ) ;
784+ await expect ( features . nth ( 2 ) ) . not . toBeVisible ( ) ;
785+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
786+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
787+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
788+
789+ await project . groupPopupByLayersSwitchFeature ( ) ;
790+ await project . checkGroupPopupByLayersFeatures ( 1 , 1 , '3/4' , 2 ) ;
791+
792+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
793+ await expect ( features . nth ( 1 ) ) . not . toBeVisible ( ) ;
794+ await expect ( features . nth ( 2 ) ) . toBeVisible ( ) ;
795+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
796+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
797+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
798+
799+ await project . groupPopupByLayersSwitchFeature ( 'prev' ) ;
800+
801+ await project . checkGroupPopupByLayersFeatures ( 1 , 1 , '2/4' , 2 ) ;
802+
803+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
804+ await expect ( features . nth ( 1 ) ) . toBeVisible ( ) ;
805+ await expect ( features . nth ( 2 ) ) . not . toBeVisible ( ) ;
806+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
807+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
808+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
809+
810+ await project . groupPopupByLayersSwitchFeature ( ) ;
811+
812+ // back to layers list
813+ await project . groupPopupByLayersBackToList ( ) ;
814+ groups = await project . checkGroupPopupByLayersGroups ( [
815+ {
816+ name : 'single_wms_points' ,
817+ count : 4
818+ } ,
819+ {
820+ name : 'single_wms_lines' ,
821+ count : 1
822+ } ,
823+ {
824+ name : 'single_wms_baselayer' ,
825+ count : 1
826+ } ,
827+ ] ) ;
828+
829+ await groups . nth ( 1 ) . click ( ) ;
830+ await project . checkGroupPopupByLayersFeatures ( 1 , 0 , '' , 0 ) ;
831+
832+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
833+ await expect ( features . nth ( 1 ) ) . not . toBeVisible ( ) ;
834+ await expect ( features . nth ( 2 ) ) . not . toBeVisible ( ) ;
835+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
836+ await expect ( features . nth ( 4 ) ) . toBeVisible ( ) ;
837+ await expect ( features . nth ( 4 ) . locator ( '.lizmapPopupTitle' ) ) . toHaveText ( 'single_wms_lines' ) ;
838+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
839+
840+ // check wether lizmap features table component is rendered
841+ await expect ( features . nth ( 4 ) . locator ( 'lizmap-features-table' ) ) . toHaveCount ( 1 ) ;
842+
843+ await project . groupPopupByLayersBackToList ( ) ;
844+ groups = await project . checkGroupPopupByLayersGroups ( [
845+ {
846+ name : 'single_wms_points' ,
847+ count : 4
848+ } ,
849+ {
850+ name : 'single_wms_lines' ,
851+ count : 1
852+ } ,
853+ {
854+ name : 'single_wms_baselayer' ,
855+ count : 1
856+ } ,
857+ ] ) ;
858+
859+ await groups . nth ( 2 ) . click ( ) ;
860+ await project . checkGroupPopupByLayersFeatures ( 1 , 0 , '' , 0 ) ;
861+ await expect ( page . locator ( 'lizmap-group-popup-layer .gpl-back' ) ) . toHaveCount ( 1 ) ;
862+ await expect ( page . locator ( 'lizmap-group-popup-layer .gpl-counter' ) ) . toHaveCount ( 0 ) ;
863+ await expect ( page . locator ( 'lizmap-group-popup-layer .gpl-nav-buttons' ) ) . toHaveCount ( 0 ) ;
864+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
865+ await expect ( features . nth ( 1 ) ) . not . toBeVisible ( ) ;
866+ await expect ( features . nth ( 2 ) ) . not . toBeVisible ( ) ;
867+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
868+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
869+ await expect ( features . nth ( 5 ) ) . toBeVisible ( ) ;
870+ await expect ( features . nth ( 5 ) . locator ( '.lizmapPopupTitle' ) ) . toHaveText ( 'single_wms_baselayer' ) ;
871+
872+ // the status is mantained
873+ await project . groupPopupByLayersBackToList ( ) ;
874+ groups = await project . checkGroupPopupByLayersGroups ( [
875+ {
876+ name : 'single_wms_points' ,
877+ count : 4
878+ } ,
879+ {
880+ name : 'single_wms_lines' ,
881+ count : 1
882+ } ,
883+ {
884+ name : 'single_wms_baselayer' ,
885+ count : 1
886+ } ,
887+ ] ) ;
888+
889+ await groups . nth ( 0 ) . click ( ) ;
890+ await project . checkGroupPopupByLayersFeatures ( 1 , 1 , '3/4' , 2 ) ;
891+
892+ await expect ( features . nth ( 0 ) ) . not . toBeVisible ( ) ;
893+ await expect ( features . nth ( 1 ) ) . not . toBeVisible ( ) ;
894+ await expect ( features . nth ( 2 ) ) . toBeVisible ( ) ;
895+ await expect ( features . nth ( 3 ) ) . not . toBeVisible ( ) ;
896+ await expect ( features . nth ( 4 ) ) . not . toBeVisible ( ) ;
897+ await expect ( features . nth ( 5 ) ) . not . toBeVisible ( ) ;
898+
899+ // check if relation is visible
900+ await features . nth ( 2 ) . locator ( '.nav-item' ) . nth ( 1 ) . click ( ) ;
901+ expect ( features . nth ( 2 ) . locator ( '.lizmapPopupSingleFeature[data-layer-id="table_for_relationnal_value_fbba335b_1fa6_4560_9eed_7591c0aa9b74"]' ) ) . toBeVisible ( )
902+
903+ await project . switcher . click ( ) ;
904+ //turn off all layers except the single_wms_baselayer and then reuqest popup
905+ await page . getByTestId ( 'single_wms_polygons' ) . locator ( 'input' ) . first ( ) . uncheck ( ) ;
906+ await page . getByTestId ( 'single_wms_points' ) . locator ( 'input' ) . first ( ) . uncheck ( ) ;
907+ await page . getByTestId ( 'single_wms_lines_group' ) . locator ( 'input' ) . first ( ) . uncheck ( ) ;
908+ await page . getByTestId ( 'single_wms_lines' ) . locator ( 'input' ) . first ( ) . uncheck ( ) ;
909+
910+ getFeatureInfoPromise = project . waitForGetFeatureInfoRequest ( ) ;
911+ await project . clickOnMap ( 417 , 289 ) ;
912+ getFeatureInfoRequest = await getFeatureInfoPromise ;
913+ getFeatureInfoResponse = await getFeatureInfoRequest . response ( ) ;
914+ responseExpect ( getFeatureInfoResponse ) . toBeHtml ( ) ;
915+ await page . waitForTimeout ( 500 ) ;
916+
917+ await project . checkGroupPopupByLayersFeatures ( 0 , 0 , '' , 0 ) ;
918+ } )
919+ } )
920+
921+ } )
0 commit comments