-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(aria): extend toHaveAccessibleName() to accept an array of expected accessible names #33277
Conversation
…ted accessible names This commit extends the toHaveAccessibleName() matcher to support an array References microsoft#32593
This commit includes the handling accessible.name.array References microsoft#32593
The expected string can be asserting softly without being equivalent to the actual string References microsoft#32593
This comment has been minimized.
This comment has been minimized.
@microsoft-github-policy-service agree |
Update type in the doc References microsoft#32593
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.
Thanks for the PR, this looks great! I'll discuss with the team tonight to see if there's anything we need to pay close attention to.
}, expected, options); | ||
if (Array.isArray(expected)) { | ||
return toEqual.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => { | ||
const expectedText = serializeExpectedTextValues(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
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'd prefer the changes to normalizeWhiteSpace
and matchSubstring
to be in a separate PR, and discuss them in an issue first - especially the matchSubstring
one sounds breaking to me.
Let's keep this PR strictly about accepting an array.
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.
+1, let's only land the array aspect.
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 excluded the matchSubstring option from the string serialization
We're happy to go forward with this. We have a related feature in the works that's about ARIA snapshots, and that should be strictly better than the array forms of |
Thank you for getting back to me. I appreciate the time you've taken to review my PR and consider it 😌🙏🏻 |
@@ -1236,7 +1236,7 @@ await Expect(locator).toHaveAccessibleNameAsync("Save to disk"); | |||
|
|||
### param: LocatorAssertions.toHaveAccessibleName.name | |||
* since: v1.44 | |||
- `name` <[string]|[RegExp]> | |||
- `name` <[string]|[RegExp]|[Array]<[string]>|[Array]<[RegExp]>> |
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 should be [Array]<[string]|[RegExp]>
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.
Fixed the type format
}, expected, options); | ||
if (Array.isArray(expected)) { | ||
return toEqual.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => { | ||
const expectedText = serializeExpectedTextValues(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
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.
+1, let's only land the array aspect.
Update accessible name check in the matchers.ts References microsoft#32593
This comment has been minimized.
This comment has been minimized.
Changed type accessible name in the doc file References microsoft#32593
Test results for "tests 1"2 flaky36917 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.
Looks great, thank you for the PR!
extend toHaveAccessibleName() to accept an array of expected accessible names and write the tests for the type
Closes #32593.