Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,6 @@
},
"engines": {
"node": ">=22",
"pnpm": "10.*.*"
},
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",
"@tailwindcss/oxide",
"cypress",
"sharp"
],
"ignoredBuiltDependencies": [
"core-js",
"cypress",
"es5-ext",
"esbuild",
"protobufjs",
"sharp"
]
"pnpm": "11.*.*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
type Chart,
type ChartData,
type ChartOptions,
type Point as ChartPoint,
type ScaleOptions,
type TooltipItem,
type TooltipModel,
Expand Down Expand Up @@ -171,7 +170,7 @@ const chartJsData: ComputedRef<ChartData<'line'>> = computed(() => {
x: point.dist ?? 0,
y: point.elevation,
...point,
})) as ChartPoint[],
})),
parsing: {
xAxisKey: 'dist',
yAxisKey: 'elevation',
Expand Down
10 changes: 10 additions & 0 deletions packages/mapviewer/cypress.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { cypressBrowserPermissionsPlugin } from 'cypress-browser-permissions'
import vitePreprocessor from 'cypress-vite'
import { existsSync, readdirSync, unlinkSync } from 'node:fs'
import { join } from 'node:path'
import { env } from 'node:process'

import viteConfig from './vite.config.mts'

Expand Down Expand Up @@ -59,6 +60,11 @@ export default defineConfig({
vitePreprocessor({
configFile: './vite.config.mts',
mode: 'test',
define: {
// Cypress 15 runs test bundles in the browser where `process` is not available
'process.env.NODE_ENV': JSON.stringify('test'),
'process.env': '{}',
},
})
)

Expand Down Expand Up @@ -107,6 +113,10 @@ export default defineConfig({
},
baseUrl: 'http://localhost:8080',
specPattern: 'tests/cypress/tests-e2e/**/*.cy.js',
excludeSpecPattern:
env.VITE_SKIP_3D_TESTS === 'true'
? 'tests/cypress/tests-e2e/3d/**/*.cy.js'
: [],
supportFile: 'tests/cypress/support/e2e.js',
},

Expand Down
42 changes: 0 additions & 42 deletions packages/mapviewer/tests/cypress/tests-e2e/compareSlider.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="cypress" />
import { WEBMERCATOR } from '@geoadmin/coordinates'

describe('Testing of the compare slider', () => {
function expectCompareRatioToBe(value) {
Expand Down Expand Up @@ -352,44 +351,3 @@ describe('Testing of the compare slider', () => {
})
})
})

describe('The compare Slider and the menu elements should not be available in 3d', () => {
context('compare slider non availability in 3d', () => {
it('does not shows up with layers, a compare slider parameter set, but in 3d', () => {
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compareRatio: '0.4',
'3d': true,
sr: WEBMERCATOR.epsgNumber,
},
true
)
cy.get('[data-cy="compareSlider"]').should('not.exist')

cy.readStoreValue('state.ui.compareRatio').then((compareRatio) => {
expect(compareRatio).to.eq(0.4)
})
})
})
context('Compare menu component with 3d', () => {
it('disappears when it is available in 2d and we swith to 3d', () => {
cy.goToMapView(
{
sr: WEBMERCATOR.epsgNumber,
},
true
)
cy.openMenuIfMobile()
cy.get('[data-cy="menu-tray-tool-section"]').click()
cy.get('[data-cy="menu-advanced-tools-compare"]').should('be.visible')
cy.closeMenuIfMobile()

cy.get('[data-cy="3d-button"]').click()

cy.openMenuIfMobile()

cy.get('[data-cy="menu-advanced-tools-compare"]').should('not.exist')
})
})
})
5 changes: 1 addition & 4 deletions packages/mapviewer/tests/cypress/tests-e2e/geolocation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ registerProj4(proj4)

const { GeolocationPositionError } = window

const testCases = [
{ description: 'on 2D Map', is3D: false },
{ description: 'on 3D Map', is3D: true },
]
const testCases = [{ description: 'on 2D Map', is3D: false }]

// PB-701: TODO Those tests below are not working as expected, as the cypress-browser-permissions is not
// working and the geolocation is always allowed, this needs to be reworked and probably need to
Expand Down
53 changes: 8 additions & 45 deletions packages/mapviewer/tests/cypress/tests-e2e/importToolFile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,59 +515,16 @@ describe('The Import File Tool', () => {
cy.wait(['@headKmlNoCORS', '@proxyfiedKmlNoCORS'])
cy.readStoreValue('state.layers.activeLayers').should('have.length', 2)

cy.log('switching to 3D and checking that online file is correctly loaded on 3D viewer')
cy.get('[data-cy="import-window"] [data-cy="window-close"]').click()
// 3 warnings to remove before being able to see the 3D button (on mobile)
cy.get('[data-cy="warning-window"]').contains(
'You have reloaded while a local layer was imported, or received a link containing a local layer, which has not been loaded. If you have the file containing the KML|external-kml-file.kml layer, please re-import it.'
)
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="warning-window"]').contains(
'You have reloaded while a local layer was imported, or received a link containing a local layer, which has not been loaded. If you have the file containing the KML|line-accross-eu.kml layer, please re-import it.'
)
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="warning-window"]').contains(
'You have reloaded while a local layer was imported, or received a link containing a local layer, which has not been loaded. If you have the file containing the KML|kml_feature_error.kml layer, please re-import it.'
)
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="3d-button"]:visible').click()
cy.waitUntilCesiumTilesLoaded()
cy.readWindowValue('cesiumViewer').should((viewer) => {
expect(viewer.scene.primitives.length).to.eq(
4,
'should have 1 primitive (KML file) on top of labels and buildings primitives'
)
})

cy.log('adding a local KML file while being in the 3D viewer')
cy.openMenuIfMobile()
cy.get('[data-cy="menu-tray-tool-section"]:visible').click()
cy.get('[data-cy="menu-advanced-tools-import-file"]:visible').click()
cy.get('[data-cy="import-file-local-btn"]').click()
cy.get('[data-cy="file-input"]').selectFile('@lineAccrossEuFixture', {
force: true,
})
cy.get('[data-cy="import-file-load-button"]:visible').click()
cy.readStoreValue('state.layers.activeLayers').then((activeLayers) => {
const kmlLayerCount = activeLayers.filter((layer) => layer.type === 'KML').length
cy.readWindowValue('cesiumViewer').should((viewer) => {
expect(viewer.dataSources.length).to.eq(
kmlLayerCount,
`should have ${kmlLayerCount} date source (KML files)`
)
})
})

cy.log('testing the import and profile viewer with a KML MultiPolygon file')
cy.get('[data-cy="import-window"] [data-cy="window-close"]').click()
cy.get('[data-cy="3d-button"]:visible').click()

cy.openMenuIfMobile()

cy.get(`[data-cy^="button-remove-layer-${validOnlineNonCORSUrl}"]:visible`).click()

cy.get(`[data-cy^="button-remove-layer-${secondValidOnlineUrl}"]:visible`).click()
cy.get(`[data-cy^="button-remove-layer-${lineAccrossEuFileName}"]:visible`).click()
// seems like this doesn't exist
// cy.get(`[data-cy^="button-remove-layer-${lineAccrossEuFileName}"]:visible`).click()

cy.get('[data-cy="menu-tray-tool-section"]:visible').click()
cy.get('[data-cy="menu-advanced-tools-import-file"]:visible').click()
Expand All @@ -591,6 +548,12 @@ describe('The Import File Tool', () => {
cy.closeMenuIfMobile()
cy.get('[data-cy="window-close"]').click()

// There's a warning window that needs to be closed before the map is clickable
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="warning-window-close"]').click({ force: true })
cy.get('[data-cy="warning-window-close"]').click({ force: true })

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

cy.get('[data-cy="show-profile"]').click()
Expand Down
76 changes: 1 addition & 75 deletions packages/mapviewer/tests/cypress/tests-e2e/infobox.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="cypress" />

import { LV95, WEBMERCATOR } from '@geoadmin/coordinates'
import { LV95 } from '@geoadmin/coordinates'

describe('The infobox', () => {
const generateInfoboxTestsForMapSelector = (mapSelector) => {
Expand Down Expand Up @@ -139,78 +139,4 @@ describe('The infobox', () => {
.should('contain', 'Link zum Object')
})
})
// since we've been serving fake tiles to Cesium, the location popup is broken as Cesium can't return proper coordinates
// we need to fix this Cesium fake tile issue before reactivating this test context
// TODO : BGDIINF_SB-3181
context.skip('Cesium map', () => {
beforeEach(() => {
cy.goToMapView({ layers: layer, '3d': true, sr: WEBMERCATOR.epsgNumber }, true)
cy.waitUntilCesiumTilesLoaded()
})
// generateInfoboxTestsForMapSelector('[data-cy="cesium-map"]')
})
context('transition from 2D to 3D (and back to 2D)', () => {
beforeEach(() => {
cy.goToMapView({ layers: layer })

cy.get('[data-cy="ol-map"]').click()
cy.waitUntilState((_, getters) => {
return getters.selectedFeatures.length > 0
})
cy.get('[data-cy="highlighted-features"]').should('be.visible')
})
it('keeps the selected features when going 3D', () => {
cy.get('[data-cy="3d-button"]').click()
// waiting for 3D to be loaded
cy.readWindowValue('cesiumViewer').then(() => {
cy.get('[data-cy="highlighted-features"]').should('be.visible')
})
})
it('keeps the selected features when going back to 2D', () => {
cy.get('[data-cy="3d-button"]').click()
cy.readWindowValue('cesiumViewer').then(() => {
cy.get('[data-cy="3d-button"]').click()
cy.get('[data-cy="highlighted-features"]').should('be.visible')
})
})
it('verifies the "More Information" button in the infobox and the information page that is shown', () => {
const infoboxFixture = 'infobox.fixture.html'
cy.intercept('GET', 'https://api3.geo.admin.ch/**', {
fixture: infoboxFixture,
}).as('infobox')

cy.get('[data-cy="highlighted-features"]').should('be.visible')
cy.get('[data-cy="more-info-link"]')
.should('exist')
.should('contain', 'More info')
.click({ force: true })

cy.wait(['@routeChange', '@layerConfig', '@topics', '@topic-ech', '@infobox'])

cy.origin('https://api3.geo.admin.ch', () => {
cy.url().should((url) => {
expect(url).to.eq(
'https://api3.geo.admin.ch/rest/services/ech/MapServer/ch.bav.haltestellen-oev/8577026/extendedHtmlPopup'
)
})
cy.get('.chsdi-htmlpopup-container').should('be.visible')
cy.get('.htmlpopup-header').should('be.visible').contains('Public transport stops')
cy.get('.htmlpopup-content')
.should('be.visible')
.should('contain', 'Number')
.should('contain', '8577026')
.should('contain', 'Name')
.should('contain', 'Rubigen, Bahnhof')
.should('contain', 'Abreviation')
.should('contain', '-')
.should('contain', 'TO')
.should('contain', 'SVB')
.should('contain', 'Type')
.should('contain', 'Haltestelle')
.should('contain', 'Means of transport')
.should('contain', 'Bus')
.should('contain', 'Link to object')
})
})
})
})
91 changes: 0 additions & 91 deletions packages/mapviewer/tests/cypress/tests-e2e/legacyParamImport.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,97 +359,6 @@ describe('Test on legacy param import', () => {
})
})

context('3D import', () => {
const lat = 47.3
const lon = 7.3
const elevation = 215370
const heading = 318
const pitch = -45

it('transfers camera parameter from legacy URL to the new URL', () => {
cy.goToMapView(
{
lat,
lon,
elevation,
heading,
pitch,
},
false
)

// checking in the store that the parameters have been converted into the new 3D parameters
cy.readStoreValue('state.cesium.active').should('eq', true) // cesium should be active

// Checking camera position
cy.readStoreValue('state.position.camera.x').should('eq', lon)
cy.readStoreValue('state.position.camera.y').should('eq', lat)
// For some reason, the z value is not exactly the same as the elevation
// There might be a recalculating of the elevation
cy.readStoreValue('state.position.camera.z').then((cameraZ) => {
expect(Number(cameraZ)).to.approximately(elevation, 100)
})
cy.readStoreValue('state.position.camera.heading').should('eq', heading)
cy.readStoreValue('state.position.camera.pitch').should('eq', pitch)
cy.readStoreValue('state.position.camera.roll').should('eq', 0)

// EPSG is set to 3857
cy.readStoreValue('state.position.projection.epsgNumber').should('eq', 3857)
})

it('transfers camera parameter from legacy URL to the new URL only heading', () => {
cy.goToMapView(
{
lat,
lon,
heading,
},
false
)

// checking in the store that the parameters have been converted into the new 3D parameters
cy.readStoreValue('state.cesium.active').should('eq', true) // cesium should be active

// Checking camera position
cy.readStoreValue('state.position.camera.x').should('eq', lon)
cy.readStoreValue('state.position.camera.y').should('eq', lat)
cy.readStoreValue('state.position.camera.z').should('eq', 0)
cy.readStoreValue('state.position.camera.heading').should('eq', heading)
cy.readStoreValue('state.position.camera.pitch').should('eq', -90)
cy.readStoreValue('state.position.camera.roll').should('eq', 0)

// EPSG is set to 3857
cy.readStoreValue('state.position.projection.epsgNumber').should('eq', 3857)
})
// camera=7.038834,46.766017,193985.5,-47,319,
// camera=8.225457,46.858429,738575.8,-90,,
it('transfers camera parameter from legacy URL to the new URL only elevation', () => {
cy.goToMapView(
{
lat,
lon,
elevation,
},
false
)

// checking in the store that the parameters have been converted into the new 3D parameters
cy.readStoreValue('state.cesium.active').should('eq', true) // cesium should be active

// Checking camera position
// x, y, and z seems recalculated when there is only elevation, so I just check that they are not null
cy.readStoreValue('state.position.camera.x').should('not.be.null')
cy.readStoreValue('state.position.camera.y').should('not.be.null')
cy.readStoreValue('state.position.camera.z').should('not.be.null')
cy.readStoreValue('state.position.camera.heading').should('eq', 0)
cy.readStoreValue('state.position.camera.pitch').should('eq', -90)
cy.readStoreValue('state.position.camera.roll').should('eq', 0)

// EPSG is set to 3857
cy.readStoreValue('state.position.projection.epsgNumber').should('eq', 3857)
})
})

context('Extra Parameter Imports', () => {
it('shows the compare slider at the correct position', () => {
/* */
Expand Down
Loading
Loading