Detox icon indicating copy to clipboard operation
Detox copied to clipboard

Long press from longPressAndDrag not being detected until after drag is completed

Open aaulthudl opened this issue 2 years ago • 18 comments

What happened?

I have tried to integrate it into a test in my app which involves a draggable flatlist from https://www.npmjs.com/package/react-native-draggable-flatlist. This flatlist has its list items wrapped inTouchableHighlight elements with onLongPress={drag}. When running the tests it seems that it tries to press but it isn't detected by the system, then it does the drag (which doesn't accomplish much). After the longPressAndDrag, it looks like a press is then detected.

I removed the dependency of react-native-draggable-flatlist and logged when the onLongPress on the TouchableHighlight is called and it's not called until after the longPressAndDrag action finishes. I tried a normal longPress and that worked as expected and was detected by the system.

Disabling/dabbling around with synchronization produced no results.

What was the expected behaviour?

The Detox test interacts with the UI like a user would. Long press is not detected until after the whole action finishes and therefore the drag doesn't result in anything.

Was it tested on latest Detox?

  • [X] I have tested this issue on the latest Detox release and it still reproduces.

Did your test throw out a timeout?

Help us reproduce this issue!

  1. Clone simplified repo https://github.com/tanakaderoy/detoxIssueRepro/
  2. Checkout branch longPressAndDragRepro
  3. Use a compatible version of node (e.g. 16.10.0)
  4. yarn install and yarn setup to install dependencies
  5. yarn start to run Metro
  6. yarn e2e-build ios.debug to build for Detox
  7. yarn e2e-run ios.debug to run the singular test that does the longPressAndDrag

If you want to run it locally then do:

  1. Steps 1-5 above are completed
  2. Open ios/detoxIssueRepro.xcworkspace in Xcode
  3. Build and run
  4. In app, long press on a list item and then drag -> see it works as expected

In what environment did this happen?

Detox version: 20.1.0 React Native version: 18.0.0 Has Fabric (React Native's new rendering system) enabled: no Node version: 16.10.0 Device model: iPhone 14 Pro iOS version: 12.4 macOS version: 12.6.2 on Apple Silicon Xcode version: 14.1 Test-runner (select one): jest

Detox logs

Github was returning the error There was an error creating your Issue: body is too long (maximum is 65536 characters). when I had the log in here so I put it in pastebin.

https://pastebin.com/WBwYve4U

Device logs

Device logs
arron.ault@HUD040087 detoxIssueRepro % yarn e2e-run ios.debug --record-logs all
yarn run v1.22.19
$ detox test -c ios.debug --record-logs all
17:40:49.876 detox[43451] B jest --config e2e/jest.config.js
watchman warning:  Recrawled this watch 5 times, most recently because:
MustScanSubDirs UserDroppedTo resolve, please review the information on
https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl
To clear this warning, run:
`watchman watch-del '/Users/arron.ault/detoxIssueRepro' ; watchman watch-project '/Users/arron.ault/detoxIssueRepro'`

17:40:54.203 detox[43453] i drag.e2e.ts is assigned to 1B71F80E-EEC3-49A8-A570-B4A8F58A2249 (iPhone 12)
17:40:56.075 detox[43453] i org.reactjs.native.example.detoxIssueRepro launched. To watch simulator logs, run:
        /usr/bin/xcrun simctl spawn 1B71F80E-EEC3-49A8-A570-B4A8F58A2249 log stream --level debug --style compact --predicate 'process == "detoxIssueRepro"'
17:40:57.936 detox[43453] i Drag: should drag and rearrange
17:41:03.602 detox[43453] i Drag: should drag and rearrange [OK]

 PASS  e2e/drag.e2e.ts (13.11 s)
  Drag
    ✓ should drag and rearrange (5601 ms)

✨  Done in 14.38s.
arron.ault@HUD040087 detoxIssueRepro %

More data, please!

https://user-images.githubusercontent.com/84314259/213827704-267c383a-4c63-4b51-95dd-edb23165aa19.mp4

aaulthudl avatar Jan 20 '23 17:01 aaulthudl

Thanks for providing the repository for the reproduction. I hope @asafkorem will be able to look at it soon.

noomorph avatar Jan 24 '23 06:01 noomorph

Hi @asafkorem, is there any update on this please?

aaulthudl avatar Feb 27 '23 15:02 aaulthudl

Hi @aaulthudl, sorry, I haven't gotten to it yet. I will take a look today or tomorrow.

asafkorem avatar Feb 28 '23 09:02 asafkorem

I was able to reproduce this issue (using @aaulthudl's repo). Investigating.

asafkorem avatar Mar 05 '23 11:03 asafkorem

Hey @aaulthudl, thanks for report. Indeed, it looks like there's some conflict with the gesture handling of this library (and its dependency - RN-Gesture-Handler) and Detox, which will require deeper investigation from my end.

For the meanwhile, I think I found some workaround for you (please confirm). Add a separate await from.longPress(1000); call right before calling longPressAndDrag. It worked for me with the reproduction test although it shouldn't basically, I will keep this issue open and will update here with any future progress on that matter.

asafkorem avatar Mar 05 '23 11:03 asafkorem

@asafkorem

Hey @aaulthudl, thanks for report. Indeed, it looks like there's some conflict with the gesture handling of this library (and its dependency - RN-Gesture-Handler) and Detox, which will require deeper investigation from my end.

For the meanwhile, I think I found some workaround for you (please confirm). Add a separate await from.longPress(1000); call right before calling longPressAndDrag. It worked for me with the reproduction test although it shouldn't basically, I will keep this issue open and will update here with any future progress on that matter.

It didn't work for me sadly.

aaulthudl avatar Mar 07 '23 16:03 aaulthudl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

stale[bot] avatar Apr 06 '23 23:04 stale[bot]

This is still required

aaulthudl avatar Apr 13 '23 09:04 aaulthudl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this repository, read this discussion.

stale[bot] avatar May 19 '23 00:05 stale[bot]

This is still required

aaulthudl avatar May 19 '23 10:05 aaulthudl

Is there any update on this issue please?

aaulthudl avatar Aug 22 '23 10:08 aaulthudl

Bump on this again please

aaulthudl avatar Nov 06 '23 12:11 aaulthudl

Any update regarding this please?

aaulthudl avatar Jan 04 '24 14:01 aaulthudl

@asafkorem Any update on this please?

aaulthudl avatar Mar 06 '24 09:03 aaulthudl

This is also an issue for us. We need to run longPressAndDrag twice in the test, which can cause test errors related to visibility of the pressable item if a ScaleDecorator is used (e.g. if the pressable item expands and is no longer 100% visible), the second "longPressAnDrag" that is required because of this issue can fail as the item is no longer 100% visible)

michaeldawson avatar May 15 '24 10:05 michaeldawson

Are there any updates on this please?

aaulthudl avatar Jul 23 '24 09:07 aaulthudl

Unfortunately, there isn't a straightforward solution for your case I can point on, though it's possible that something is incorrect on this implementation.

Currently, there is no priority or ETA from the Detox team to investigate this issue any deeper. However, we welcome external contributors who are interested in exploring this further.

asafkorem avatar Jul 23 '24 17:07 asafkorem

Hello! We appreciate you bringing this issue to our attention. It looks like this could be a valuable addition or fix to our project. We believe that this feature would benefit greatly from contributions from the community, even from first-time contributors.

If you're interested in contributing to this feature, please take a look at our contribution guide. It has all the information you need to know about how to submit a pull request and contribute to our project.

You're also welcome to join our Discord server and discuss this feature with the collaborators or other contributors under the channel 'contributions'.

Please feel free to reach out to us if you have any questions, or need help with anything. We appreciate your feedback and look forward to working with you!

github-actions[bot] avatar Jul 23 '24 18:07 github-actions[bot]