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

realSwipe - x: 0 or y: 0 is incorrectly rejected as being treated as falsey #641

Open
amoshydra opened this issue Feb 24, 2024 · 0 comments · May be fixed by #642
Open

realSwipe - x: 0 or y: 0 is incorrectly rejected as being treated as falsey #641

amoshydra opened this issue Feb 24, 2024 · 0 comments · May be fixed by #642

Comments

@amoshydra
Copy link

amoshydra commented Feb 24, 2024

Expected

TouchStart and TouchEvent should start at coordinate x: 0 and y: 0 when x: 0 and y: 0 is provided in readSwipe

cy.mount(<Canvas />);

cy
  .get("body")
  .realSwipe("toRight", {
    x: 0,
    y: 0,
  })
;

Current

However when a 0 value is provided to either x or y, position is computed to be undefined as the values are falsey and intepreted as not provided.

const position =
options.x && options.y
? { x: options.x, y: options.y }
: options.touchPosition;

Reproduce:

Reproduce repository: https://github.com/amoshydra/repro-dmtrKovalenko-cypress-real-events-i-swipes/blob/real-swipe-with-x-or-y-be-0/src/components/input/Canvas.cy.tsx

The video preview shows 3 tests with the following calls:

.realSwipe("toRight", {
  x: 0,
  y: 1,
})
.realSwipe("toRight", {
  x: 1,
  y: 0,
})
.realSwipe("toRight", {
  x: 1,
  y: 1,
})
repro.mp4

Possible solution

  1. Actually check if x and y are undefined or 0.
  2. If either x or y is provided, automatically fill the undefined x or y as 0.
  3. options.touchPosition should be used only when both x and y are undefined.

Proposal : #642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant