Skip to content

Compare Ratio Case Change #708

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

Merged
merged 1 commit into from
Mar 15, 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
2 changes: 1 addition & 1 deletion src/modules/map/components/CompareSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function releaseSlider() {
<template>
<div
class="compare-slider position-absolute top-0 translate-middle-x h-100 d-inline-block"
data-cy="compare_slider"
data-cy="compareSlider"
:style="compareSliderPosition"
@touchstart.passive="grabSlider"
@mousedown.passive="grabSlider"
Expand Down
2 changes: 1 addition & 1 deletion src/router/legacyPermalinkManagement.routerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const handleLegacyParam = (
// Setting the position of the compare slider
case 'swipe_ratio':
newValue = legacyValue
key = 'compare_ratio'
key = 'compareRatio'
break
case 'layers_opacity':
case 'layers_visibility':
Expand Down
4 changes: 2 additions & 2 deletions src/router/storeSync/CompareSliderParamConfig.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ function generateCompareSliderUrlParamFromStore(store) {

/**
* This ensure the following: When the compare ratio is set in the url, the flag telling if the
* compare slider is active is set to true. We remove the compare_ratio parameter from the URL when
* compare slider is active is set to true. We remove the compareRatio parameter from the URL when
* the compare slider is not active The default value of the parameter is null
*/
export default class CompareSliderParamConfig extends AbstractParamConfig {
constructor() {
super(
'compare_ratio',
'compareRatio',
'setCompareRatio, setCompareSliderActive',
dispatchCompareSliderFromUrlParam,
generateCompareSliderUrlParamFromStore,
Expand Down
56 changes: 28 additions & 28 deletions tests/cypress/tests-e2e/compareSlider.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@ describe('Testing of the compare slider', () => {

expectCompareRatioToBe(null)
expectCompareSliderToBeActive(false)
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
})
it('does not shows up with layers and the compare ratio parameter out of bounds or not a number', () => {
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compare_ratio: '1.4',
compareRatio: '1.4',
},
true
)
expectCompareRatioToBe(null)
expectCompareSliderToBeActive(false)

cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compare_ratio: '-0.3',
compareRatio: '-0.3',
},
true
)
expectCompareRatioToBe(null)
expectCompareSliderToBeActive(false)

cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compare_ratio: 'aRandomText',
compareRatio: 'aRandomText',
},
true
)
expectCompareRatioToBe(null)
expectCompareSliderToBeActive(false)

cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
})
})
})
Expand All @@ -71,39 +71,39 @@ describe('Testing of the compare slider', () => {
This function moves the slider so the 'left' position of the element will be at x.
The slider is 40 px wide and we drag it from the center.
*/
cy.get('[data-cy="compare_slider"]').trigger('mousedown', { button: 0 })
cy.get('[data-cy="compare_slider"]').trigger('mousemove', {
cy.get('[data-cy="compareSlider"]').trigger('mousedown', { button: 0 })
cy.get('[data-cy="compareSlider"]').trigger('mousemove', {
clientX: Math.abs(x + 20),
clientY: 100,
})
cy.get('[data-cy="compare_slider"]').trigger('mouseup', { force: true })
cy.get('[data-cy="compareSlider"]').trigger('mouseup', { force: true })
}
context('Moving the compare slider', () => {
it('moves when we click on it and drag the mouse', () => {
cy.goToMapView(
{
layers: 'test-1.wms.layer',
compare_ratio: '0.3',
compareRatio: '0.3',
},
true
)
// initial slider position is width * 0.3 -20
cy.get('[data-cy="compare_slider"]').then((slider) => {
cy.get('[data-cy="compareSlider"]').then((slider) => {
cy.readStoreValue('state.ui.width').then((width) => {
cy.wrap(slider.position()['left']).should('eq', width * 0.3 - 20)
})
})
expectCompareRatioToBe(0.3)
expectCompareSliderToBeActive(true)
cy.get('[data-cy="compare_slider"]').should('be.visible')
cy.get('[data-cy="compareSlider"]').should('be.visible')
moveSlider(73)
cy.get('[data-cy="compare_slider"]').then((slider) => {
cy.get('[data-cy="compareSlider"]').then((slider) => {
cy.wrap(slider.position()['left']).should('be.closeTo', 73.0, 0.2)
})

cy.log('It refuses to get out of bounds when we move around')
moveSlider(-10)
cy.get('[data-cy="compare_slider"]').then((slider) => {
cy.get('[data-cy="compareSlider"]').then((slider) => {
//it stops at around 5.999, so we ensure this does not make the test fail, while still being close enough to be relevant

cy.wrap(slider.position()['left']).should('be.closeTo', -6.0, 0.2)
Expand All @@ -114,7 +114,7 @@ describe('Testing of the compare slider', () => {
moveSlider(width - 1)
})

cy.get('[data-cy="compare_slider"]').then((slider) => {
cy.get('[data-cy="compareSlider"]').then((slider) => {
cy.readStoreValue('state.ui.width').then((width) => {
cy.wrap(slider.position()['left']).should('be.lte', width - 34.0)
cy.wrap(slider.position()['left']).should('be.closeTo', width - 34.0, 0.2)
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('Testing of the compare slider', () => {
cy.goToMapView(
{
layers: layerIds.join(';'),
compare_ratio: '0.5',
compareRatio: '0.5',
},
true
)
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('Testing of the compare slider', () => {
.should('be.visible')
.click()
cy.closeMenuIfMobile()
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
})
})
})
Expand All @@ -258,10 +258,10 @@ describe('Testing of the compare slider', () => {
cy.readStoreValue('state.ui.isCompareSliderActive').then((isSliderActive) => {
expect(isSliderActive).to.eq(true)
})
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
})
it('stays "active" when we remove the last layer', () => {
cy.goToMapView({ layers: 'test-1.wms.layer', compare_ratio: '0.3' }, true)
cy.goToMapView({ layers: 'test-1.wms.layer', compareRatio: '0.3' }, true)
cy.openMenuIfMobile()
cy.readStoreValue('state.ui.compareRatio').then((compareRatio) => {
expect(compareRatio).to.eq(0.3)
Expand All @@ -270,7 +270,7 @@ describe('Testing of the compare slider', () => {
cy.readStoreValue('state.ui.isCompareSliderActive').then((isSliderActive) => {
expect(isSliderActive).to.eq(true)
})
cy.get('[data-cy="compare_slider"]').should('be.visible')
cy.get('[data-cy="compareSlider"]').should('be.visible')

cy.get(`[data-cy="button-remove-layer-test-1.wms.layer"]`)
.should('be.visible')
Expand All @@ -283,17 +283,17 @@ describe('Testing of the compare slider', () => {
cy.readStoreValue('state.ui.isCompareSliderActive').then((isSliderActive) => {
expect(isSliderActive).to.eq(true)
})
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')
})
it('appears and is functional when layers are present in 2d', () => {
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compare_ratio: '0.3',
compareRatio: '0.3',
},
true
)
cy.get('[data-cy="compare_slider"]').should('be.visible')
cy.get('[data-cy="compareSlider"]').should('be.visible')
cy.openMenuIfMobile()
cy.get('[data-cy="menu-tray-tool-section"]').click()
cy.get('[data-cy="menu-advanced-tools-compare"]').should('be.visible')
Expand All @@ -313,13 +313,13 @@ describe('Testing of the compare slider', () => {
cy.readStoreValue('state.ui.isCompareSliderActive').then((isSliderActive) => {
expect(isSliderActive).to.eq(false)
})
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')

cy.get('[data-cy="menu-advanced-tools-compare"]').click()
cy.readStoreValue('state.ui.compareRatio').then((compareRatio) => {
expect(compareRatio).to.eq(0.3)
})
cy.get('[data-cy="compare_slider"]').should('be.visible')
cy.get('[data-cy="compareSlider"]').should('be.visible')
})
}
)
Expand All @@ -332,13 +332,13 @@ describe('The compare Slider and the menu elements should not be available in 3d
cy.goToMapView(
{
layers: ['test-1.wms.layer', 'test-2.wms.layer,,'].join(';'),
compare_ratio: '0.4',
compareRatio: '0.4',
'3d': true,
sr: WEBMERCATOR.epsgNumber,
},
true
)
cy.get('[data-cy="compare_slider"]').should('not.exist')
cy.get('[data-cy="compareSlider"]').should('not.exist')

cy.readStoreValue('state.ui.compareRatio').then((compareRatio) => {
expect(compareRatio).to.eq(0.4)
Expand Down
4 changes: 2 additions & 2 deletions tests/cypress/tests-e2e/legacyParamImport.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,15 @@ describe('Test on legacy param import', () => {
false
)
// initial slider position is width * 0.3 -20
cy.get('[data-cy="compare_slider"]').then((slider) => {
cy.get('[data-cy="compareSlider"]').then((slider) => {
cy.readStoreValue('state.ui.width').should((width) => {
expect(slider.position()['left']).to.eq(width * 0.3 - 20)
})
})
cy.readStoreValue('state.ui.compareRatio').should('be.equal', 0.3)

cy.readStoreValue('state.ui.isCompareSliderActive').should('be.equal', true)
cy.get('[data-cy="compare_slider"]').should('be.visible')
cy.get('[data-cy="compareSlider"]').should('be.visible')
})
})
})