Current behavior:
cy.click will not respect either coordinate option if it is passed as 0. This is because a truthy comparison is used to set the default option, when it should really check if it is a finite number.
This issue is most likely present on right click and double click as well.
Desired behavior:
x and y parameters can be 0 and the function will behave as it does for all other number values (and click the top left of the element).
Test code to reproduce
it('can specify x and/or y to be 0', () => {
const $btn = $('<button id="click-button">clicking button</button>')
.prependTo(cy.$$('body'))
const position = $btn.offset()
cy.on('log:changed', (log, attr) => {
if (log.name === 'click' && attr._emittedAttrs.coords) {
const args = attr._emittedAttrs.message.split(', ').map((i) => parseInt(i))
const coords = attr._emittedAttrs.coords
expect(coords.x).to.equal(coords.left)
expect(coords.y).to.equal(coords.top)
expect(coords.x).to.equal(position.left + args[0])
expect(coords.y).to.equal(position.top + args[1])
}
})
cy.get('#click-button').click(2, 2)
cy.get('#click-button').click(0, 0)
cy.get('#click-button').click(0, 2)
cy.get('#click-button').click(2, 0)
})
Current behavior:
cy.clickwill not respect either coordinate option if it is passed as 0. This is because a truthy comparison is used to set the default option, when it should really check if it is a finite number.This issue is most likely present on right click and double click as well.
Desired behavior:
xandyparameters can be 0 and the function will behave as it does for all other number values (and click the top left of the element).Test code to reproduce