diff --git a/cypress/e2e/draw/draw-panel.cy.ts b/cypress/e2e/draw/draw-panel.cy.ts index 82018f86..80f1c2b3 100644 --- a/cypress/e2e/draw/draw-panel.cy.ts +++ b/cypress/e2e/draw/draw-panel.cy.ts @@ -47,4 +47,29 @@ describe('Draw panel', () => { testFeatItem() }) }) + + describe('When clicking edit pencil button', () => { + beforeEach(() => { + cy.get('*[data-cy="featItemActionEdit"]').click() + }) + it('should open the edit panel', () => { + cy.get('*[data-cy="featureLabelEdit"]').should('exist') + }) + it('should update the feature label on submit', () => { + cy.get('*[data-cy="featureLabelEdit"]').clear() + cy.get('*[data-cy="featureLabelEdit"]').type('New label') + cy.get('*[data-cy="featureEditValidate"]').click() + cy.reload() + cy.get('*[data-cy="mymapsOpenClose"]').click() + cy.get('*[data-cy="featItemName"]').should('have.text', 'New label') + }) + it('should NOT update the feature label on cancel', () => { + cy.get('*[data-cy="featureLabelEdit"]').clear() + cy.get('*[data-cy="featureLabelEdit"]').type('New label') + cy.get('*[data-cy="featureEditCancel"]').click() + cy.reload() + cy.get('*[data-cy="mymapsOpenClose"]').click() + cy.get('*[data-cy="featItemName"]').should('have.text', 'Nom 1') + }) + }) }) diff --git a/src/components/draw/draw-panel-features.vue b/src/components/draw/draw-panel-features.vue index adefe4c6..960d52ca 100644 --- a/src/components/draw/draw-panel-features.vue +++ b/src/components/draw/draw-panel-features.vue @@ -50,6 +50,7 @@ onMounted(() => { @toggleDock="() => (featureEditionDocked = !featureEditionDocked)" @closePopup="() => (featureEditionDocked = false)" @clickDelete="featureId => drawStore.removeFeature(featureId)" + @submitEditInfo="feature => drawStore.updateDrawnFeature(feature)" /> diff --git a/src/components/draw/feature-edit-info.vue b/src/components/draw/feature-edit-info.vue index bef0539f..9dd8706c 100644 --- a/src/components/draw/feature-edit-info.vue +++ b/src/components/draw/feature-edit-info.vue @@ -11,6 +11,7 @@ const feature: DrawnFeature | undefined = inject('feature')