Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PB-1254: fix embed preview in chrome #1159

Merged
merged 2 commits into from
Dec 6, 2024
Merged
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
41 changes: 22 additions & 19 deletions src/router/storeSync/storeSync.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ const storeSyncConfig = [
valueType: Boolean,
defaultValue: false,
}),
new SimpleUrlParamConfig({
urlParamName: 'topic',
mutationsToWatch: ['changeTopic'],
dispatchName: 'changeTopic',
dispatchValueName: 'topicId',
extractValueFromStore: (store) => store.state.topics.current,
keepInUrlWhenDefault: true,
valueType: String,
defaultValue: null,
validateUrlInput: (store, query) =>
getStandardValidationResponse(
query,
store.state.topics.config.map((topic) => topic.id).includes(query),
'topic'
),
}),
new CrossHairParamConfig(),
new CompareSliderParamConfig(),
new LayerParamConfig(),
// For now, bgLayer must be after layers, as it could cause an issue where it would reload the application
// without the layers when previewing the embed view to be shared, causing those layers to disappear from the
// link sharing.
new SimpleUrlParamConfig({
urlParamName: 'bgLayer',
mutationsToWatch: ['setBackground'],
Expand All @@ -111,25 +133,6 @@ const storeSyncConfig = [
'bgLayer'
),
}),
new SimpleUrlParamConfig({
urlParamName: 'topic',
mutationsToWatch: ['changeTopic'],
dispatchName: 'changeTopic',
dispatchValueName: 'topicId',
extractValueFromStore: (store) => store.state.topics.current,
keepInUrlWhenDefault: true,
valueType: String,
defaultValue: null,
validateUrlInput: (store, query) =>
getStandardValidationResponse(
query,
store.state.topics.config.map((topic) => topic.id).includes(query),
'topic'
),
}),
new CrossHairParamConfig(),
new CompareSliderParamConfig(),
new LayerParamConfig(),
new SimpleUrlParamConfig({
urlParamName: 'featureInfo',
mutationsToWatch: ['setFeatureInfoPosition'],
Expand Down
56 changes: 35 additions & 21 deletions tests/cypress/tests-e2e/embed.cy.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you change all your invoke(...).then(...) into invoke(...).should(...) ? This would add retry-ability to all your tests (and should make them a bit more resilient on the CI)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/// <reference types="cypress" />

describe('Testing the embed view', () => {
function checkUrlParams(urlToCheck, validationUrl) {
const href = new URLSearchParams(urlToCheck.replace('#map', ''))
const validation = new URLSearchParams(validationUrl.replace('#map', ''))
for (const key of validation.keys()) {
expect(validation.get(key)).to.equal(href.get(key))
}
}
it('Open in embed mode and can jump to the non embed mode', () => {
cy.goToEmbedView()

Expand Down Expand Up @@ -29,13 +36,14 @@ describe('Testing the embed view', () => {
cy.log(`Check the link url`)
cy.get('[data-cy="open-full-app-link"]').should('be.visible').should('contain', 'View on ')
cy.get('[data-cy="open-full-app-link-anchor"]', { timeout: 20000 })
.should(
'have.attr',
'href',
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=`
)
.should('have.attr', 'target', '_blank')

.invoke('attr', 'href')
.should((href) =>
checkUrlParams(
href,
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=`
)
)
cy.log('Test mouse zoom scrolling')
cy.location('hash').should('contain', 'z=1')
cy.get('[data-cy="scaleline"]').should('contain', '50 km')
Expand Down Expand Up @@ -84,12 +92,14 @@ describe('Testing the embed view', () => {
cy.log(`Check the link url`)
cy.get('[data-cy="open-full-app-link"]').should('be.visible').should('contain', 'View on ')
cy.get('[data-cy="open-full-app-link-anchor"]')
.should(
'have.attr',
'href',
`#/map?layers=test-1.wms.layer;test.wmts.layer,,0.5;test-2.wms.layer,f;test.timeenabled.wmts.layer&lang=en&center=2660000,1190000&z=1.667&bgLayer=test.background.layer2&topic=ech`
)
.should('have.attr', 'target', '_blank')
.invoke('attr', 'href')
.should((href) =>
checkUrlParams(
href,
`#/map?layers=test-1.wms.layer;test.wmts.layer,,0.5;test-2.wms.layer,f;test.timeenabled.wmts.layer&lang=en&center=2660000,1190000&z=1.667&bgLayer=test.background.layer2&topic=ech`
)
)
})
it('Open in legacy embed mode and can jump to the non embed mode', () => {
cy.log(`Open in legacy mode without parameters`)
Expand Down Expand Up @@ -120,12 +130,14 @@ describe('Testing the embed view', () => {
cy.log(`Check the link url`)
cy.get('[data-cy="open-full-app-link"]').should('be.visible').should('contain', 'View on ')
cy.get('[data-cy="open-full-app-link-anchor"]')
.should(
'have.attr',
'href',
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=`
)
.should('have.attr', 'target', '_blank')
.invoke('attr', 'href')
.should((href) =>
checkUrlParams(
href,
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=`
)
)

cy.log('Test mouse zoom scrolling')
cy.location('hash').should('contain', 'z=1')
Expand Down Expand Up @@ -181,11 +193,13 @@ describe('Testing the embed view', () => {
cy.log(`Check the link url`)
cy.get('[data-cy="open-full-app-link"]').should('be.visible').should('contain', 'View on ')
cy.get('[data-cy="open-full-app-link-anchor"]')
.should(
'have.attr',
'href',
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=test-1.wms.layer;test.wmts.layer,,0.5;test-2.wms.layer,f,1;test.timeenabled.wmts.layer@year=2016,,1`
)
.should('have.attr', 'target', '_blank')
.invoke('attr', 'href')
.should((href) =>
checkUrlParams(
href,
`#/map?lang=en&center=2660000,1190000&z=1&bgLayer=test.background.layer2&topic=ech&layers=test-1.wms.layer;test.wmts.layer,,0.5;test-2.wms.layer,f,1;test.timeenabled.wmts.layer@year=2016,,1`
)
)
})
})
Loading