I'm trying to test the panning action in open layers but I can't get the map to move. The versions I am using are these:
- OpenLayers: 6.10.0
- Cypress: 9.7.0
This is the code I have:
When('I pan the map to a different area', () => {
cy.wait(3000)
cy.get('.ol-layer canvas').trigger('pointerdown', {
clientX: 900,
clientY: 300,
force: true,
pointerId: 1,
})
cy.get('.ol-layer canvas').trigger('pointermove', {
x: 600,
y: 200,
force: true,
pointerId: 2,
})
cy.get('.ol-layer canvas').trigger('pointermove', {
x: 300,
y: 100,
force: true,
pointerId: 1,
})
cy.wait(2000)
cy.get('.ol-layer canvas').trigger('pointerup', { force: true, pointerId: 1 })
})
I've been dealing with the same issue. Eventually I made it work, at least partially. The only thing is that the first pointermove is ignored but the rest do just fine. I have no idea why this happens.
This is the code. Hope it works for you as well