Detox
Detox copied to clipboard
Long press from longPressAndDrag not being detected until after drag is completed
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?
- [X] I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
Help us reproduce this issue!
- Clone simplified repo https://github.com/tanakaderoy/detoxIssueRepro/
- Checkout branch
longPressAndDragRepro
- Use a compatible version of
node
(e.g.16.10.0
) -
yarn install
andyarn setup
to install dependencies -
yarn start
to run Metro -
yarn e2e-build ios.debug
to build for Detox -
yarn e2e-run ios.debug
to run the singular test that does thelongPressAndDrag
If you want to run it locally then do:
- Steps 1-5 above are completed
- Open
ios/detoxIssueRepro.xcworkspace
in Xcode - Build and run
- 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
Thanks for providing the repository for the reproduction. I hope @asafkorem will be able to look at it soon.
Hi @asafkorem, is there any update on this please?
Hi @aaulthudl, sorry, I haven't gotten to it yet. I will take a look today or tomorrow.
I was able to reproduce this issue (using @aaulthudl's repo). Investigating.
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
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 callinglongPressAndDrag
. 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.
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.
This is still required
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.
This is still required
Is there any update on this issue please?
Bump on this again please
Any update regarding this please?
@asafkorem Any update on this please?
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)
Are there any updates on this please?
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.
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!