From e77d7279738a80037f76204857693a5ade7c41e4 Mon Sep 17 00:00:00 2001 From: Felix Sommer Date: Fri, 5 Dec 2025 10:37:14 +0100 Subject: [PATCH 1/2] PB-2064: fix featureSelection cypress test --- .../plugins/storeSync/params/featureInfo.param.ts | 2 +- .../store/plugins/storeSync/params/layers.param.ts | 5 +++-- .../tests/cypress/tests-e2e/featureSelection.cy.ts | 14 ++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/viewer/src/store/plugins/storeSync/params/featureInfo.param.ts b/packages/viewer/src/store/plugins/storeSync/params/featureInfo.param.ts index ae9b13fb7f..a5ffba28cb 100644 --- a/packages/viewer/src/store/plugins/storeSync/params/featureInfo.param.ts +++ b/packages/viewer/src/store/plugins/storeSync/params/featureInfo.param.ts @@ -29,7 +29,7 @@ function parseFeatureInfoPosition(urlParamValue?: string): FeatureInfoPositions const featureInfoParamConfig = new UrlParamConfig({ urlParamName: 'featureInfo', - actionsToWatch: ['setFeatureInfoPosition'], + actionsToWatch: ['setFeatureInfoPosition', 'clearAllSelectedFeatures'], extractValueFromStore: () => useUIStore().featureInfoPosition, setValuesInStore: (_: RouteLocationNormalizedGeneric, urlParamValue?: string) => { const position = parseFeatureInfoPosition(urlParamValue) diff --git a/packages/viewer/src/store/plugins/storeSync/params/layers.param.ts b/packages/viewer/src/store/plugins/storeSync/params/layers.param.ts index de6535092b..7f36b6a95c 100644 --- a/packages/viewer/src/store/plugins/storeSync/params/layers.param.ts +++ b/packages/viewer/src/store/plugins/storeSync/params/layers.param.ts @@ -125,7 +125,7 @@ export function createLayerObject(parsedLayer: Partial, currentLayer?: La layer.opacity = parsedLayer.opacity ?? DEFAULT_OPACITY if (adminId && layer.type === LayerType.KML) { - ;(layer as KMLLayer).adminId = adminId + ; (layer as KMLLayer).adminId = adminId } } else if (parsedLayer.type === LayerType.KML) { // format is KML|FILE_URL @@ -184,7 +184,7 @@ export function createLayerObject(parsedLayer: Partial, currentLayer?: La const internalLayer = layer as GeoAdminLayer if (internalLayer.type === LayerType.GEOJSON && updateDelay !== undefined) { - ;(internalLayer as GeoAdminGeoJSONLayer).updateDelay = updateDelay + ; (internalLayer as GeoAdminGeoJSONLayer).updateDelay = updateDelay } // only highlightable feature will output something, for the others a click coordinate is required @@ -427,6 +427,7 @@ const layersParam = new UrlParamConfig({ 'updateLayer', 'updateLayers', 'setSelectedFeatures', + 'clearAllSelectedFeatures' ], setValuesInStore: dispatchLayersFromUrlIntoStore, extractValueFromStore: generateLayerUrlParamFromStoreValues, diff --git a/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts b/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts index 2547ce305b..9f3f5ab336 100644 --- a/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts +++ b/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts @@ -127,7 +127,6 @@ describe('Testing the feature selection', () => { checkFeatures() checkFeatureInfoPosition(FeatureInfoPositions.ToolTip) }) - it('Synchronise URL and feature selection', () => { const expectedFeatureIds = [1234, 5678] const mapSelector = '[data-cy="ol-map"]' @@ -137,7 +136,7 @@ describe('Testing the feature selection', () => { }, }) cy.url().should((url) => { - expect(new URLSearchParams(url.split('map')[1]).get('featureInfo')).to.eq(undefined) + expect(new URLSearchParams(url.split('map')[1]).get('featureInfo')).to.eq(null) }) cy.log('Check that the features appear in the URL') @@ -167,7 +166,7 @@ describe('Testing the feature selection', () => { } }) }) - // ------------------------------------------------------------------------------------------------ + // ------------------------------------------------------------------------------------------------- cy.log('Check that clicking another feature from the same layer changes the URL') assertDefined(expectedFeatureIds[1]) createInterceptWithFeatureId(expectedFeatureIds[1], standardLayer) @@ -192,7 +191,8 @@ describe('Testing the feature selection', () => { cy.log('Check that after a reload, features remain selected') cy.reload() - cy.wait(`@featureDetail_${expectedFeatureIds[1]}`) + cy.wait(['@layerConfig', '@topics']) + cy.wait(`@featureDetail_${expectedFeatureIds[1]}`, { timeout: 10000 }) cy.url().should((url) => { new URLSearchParams(url.split('map')[1]) .get('layers')! @@ -219,10 +219,12 @@ describe('Testing the feature selection', () => { .should('be.visible') .click() cy.closeMenuIfMobile() + cy.wait(`@htmlPopup`) cy.get(mapSelector).click() cy.wait(`@${timeLayer}_identify`) cy.wait(`@htmlPopup`) + cy.wait('@htmlPopup') cy.url().should((url) => { new URLSearchParams(url.split('map')[1]) @@ -241,7 +243,6 @@ describe('Testing the feature selection', () => { } }) }) - cy.log('Check that upon closing, the features are no longer in the URL') cy.get('[data-cy="infobox-close"]').click() cy.get('[data-cy="highlighted-features"]').should('not.exist') @@ -369,7 +370,6 @@ describe('Testing the feature selection', () => { assertDefined(location[1]) cy.get('@olMap').click(location[0], location[1], { ctrlKey }) } - it('can select an area to identify features inside it', () => { const fileName = 'external-kml-file.kml' const localKmlFile = `import-tool/${fileName}` @@ -526,7 +526,6 @@ describe('Testing the feature selection', () => { cy.get('@identifySingleFeature.all').should('have.length', 1) cy.get('@emptyIdentify.all').should('have.length', 1) }) - it('can select feature by click, add more feature, and deselect feature', () => { const fileName = '4-points.kml' const localKmlFile = `import-tool/${fileName}` @@ -598,7 +597,6 @@ describe('Testing the feature selection', () => { }) }) }) - it('can print feature information', () => { const fileName = 'external-kml-file.kml' const localKmlFile = `import-tool/${fileName}` From 548124155f999ee85ea4bf167164c29f955ea5d1 Mon Sep 17 00:00:00 2001 From: Felix Sommer Date: Fri, 5 Dec 2025 15:44:50 +0100 Subject: [PATCH 2/2] PB-2064: fix feature selection test --- packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts b/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts index 9f3f5ab336..2ef989aeca 100644 --- a/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts +++ b/packages/viewer/tests/cypress/tests-e2e/featureSelection.cy.ts @@ -166,7 +166,7 @@ describe('Testing the feature selection', () => { } }) }) - // ------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------------------------------------------ cy.log('Check that clicking another feature from the same layer changes the URL') assertDefined(expectedFeatureIds[1]) createInterceptWithFeatureId(expectedFeatureIds[1], standardLayer) @@ -224,7 +224,6 @@ describe('Testing the feature selection', () => { cy.get(mapSelector).click() cy.wait(`@${timeLayer}_identify`) cy.wait(`@htmlPopup`) - cy.wait('@htmlPopup') cy.url().should((url) => { new URLSearchParams(url.split('map')[1])