ngx-mask
ngx-mask copied to clipboard
Misleading "backspace/delete" tests
Description
The "Directive: Mask (Delete)" tests do not replicate real browser behavior at all. With real "Delete/Backspace" events, the browser actually deletes the characters selected / next to the cursor.
Example
For instance this test only tests if the value that is set at the beginning is formatted correctly. https://github.com/JsDaddy/ngx-mask/blob/fb6f176ce841bb78b3ec5ca4e3a3d52bce7404ac/projects/ngx-mask-lib/src/test/delete.spec.ts#L24-L39 The same would happen if the two triggerEventHandlers were omitted, because after the value "2/34/5678" is set, the input value is automatically formatted to "23/45/678". Also the cursor position is checked incorrectly. After a backspace at position 1 (between "2" and "3") the cursor should be at position 0.
Problem
With these tests, a false sense of security is created and changes that would solve the misbehavior fail.
Solution
- added cypress to be able to e2e test the directive.
- tried to solve the problems in the mask directive but didn't fully understand the apply mask service.
Issues probably caused by these tests or relevant:
https://github.com/JsDaddy/ngx-mask/issues/664 https://github.com/JsDaddy/ngx-mask/issues/799 https://github.com/JsDaddy/ngx-mask/issues/844 https://github.com/JsDaddy/ngx-mask/issues/865
There are also other issues like you can't select text and delete the selected text with backspace. Instead it will only delete one character.

~~Maybe these tests and mask directive changes could fix #899 as well?~~ 🙈
Nevermind, just noticed it is only for deleting characters but not when adding new ones with multiple masks.
@manuelmeister @KingDarBoja Seems like we merged a couple request relative to this . If problem still actual please create new one issues or connect with me directly