Skip to content

Commit

Permalink
further simplification of e2e test Cesium load detection
Browse files Browse the repository at this point in the history
No need to wait for the viewer to load a tile with custom code, we already do it with intercepts.
Also as removing this part now remove the viewer being returned, adding a viewer "grab" when needed
  • Loading branch information
pakb committed Nov 7, 2023
1 parent 3510b0e commit f5a58a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
9 changes: 6 additions & 3 deletions tests/e2e-cypress/integration/3d/layers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ describe('Test of layer handling in 3D', () => {
'3d': true,
layers: `${visibleLayerIds[0]},,0.5`,
})
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
const layers = viewer.scene.imageryLayers
expect(layers.get(1).alpha).to.eq(0.5)
})
Expand All @@ -78,7 +79,8 @@ describe('Test of layer handling in 3D', () => {
4
)}`,
})
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
expect(viewer.scene.imageryLayers.get(1).imageryProvider.url).to.have.string(
`1.0.0/${timeEnabledLayerId}/default/${randomTimestampFromLayer}/3857/{z}/{x}/{y}.png`
)
Expand Down Expand Up @@ -123,7 +125,8 @@ describe('Test of layer handling in 3D', () => {
'3d': true,
layers: `${visibleLayerIds[3]},,0.5`,
})
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
expect(viewer.scene.primitives.length).to.eq(
3,
'should have 1 primitive (GeoJSON) on top of labels and buildings primitives'
Expand Down
18 changes: 12 additions & 6 deletions tests/e2e-cypress/integration/3d/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('Testing 3D navigation', () => {
})
})
it('minimum distance from the terrain', () => {
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
// Move close to the ground and try to zoom closer with the mouse wheel
viewer.camera.flyTo({
destination: Cartesian3.fromDegrees(
Expand All @@ -27,15 +28,17 @@ describe('Testing 3D navigation', () => {
duration: 0.0,
})
cy.get('[data-cy="cesium-map"] .cesium-viewer').trigger('wheel', { deltaY: -5000 })
cy.waitUntilCesiumTilesLoaded().then(() => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then(() => {
expect(viewer.scene.camera.positionCartographic.height).gt(
CAMERA_MIN_ZOOM_DISTANCE
)
})
})
})
it('maximum distance from the terrain', () => {
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
// Move far from the ground and try to zoom higher with the mouse wheel
viewer.camera.flyTo({
destination: Cartesian3.fromDegrees(
Expand All @@ -46,15 +49,17 @@ describe('Testing 3D navigation', () => {
duration: 0.0,
})
cy.get('[data-cy="cesium-map"] .cesium-viewer').trigger('wheel', { deltaY: 5000 })
cy.waitUntilCesiumTilesLoaded().then(() => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then(() => {
expect(viewer.scene.camera.positionCartographic.height).lt(
CAMERA_MAX_ZOOM_DISTANCE
)
})
})
})
it('updates the position in store', () => {
cy.waitUntilCesiumTilesLoaded().then((viewer) => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then((viewer) => {
const lon = 7.451498
const lat = 46.92805
viewer.camera.flyTo({
Expand All @@ -64,7 +69,8 @@ describe('Testing 3D navigation', () => {
},
duration: 0.0,
})
cy.waitUntilCesiumTilesLoaded().then(() => {
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').then(() => {
cy.readStoreValue('getters.centerEpsg4326').should((center) => {
expect(center[0]).to.eq(lon)
expect(center[1]).to.eq(lat)
Expand Down
4 changes: 0 additions & 4 deletions tests/e2e-cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,6 @@ function cesiumTilesLoaded(viewer) {

Cypress.Commands.add('waitUntilCesiumTilesLoaded', () => {
cy.wait(['@cesiumTileset', '@cesiumTile'])
cy.readWindowValue('cesiumViewer').then(async (viewer) => {
await cesiumTilesLoaded(viewer)
return viewer
})
})

Cypress.Commands.add('clickOnMenuButtonIfMobile', () => {
Expand Down

0 comments on commit f5a58a4

Please sign in to comment.