Skip to content

Commit

Permalink
rename feature edit layer for better distinction in tests + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Oct 31, 2024
1 parent eb04ee8 commit 5d2f860
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
42 changes: 7 additions & 35 deletions cypress/e2e/draw/draw-feat-style.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/composables/draw/edit.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 => {
Expand Down

0 comments on commit 5d2f860

Please sign in to comment.