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

Clicking the Correct Location but not Draging From Clicked Location #115

Open
Bassy-Teisen opened this issue Aug 1, 2022 · 0 comments
Open

Comments

@Bassy-Teisen
Copy link

I was able to make cypress click the source element location and target location, however when cypress attempted to drag the source element it would be moved to the wrong location. I found that the locations were be captured from inside of the parent div, then when the element was dragged, its location would be placed relative to the body. This meant that the element was always to high to be dropped on its target. By replace .getBoundingClientRect() with .offsetTop I was able to correct this.

const currentSourcePosition = this.source.getBoundingClientRect()

this.initialSourcePosition = this.source.getBoundingClientRect()

diff --git a/node_modules/@4tw/cypress-drag-drop/index.js b/node_modules/@4tw/cypress-drag-drop/index.js
index b316fc1..6a4ada3 100644
--- a/node_modules/@4tw/cypress-drag-drop/index.js
+++ b/node_modules/@4tw/cypress-drag-drop/index.js
@@ -23,7 +23,7 @@ const DragSimulator = {
     return { source, target }
   },
   get dropped() {
-    const currentSourcePosition = this.source.getBoundingClientRect()
+      const currentSourcePosition = this.source.offsetTop;
     return !this.rectsEqual(this.initialSourcePosition, currentSourcePosition)
   },
   get hasTriesLeft() {
@@ -118,7 +118,7 @@ const DragSimulator = {
     this.options = this.createDefaultOptions(options)
     this.counter = 0
     this.source = source.get(0)
-    this.initialSourcePosition = this.source.getBoundingClientRect()
+    this.initialSourcePosition = this.source.offsetTop
     return cy.get(target).then((targetWrapper) => {
       this.target = targetWrapper.get(0)
     })
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

No branches or pull requests

1 participant