-
-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when fillIn
/ typeIn
attempt to enter a value longer than maxlength
#747
Conversation
Thanks for working on failing test cases here! If you have the time, you can probably implement a check that truncates (or whatever the "right" behavior is) here in these spots:
|
I think fillIn is pretty straightforward - just truncate at maxlength, as it replaces any previous value in the control. For typeIn I'm less sure. I think typeIn is additive, so if I did await typeIn('input', 'a');
await typeIn('input', 'b'); I would end up w/ 'ab'. So I guess typeIn should stop modifying element.value when the maxlength of the combined (previous values + new values).length === maxlength. |
Yep, that is what I think also but we should confirm that is the actual browser. |
97a3040
to
ae4aab2
Compare
I went down a bit of a rabbit hole reading docs around https://developer.mozilla.org/en-US/docs/Web/API/Constraint_validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes were needed to typeIn
?
Still working on typeIn |
addon-test-support/@ember/test-helpers/dom/-is-maxlength-constrained.ts
Outdated
Show resolved
Hide resolved
@jaydgruber what's the status on this? |
oh I guess I could have pinged someone for re-review. this one should be ready to go, pending the one above question about do I need to do more to make it 'TypeScript-y' |
Seems like As far as I can see, in this PR, we try to trim the input and keep emitting events. If my codepen test is correct, I think we should not emit any events. Maybe we should even throw, to make un-intended |
Yeah, I think throw similarly makes sense here |
addon-test-support/@ember/test-helpers/dom/-is-maxlength-constrained.ts
Outdated
Show resolved
Hide resolved
@jaydgruber I just wanna check if you are going to keep working on this? in case you are busy with something else, I can take it over. Otherwise it'd be glad to provide any assistance! |
@ro0gr I won't be able to get to it until probably Friday. I've got no objections if you want to pick it up. Thanks |
@jaydgruber Great! sounds like you are in the game :) Take your time. |
…-in and type-in to use helper
4bc205e
to
d1109f3
Compare
@ro0gr this should be ready for another look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Events test for IE seems to be broken though.
addon-test-support/@ember/test-helpers/dom/-is-maxlength-constrained.ts
Outdated
Show resolved
Hide resolved
addon-test-support/@ember/test-helpers/dom/-is-maxlength-constrained.ts
Outdated
Show resolved
Hide resolved
tests/unit/dom/type-in-test.js
Outdated
await assert.rejects( | ||
typeIn(element, tooLongString).finally(() => { | ||
// should throw before the second input event | ||
assert.verifySteps(expectedEvents.slice(0, 8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like for isIE11
it would expect to throw before the third keypress
, that doesn't seem correct.
@rwjblue do we have IE tests broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, it is possible, we don't have IE11 under CI test at the moment. We should look into hooking that up... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I corrected the assertion here, but I don't have an IE launcher for testem locally, so not sure the best way to confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
fillIn
/ typeIn
attempt to enter a value longer than maxlength
Awesome, thank you! |
What
isMaxLengthConstrained
['keydown', 'keypress', 'keyup']
events, but noinput
event, and element.value does not changeWhy