Update ValidityState when editing values
Problem description:
When changing an element in UI, the browser updates element.validity.
user-event maintains the UI value as it diverges from the IDL value, but it does not update element.validity accordingly.
There was a test asserting this behavior: https://github.com/testing-library/user-event/blob/a747b0ab07681651bf6b6428471de2dd76bc22df/tests/type/index.ts#L531-L542
Suggested solution:
Implement ValidityState and update it when changing UI value.
My team is also suffering with this problem on a HTML 5 date field. In the browser you can partially fill out a date whereas in react testing library we can only input complete dates.
We have worked around the problem by extracting the function and testing it in isolation but its not an ideal solution.
// THIS IS A LIMITATION OF THE BROWSER // It is impossible to programmatically set an input // value to an invlid value. Not sure how to work around this
I don't know if that would help but the customError member of ValidiyState can be set through setCustomValidity