Skip to content

Commit

Permalink
Merge pull request #525 from geoadmin/feat-BGDIINF_SB-3187-e2e-tests-…
Browse files Browse the repository at this point in the history
…layers

BGDIINF_SB-3187: Improved layers.api cypress tests
  • Loading branch information
ltshb authored Nov 15, 2023
2 parents 561c493 + ec44e0f commit f18de91
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 34 deletions.
76 changes: 76 additions & 0 deletions tests/e2e-cypress/fixtures/layers.fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,82 @@
"type": "wms",
"serverLayerName": "test.wms.layer"
},
"test-1.wms.layer": {
"opacity": 0.75,
"wmsLayers": "test-1.wms.layer",
"attribution": "attribution.test-1.wms.layer",
"background": false,
"searchable": false,
"format": "png",
"topics": "ech,test-topic-standard",
"wmsUrl": "https://wms.geo.admin.ch",
"tooltip": true,
"timeEnabled": false,
"singleTile": false,
"highlightable": true,
"chargeable": false,
"hasLegend": true,
"label": "WMS test layer 1",
"type": "wms",
"serverLayerName": "test-1.wms.layer"
},
"test-2.wms.layer": {
"opacity": 0.75,
"wmsLayers": "test-2.wms.layer",
"attribution": "attribution.test-2.wms.layer",
"background": false,
"searchable": false,
"format": "png",
"topics": "ech,test-topic-standard",
"wmsUrl": "https://wms.geo.admin.ch",
"tooltip": true,
"timeEnabled": false,
"singleTile": false,
"highlightable": true,
"chargeable": false,
"hasLegend": true,
"label": "WMS test layer 2",
"type": "wms",
"serverLayerName": "test-2.wms.layer"
},
"test-3.wms.layer": {
"opacity": 0.75,
"wmsLayers": "test-3.wms.layer",
"attribution": "attribution.test-3.wms.layer",
"background": false,
"searchable": false,
"format": "png",
"topics": "ech,test-topic-standard",
"wmsUrl": "https://wms.geo.admin.ch",
"tooltip": true,
"timeEnabled": false,
"singleTile": false,
"highlightable": true,
"chargeable": false,
"hasLegend": true,
"label": "WMS test layer 3",
"type": "wms",
"serverLayerName": "test-3.wms.layer"
},
"test-4.wms.layer": {
"opacity": 0.75,
"wmsLayers": "test-4.wms.layer",
"attribution": "attribution.test-4.wms.layer",
"background": false,
"searchable": false,
"format": "png",
"topics": "ech,test-topic-standard",
"wmsUrl": "https://wms.geo.admin.ch",
"tooltip": true,
"timeEnabled": false,
"singleTile": false,
"highlightable": true,
"chargeable": false,
"hasLegend": true,
"label": "WMS test layer 4",
"type": "wms",
"serverLayerName": "test-4.wms.layer"
},
"test.wmts.layer": {
"opacity": 1.0,
"attribution": "attribution.test.wmts.layer",
Expand Down
55 changes: 21 additions & 34 deletions tests/e2e-cypress/integration/layers.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,32 @@ describe('Test of layer handling', () => {
cy.goToMapView()
cy.readStoreValue('getters.visibleLayers').should('be.empty')
})
it('adds a layer to the map when the app is opened through a URL with a layer in it', () => {
it.only('adds a layers with config to the map when opening the app layers URL param', () => {
cy.goToMapView({
layers: 'test.wms.layer;test.wmts.layer',
layers: [
'test-1.wms.layer',
'test-2.wms.layer,,',
'test-3.wms.layer,f',
'test-4.wms.layer,,0.4',
'test.wmts.layer,f,0.5',
].join(';'),
})
cy.readStoreValue('getters.visibleLayers').then((layers) => {
expect(layers).to.be.an('Array')
expect(layers.length).to.eq(2)
expect(layers[0]).to.be.an('Object')
expect(layers[0].getID()).to.eq('test.wms.layer')
expect(layers[1]).to.be.an('Object')
expect(layers[1].getID()).to.eq('test.wmts.layer')
})
})
it('adds a layer to active layers without showing it if the URL sets visibility to false', () => {
cy.goToMapView({
layers: 'test.wms.layer,f;test.wmts.layer',
})
cy.readStoreValue('getters.visibleLayers').then((layers) => {
expect(layers).to.be.an('Array').length(1)
const [wmtsLayer] = layers
expect(wmtsLayer).to.be.an('Object')
expect(wmtsLayer.getID()).to.eq('test.wmts.layer')
expect(layers).to.be.an('Array').length(3)
expect(layers[0].getID()).to.eq('test-1.wms.layer')
expect(layers[1].getID()).to.eq('test-2.wms.layer')
expect(layers[2].getID()).to.eq('test-4.wms.layer')
expect(layers[2].opacity).to.eq(0.4)
})
cy.readStoreValue('state.layers.activeLayers').then((layers) => {
expect(layers).to.be.an('Array').length(2)
const [wmsLayer, wmtsLayer] = layers
expect(wmsLayer).to.be.an('Object')
expect(wmsLayer.getID()).to.eq('test.wms.layer')
expect(wmtsLayer).to.be.an('Object')
expect(wmtsLayer.getID()).to.eq('test.wmts.layer')
})
})
it('sets the opacity to the value defined in the layers URL param', () => {
cy.goToMapView({
layers: 'test.wmts.layer,,0.5',
})
cy.readStoreValue('getters.visibleLayers').then((layers) => {
const [wmtsLayer] = layers
expect(wmtsLayer.opacity).to.eq(0.5)
expect(layers).to.be.an('Array').length(5)
expect(layers[0].getID()).to.eq('test-1.wms.layer')
expect(layers[1].getID()).to.eq('test-2.wms.layer')
expect(layers[2].getID()).to.eq('test-3.wms.layer')
expect(layers[3].getID()).to.eq('test-4.wms.layer')
expect(layers[3].opacity).to.eq(0.4)
expect(layers[4].getID()).to.eq('test.wmts.layer')
expect(layers[4].opacity).to.eq(0.5)
})
})
it('uses the default timestamp of a time enabled layer when not specified in the URL', () => {
Expand Down

0 comments on commit f18de91

Please sign in to comment.