Skip to content

Commit b3f956d

Browse files
committed
PB-2068: Fix missing import on 3D geolocation test.
1 parent 8d3f487 commit b3f956d

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

packages/viewer/tests/cypress/tests-e2e/3d/geolocation.cy.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import proj4 from 'proj4'
66
import {
77
getGeolocationButtonAndClickIt,
88
testErrorMessage,
9-
checkStorePosition,
9+
checkPosition,
1010
} from '@/../tests/cypress/tests-e2e/utils'
11+
import useGeolocationStore from '@/store/modules/geolocation'
1112
import usePositionStore from '@/store/modules/position'
1213

1314
registerProj4(proj4)
@@ -62,12 +63,17 @@ describe('Geolocation on 3D cypress', () => {
6263
expect(camera?.pitch).to.eq(-90)
6364
expect(camera?.roll).to.eq(0)
6465
})
65-
6666
getGeolocationButtonAndClickIt()
67-
// check that the geolocation has been set in the store
68-
checkStorePosition('state.geolocation.position', geoX, geoY)
69-
// check that the map has been centered on the geolocation
70-
checkStorePosition('state.position.center', geoX, geoY)
67+
68+
cy.getPinia().then((pinia) => {
69+
const positionStore = usePositionStore(pinia)
70+
const geolocationStore = useGeolocationStore(pinia)
71+
// check that the geolocation has been set in the store
72+
checkPosition(geolocationStore.position, geoX, geoY)
73+
// check that the map has been centered on the geolocation
74+
checkPosition(positionStore.center, geoX, geoY)
75+
})
76+
7177
// Camera position after geolocation
7278
cy.getPinia().then((pinia) => {
7379
const positionStore2 = usePositionStore(pinia)

packages/viewer/tests/cypress/tests-e2e/geolocation.cy.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import proj4 from 'proj4'
66
import {
77
getGeolocationButtonAndClickIt,
88
testErrorMessage,
9+
checkPosition,
910
} from '@/../tests/cypress/tests-e2e/utils'
1011
import { DEFAULT_PROJECTION } from '@/config/map.config'
1112
import useGeolocationStore from '@/store/modules/geolocation'
@@ -25,17 +26,6 @@ const testCases: TestCase[] = [
2526
{ description: 'on 3D Map', is3D: true },
2627
]
2728

28-
function checkPosition(
29-
position: SingleCoordinate | undefined,
30-
expectedX: number,
31-
expectedY: number
32-
) {
33-
expect(position).to.be.an('Array')
34-
expect(position!.length).to.eq(2)
35-
expect(position![0]).to.approximately(expectedX, 0.1)
36-
expect(position![1]).to.approximately(expectedY, 0.1)
37-
}
38-
3929
// PB-701: TODO Those tests below are not working as expected, as the cypress-browser-permissions is not
4030
// working and the geolocation is always allowed, this needs to be reworked and probably need to
4131
// use another plugin.

packages/viewer/tests/cypress/tests-e2e/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference types="cypress" />
22

3+
import type { SingleCoordinate } from '@swissgeo/coordinates'
4+
35
import useUIStore from '@/store/modules/ui'
46

57
export function moveTimeSlider(x: number) {
@@ -37,3 +39,14 @@ export function testErrorMessage(message: string) {
3739
cy.get('[data-cy="error-window"]').should('be.visible')
3840
cy.get('[data-cy="error-window-close"]').should('be.visible').click() // close the error window
3941
}
42+
43+
export function checkPosition(
44+
position: SingleCoordinate | undefined,
45+
expectedX: number,
46+
expectedY: number
47+
) {
48+
expect(position).to.be.an('Array')
49+
expect(position!.length).to.eq(2)
50+
expect(position![0]).to.approximately(expectedX, 0.1)
51+
expect(position![1]).to.approximately(expectedY, 0.1)
52+
}

0 commit comments

Comments
 (0)