Skip to content

Commit

Permalink
PB-792: Update cypress tests to check for area info formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJoss committed Jul 16, 2024
1 parent 82e91fc commit 080cd0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/modules/infobox/components/FeatureAreaInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useStore } from 'vuex'
import { useTippyTooltip } from '@/utils/composables/useTippyTooltip'
import { WGS84 } from '@/utils/coordinates/coordinateSystems'
import { reprojectGeoJsonData, transformIntoTurfEquivalent } from '@/utils/geoJsonUtils'
import { round } from '@/utils/numberUtils'
const props = defineProps({
geometry: {
Expand Down Expand Up @@ -40,10 +39,10 @@ const humanReadableArea = computed(() => {
const value = calculatedArea < unitThreshold ? calculatedArea : calculatedArea / divider
result += parseFloat(value.toPrecision(precision))
if (calculatedArea >= unitThreshold) {
result += ' km'
} else {
if (calculatedArea < unitThreshold) {
result += ' m'
} else {
result += ' km'
}
}
return result
Expand Down
32 changes: 29 additions & 3 deletions tests/cypress/tests-e2e/drawing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,6 @@ describe('Drawing module tests', () => {
const [polygonCoordinates] = polygon.getGeometry().getCoordinates()
expect(polygonCoordinates).to.be.an('Array').lengthOf(4)
})
cy.get('[data-cy="feature-area-information"]')
.should('be.visible')
.contains('187.224 km')

// Changing the color of the polygon and checking that the KMl was updated accordingly
cy.get('[data-cy="drawing-style-line-button"]').click()
Expand Down Expand Up @@ -628,6 +625,35 @@ describe('Drawing module tests', () => {
const line = features[1]
expect(line.getGeometry().getCoordinates().length).to.eq(2)
})

cy.goToMapView(
{
zoom: 6,
},
false
)

cy.log('Feature Area Info should be in meters below unit threshold')
cy.goToDrawing()
cy.clickDrawingTool(EditableFeatureTypes.LINEPOLYGON)

cy.get('[data-cy="ol-map"]').click(100, 200)
cy.get('[data-cy="ol-map"]').click(150, 200)
cy.get('[data-cy="ol-map"]').click(150, 230)
cy.get('[data-cy="ol-map"]').click(100, 200)
cy.get('[data-cy="feature-area-information"]').should('be.visible').contains('74802 m2')

cy.log('Feature Area Info should be in kilometers above unit threshold')
cy.clickDrawingTool(EditableFeatureTypes.LINEPOLYGON)

cy.get('[data-cy="ol-map"]').click(200, 200)
cy.get('[data-cy="ol-map"]').click(150, 200)
cy.get('[data-cy="ol-map"]').click(150, 300)
cy.get('[data-cy="ol-map"]').click(200, 200)

cy.get('[data-cy="feature-area-information"]')
.should('be.visible')
.contains('0.24935 km2')
})
})
context('KML management', () => {
Expand Down

0 comments on commit 080cd0b

Please sign in to comment.