Skip to content

Commit

Permalink
Merge pull request #641 from MTES-MCT/fix-administrative-zone-hiding
Browse files Browse the repository at this point in the history
Fix administrative zones hiding
  • Loading branch information
louptheron authored Sep 29, 2021
2 parents 756b325 + 3fbbc04 commit 8236077
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
21 changes: 19 additions & 2 deletions frontend/cypress/integration/layers_sidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ context('LayersSidebar', () => {
cy.get('*[data-cy="regulatory-layers-my-zones-zone-show"]').eq(0).click({ timeout: 20000 })
cy.wait(1000)

cy.get('canvas').eq(2).click(490, 580, { timeout: 20000, force: true })
cy.get('canvas', { timeout: 20000 }).eq(2).click(490, 580, { timeout: 20000, force: true })
cy.get('*[data-cy="regulatory-layers-metadata-seafront"]').contains('MEMN')

// Close the metadata modal and hide the zone
cy.get('*[data-cy="regulatory-layers-metadata-close"]').click()
cy.get('*[data-cy="regulatory-layers-my-zones-zone-hide"]').eq(0).click({ timeout: 20000 })

// The layer is hidden, the metadata modal should not be opened
cy.get('canvas').eq(2).click(490, 580, { timeout: 20000, force: true })
cy.get('canvas', { timeout: 20000 }).eq(2).click(490, 580, { timeout: 20000, force: true })
cy.get('*[data-cy="regulatory-layers-metadata-seafront"]', { timeout: 20000 }).should('not.exist')
})

Expand Down Expand Up @@ -118,4 +118,21 @@ context('LayersSidebar', () => {
cy.get('*[data-cy^="regulatory-layers-advanced-search-species"]').type('VEV')
cy.get('*[data-cy^="regulatory-layer-topic"]').contains('Ouest Cotentin Bivalves')
})

it('An administrative zone Should be showed and hidden', () => {
// Given
cy.get('.eez_areas', { timeout: 20000 }).should('not.exist')

// When
cy.get('*[data-cy^="layers-sidebar"]').click({ timeout: 20000 })
cy.get('*[data-cy^="administrative-zones-open"]').click({ timeout: 20000 })
cy.get('*[data-cy^="administrative-layer-toggle"]').eq(0).click({ timeout: 20000 })
cy.wait(500)

// Then
cy.get('.eez_areas', { timeout: 20000 }).should('exist')

cy.get('*[data-cy^="administrative-layer-toggle"]').eq(0).click({ timeout: 20000 })
cy.get('.eez_areas', { timeout: 20000 }).should('not.exist')
})
})
2 changes: 1 addition & 1 deletion frontend/cypress/integration/vessel_filters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ context('Vessel filters', () => {
cy.get('*[data-cy="vessel-filter-remove-tag"]').eq(0).click({ timeout: 20000 })

// We should have ~ the same number of labels than in init
cy.get('*[data-cy^="vessel-label-risk-factor"]').should('have.length.to.be.greaterThan', 18)
cy.get('*[data-cy^="vessel-label-risk-factor"]').should('have.length.to.be.greaterThan', 5)
})
})
15 changes: 15 additions & 0 deletions frontend/cypress/mappings/administrative-zone.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions frontend/src/domain/use_cases/hideLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const hideLayer = layerToHide => (dispatch, getState) => {
layersToRemove = getState().layer.layers.filter(layer => {
return layer.className_.includes(`${type}:${zone}`)
})
} else {
layerToRemove = getState().layer.layers.find(layer => layer.className_ === type)
}

if (layerToRemove) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const AdministrativeLayer = props => {
isFirst={isFirst}
isGrouped={isGrouped}
onClick={() => setShowLayer(!showLayer_)}
data-cy={'administrative-layer-toggle'}
>
<LayerName
title={layer.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const AdministrativeLayers = props => {

return (
<>
<SectionTitle onClick={onSectionTitleClicked} showZones={showZones}>
<SectionTitle
onClick={onSectionTitleClicked}
showZones={showZones}
data-cy={'administrative-zones-open'}
>
Zones administratives <ChevronIcon isOpen={showZones}/>
</SectionTitle>
<NamespaceContext.Consumer>
Expand Down

0 comments on commit 8236077

Please sign in to comment.