From 3ecde45f5c5ea28bc9a0204432359ac26b649ac6 Mon Sep 17 00:00:00 2001 From: AlitaBernachot Date: Thu, 19 Oct 2023 13:24:51 +0200 Subject: [PATCH] test: add e2e testing for attribution --- cypress/e2e/background-selection.cy.ts | 43 +++++++++++++------ cypress/e2e/map/controls.cy.ts | 9 +++- src/__fixtures__/themes.api.fixture.ts | 2 +- .../map-controls/attribution-control.vue | 1 + 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/cypress/e2e/background-selection.cy.ts b/cypress/e2e/background-selection.cy.ts index 2e692c605..bdab61c1d 100644 --- a/cypress/e2e/background-selection.cy.ts +++ b/cypress/e2e/background-selection.cy.ts @@ -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 = (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 = (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 = (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') }) }) diff --git a/cypress/e2e/map/controls.cy.ts b/cypress/e2e/map/controls.cy.ts index 886bf04be..2a52745b7 100644 --- a/cypress/e2e/map/controls.cy.ts +++ b/cypress/e2e/map/controls.cy.ts @@ -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 diff --git a/src/__fixtures__/themes.api.fixture.ts b/src/__fixtures__/themes.api.fixture.ts index 45909fc7d..1f95cb54c 100644 --- a/src/__fixtures__/themes.api.fixture.ts +++ b/src/__fixtures__/themes.api.fixture.ts @@ -38617,7 +38617,7 @@ export const themesApiFixture = (): ConfigModel => ({ id: 502, name: 'topo_bw_jpeg', metadata: { - attribution: "© MapTiler © OpenStreetMap contributors for data outside of Luxembourg", + attribution: "© B&W custom attribution for test only", exclusion: "[35, 45]", legend_name: "act_topovt_bw", metadata_id: "b786acc2-b87e-4c7a-aff7-52778357243b" diff --git a/src/components/map-controls/attribution-control.vue b/src/components/map-controls/attribution-control.vue index f26c11ab7..24c14fd5b 100644 --- a/src/components/map-controls/attribution-control.vue +++ b/src/components/map-controls/attribution-control.vue @@ -12,6 +12,7 @@ watchEffect(() => {