Skip to content

Commit

Permalink
test: add e2e testing for attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Oct 19, 2023
1 parent 94d1523 commit 3ecde45
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
43 changes: 31 additions & 12 deletions cypress/e2e/background-selection.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,44 @@ describe('Background selector', () => {
cy.get('[data-cy="available-bgs"]').find('button').should('not.be.hidden')
})

it('updates the layer manager and the map when selecting a background layer', () => {
it('has the default background layer on the map', () => {
cy.window().then(window => {
const layers = (<AUTWindowOlMap>window).olMap.getLayers().getArray()
expect(layers[0].get('id')).to.eq(556)
})

cy.get('[data-cy="selectedBg"]').find('button').click()
cy.get('[data-cy="available-bgs"]')
.find('button')
.filter('[title*="topo_bw"]')
.click()
cy.get('.lux-layer-manager-item')
.last()
.contains('Carte topographique N/B')
cy.get('[data-cy="attributionControl"]')
.should('be.visible')
.contains(
'© MapTiler © OpenStreetMap contributors for data outside of Luxembourg'
)
})

cy.window().then(window => {
const layers = (<AUTWindowOlMap>window).olMap.getLayers().getArray()
expect(layers[0].get('id')).to.eq(502)
describe('When selecting a other background layer', () => {
beforeEach(() => {
cy.get('[data-cy="selectedBg"]').find('button').click()
cy.get('[data-cy="available-bgs"]')
.find('button')
.filter('[title*="topo_bw"]')
.click()
})

it('updates the layer manager and the map when selecting a background layer', () => {
cy.get('.lux-layer-manager-item')
.last()
.contains('Carte topographique N/B')
.should('be.visible')

cy.window().then(window => {
const layers = (<AUTWindowOlMap>window).olMap.getLayers().getArray()
expect(layers[0].get('id')).to.eq(502)
})
})

it('updates the attribution content', () => {
cy.get('[data-cy="attributionControl"]')
.should('be.visible')
.contains('© B&W custom attribution for test only')
})
})

Expand Down
9 changes: 8 additions & 1 deletion cypress/e2e/map/controls.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ describe('Map controls', () => {
cy.get('[data-cy="mapContainer"] .ol-full-screen')
})

// TODO: test attribution control
it('displays the attribution text', () => {
cy.get('[data-cy="attributionControl"]')
.should('be.visible')
.contains(
'© MapTiler © OpenStreetMap contributors for data outside of Luxembourg'
)
})

// TODO: test Location control
// TODO: test 3D control
// TODO: test info bar control
Expand Down
2 changes: 1 addition & 1 deletion src/__fixtures__/themes.api.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38617,7 +38617,7 @@ export const themesApiFixture = (): ConfigModel => ({
id: 502,
name: 'topo_bw_jpeg',
metadata: {
attribution: "&copy; <a href='https://www.maptiler.com/copyright/'>MapTiler</a> &copy; <a href=\"https://openstreetmap.org/copyright\">OpenStreetMap</a> contributors for data outside of Luxembourg",
attribution: "&copy; B&W custom attribution for test only",
exclusion: "[35, 45]",
legend_name: "act_topovt_bw",
metadata_id: "b786acc2-b87e-4c7a-aff7-52778357243b"
Expand Down
1 change: 1 addition & 0 deletions src/components/map-controls/attribution-control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ watchEffect(() => {

<template>
<div
data-cy="attributionControl"
class="absolute bottom-0 z-10 text-[0.8em] px-[4px] text-[#6b818f] bg-[#ffffffb3]"
v-if="attribution"
v-dompurify-html="attribution"
Expand Down

0 comments on commit 3ecde45

Please sign in to comment.