Skip to content

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

@aaulthudl

Description

@aaulthudl

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?

  • 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!

Untitled.mp4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions