-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat: expect(locator).toHaveAccessibleErrorMessage #33904
feat: expect(locator).toHaveAccessibleErrorMessage #33904
Conversation
This comment has been minimized.
This comment has been minimized.
e68009a
to
cccdd97
Compare
This comment has been minimized.
This comment has been minimized.
cccdd97
to
6623a77
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
95d0978
to
0a4ee89
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0a4ee89
to
c963a6d
Compare
This comment has been minimized.
This comment has been minimized.
c963a6d
to
2195194
Compare
This comment has been minimized.
This comment has been minimized.
f764780
to
139b5dd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This looks very good! Just a few comments about aria spec/semantics, and this will be good to do.
3c01c81
to
41921ed
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Thank you for the PR, looks very good!
export const kInputValidityAttributes = ['required', 'pattern', 'min', 'max', 'minlength', 'maxlength', 'step', 'type', 'value']; | ||
|
||
export function hasValidationAttributes(element: Element): boolean { | ||
if (!(element instanceof HTMLInputElement)) |
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.
validity
is defined for a lot of elements, e.g. <select>
, <textarea>
, <object>
, <button>
, <fieldset>
, probably more. I'd drop this check, and assume that element.validity?.valid === false
means it is invalid.
const role = getAriaRole(element) || ''; | ||
if (!role || !kAriaInvalidRoles.includes(role)) | ||
return 'false'; | ||
if (element instanceof HTMLInputElement && hasValidationAttributes(element) && element.validity) |
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.
Perhaps check both aria-invalid
and element.validity?.valid === false
, and consider the element invalid when either of the indicators is present?
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 understood it as being asked to remove hasValidationAttributes and evaluate only with
element.validity?.valid === false
without assessing thekAriaInvalidRoles attributes
. Would that be correct? :) -
According to the spec, it seems that the return values of the
getAriaInvalid
function should be'false' | 'true' | 'grammar' | 'spelling'
.
Rather than evaluatingvalidity
within this function, I think it would be better to separate it into a dedicated function, such asgetValidityInvalid
. I look forward to your feedback on this! :)
41921ed
to
9378431
Compare
This comment has been minimized.
This comment has been minimized.
9378431
to
b28ad83
Compare
This comment has been minimized.
This comment has been minimized.
…essage references
b28ad83
to
cab504b
Compare
Test results for "tests 1"8 flaky37461 passed, 650 skipped Merge workflow run. |
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.
This looks great! Thank you for the PR! and following through the review process. Merging in.
Closes #31249
toHaveAccessibleErrorMessage
matcher forexpect(locator)
.Looking forward to teams feedback. Thanks! :)