replaceText duplicates the string when a maxLength is set
What happened?
In a TextInput with a maxLength prop set, calling replaceText with a string that has a length over half of the maxLength causes the string to be repeated at the start of the input.
For example
<TextInput testID='testInput' maxLength={10} >
element(by.id('testInput')).replaceText('abcdef');
causes the TextInput value to become abcdabcdef
It seems this was reported back in 2018 but wasn't addressed. https://github.com/wix/Detox/issues/921
What was the expected behaviour?
That replaceText would only enter the specified string once in the TextInput
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?
- [ ] I have followed the instructions under Identifying which synchronization mechanism causes us to wait too much.
Help us reproduce this issue!
- Create a TextInput component with a maxLength, e.g.
maxLength={10} - In a test, call
replaceTexton the above TextInput using a string with a length >= half of the maxLength, e.g.'abcdef' - Run the test and see the TextInput value become
abcdabcdef
In what environment did this happen?
Detox version: 19.9.0 React Native version: 0.66.4 Node version: 16.14.0 Device model: iPhone 13 iOS version: 15.2 Test-runner (select one): jest-circus
Detox logs
Detox logs
15:16:18.746 detox[98658] TRACE: [WS_SEND] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:18.746 detox[98658] TRACE: [WSS_GET_FROM, #tester] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:18.746 detox[98658] TRACE: [WSS_SEND_TO, #app] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["abcdef"],"predicate":{"type":"id","value":"TEST"}},"messageId":18}
15:16:20.346 detox[98658] TRACE: [WSS_GET_FROM, #app] {"params":{},"messageId":18,"type":"invokeResult"}
15:16:20.346 detox[98658] TRACE: [WSS_SEND_TO, #tester] {"params":{},"messageId":18,"type":"invokeResult"}
15:16:20.347 detox[98658] TRACE: [WS_MESSAGE] {"params":{},"messageId":18,"type":"invokeResult"}
Device logs
Device logs
paste logs here!
More data, please!
No response
Thanks for reporting @kaibarnes! I will try to reproduce this issue using the steps you provided.
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 reporsitory, read this discussion.
It seems this issue is still reproducible on 20.17.0.
Except using typeText instead, any other way to fix it?
@lclnrd Hopefully, Asaf will be back soon (we miss him too) and will be able to look. Otherwise, pull requests are welcome.