From 5d2f860432f022c5c3e9ca743524765ad89b8a87 Mon Sep 17 00:00:00 2001 From: Moritz Kirmse Date: Thu, 31 Oct 2024 16:30:34 +0100 Subject: [PATCH] rename feature edit layer for better distinction in tests + cleanup --- cypress/e2e/draw/draw-feat-style.cy.ts | 42 +++++-------------------- src/composables/draw/edit.composable.ts | 8 +++-- 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/cypress/e2e/draw/draw-feat-style.cy.ts b/cypress/e2e/draw/draw-feat-style.cy.ts index 45bbdcbc..674da6fe 100644 --- a/cypress/e2e/draw/draw-feat-style.cy.ts +++ b/cypress/e2e/draw/draw-feat-style.cy.ts @@ -33,6 +33,7 @@ describe('Test style edition of Point feature', () => { cy.wrap(ff[0].get('t')).should('equal', '10') }) + // URL is updated when clicking validation button cy.get('button[data-cy="featureEditValidate"]').click() cy.url().as('url') @@ -44,7 +45,7 @@ describe('Test style edition of Point feature', () => { )! const ff = fh.readFeatures(features) cy.wrap(ff).its('length').should('equal', 1) - cy.log(JSON.stringify(ff[0].values_)) + cy.wrap(ff[0].getGeometry()?.getType()).should('equal', 'Point') // check color green cy.wrap(ff[0].get('c')).should('equal', '%2300ff00') @@ -127,15 +128,8 @@ describe('Test style edition of Point feature', () => { const features = featureLayers .map((l: any) => l.getSource().getFeatures()) .flat() - // if the edit mode stays active, two features are created, so the length check fails - cy.log( - `${features.length} features found with names: ${features.map( - (f: any) => f.get('name') - )}` - ) - // cy.wrap(features.length).should('equal', 1) + cy.wrap(features.length).should('equal', 1) - // const ff = features.find((f: any) => f.get('name') == 'Nom 1') const ff = features[0] // check size = 10 cy.wrap(ff.featureStyle.size).should('equal', 10) @@ -176,15 +170,8 @@ describe('Test style edition of Label feature', () => { const features = featureLayers .map((l: any) => l.getSource().getFeatures()) .flat() - // if the edit mode stays active, two features are created, so the length check fails - cy.log( - `${features.length} features found with names: ${features.map(f => - f.get('name') - )}` - ) - // cy.wrap(features.length).should('equal', 1) + cy.wrap(features.length).should('equal', 1) - // const ff = features.find((f: any) => f.get('name') == 'Étiquette 1') const ff = features[0] cy.wrap(ff.featureType).should('equal', 'drawnLabel') // check color green @@ -235,15 +222,10 @@ describe('Test style edition of Line feature', () => { .getLayers() .getArray() .filter((l: any) => l.get('cyLayerType') == 'featureLayer') - cy.log(featureLayers.length) const features = featureLayers .map((l: any) => l.getSource().getFeatures()) .flat() - cy.log(features.length) - cy.log(features.map(f => f.get('name'))) - // if the edit mode stays active, two features are created, so the length check fails - // cy.wrap(features.length).should('equal', 1) - // const ff = features.find((f: any) => f.get('name') == 'Ligne 1') + cy.wrap(features.length).should('equal', 1) const ff = features[0] cy.wrap(ff.featureType).should('equal', 'drawnLine') // check color blue @@ -288,15 +270,10 @@ describe('Test style edition of Polygon feature', () => { .getLayers() .getArray() .filter((l: any) => l.get('cyLayerType') == 'featureLayer') - cy.log(featureLayers.length) const features = featureLayers .map((l: any) => l.getSource().getFeatures()) .flat() - cy.log(features.length) - cy.log(features.map(f => f.get('name'))) - // if the edit mode stays active, two features are created, so the length check fails - // cy.wrap(features.length).should('equal', 1) - // const ff = features.find((f: any) => f.get('name') == 'Polygone 1') + cy.wrap(features.length).should('equal', 1) const ff = features[0] cy.wrap(ff.featureType).should('equal', 'drawnPolygon') // check color blue @@ -340,15 +317,10 @@ describe('Test style edition of Circle feature', () => { .getLayers() .getArray() .filter((l: any) => l.get('cyLayerType') == 'featureLayer') - cy.log(featureLayers.length) const features = featureLayers .map((l: any) => l.getSource().getFeatures()) .flat() - cy.log(features.length) - cy.log(features.map(f => f.get('name'))) - // if the edit mode stays active, two features are created, so the length check fails - // cy.wrap(features.length).should('equal', 1) - // const ff = features.find((f: any) => f.get('name') == 'Cercle 1') + cy.wrap(features.length).should('equal', 1) const ff = features[0] cy.wrap(ff.featureType).should('equal', 'drawnCircle') // check color blue diff --git a/src/composables/draw/edit.composable.ts b/src/composables/draw/edit.composable.ts index 260ea568..58efcaed 100644 --- a/src/composables/draw/edit.composable.ts +++ b/src/composables/draw/edit.composable.ts @@ -10,7 +10,9 @@ import { DrawnFeature } from '@/services/draw/drawn-feature' import { useDrawStore } from '@/stores/draw.store' import useMap from '../map/map.composable' import { EditStateActive } from '@/stores/draw.store.model' -import { DEFAULT_DRAW_ZINDEX, FEATURE_LAYER_TYPE } from './draw.composable' + +const DEFAULT_DRAW_EDIT_ZINDEX = 1001 +const FEATURE_EDIT_LAYER_TYPE = 'featureEditLayer' export default function useEdit() { const { editStateActive, editingFeatureId, drawnFeatures } = storeToRefs( @@ -25,9 +27,9 @@ export default function useEdit() { }) const editLayer = new VectorLayer({ source: editSource, - zIndex: DEFAULT_DRAW_ZINDEX, + zIndex: DEFAULT_DRAW_EDIT_ZINDEX, }) - editLayer.set('cyLayerType', FEATURE_LAYER_TYPE) + editLayer.set('cyLayerType', FEATURE_EDIT_LAYER_TYPE) map.addLayer(editLayer) watch(editStateActive, editStateActive => {