-
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
Changes from 5 commits
459914c
7456dea
988c876
423b85a
8224c93
0e54692
bc99d14
6ad67d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,13 +189,20 @@ export function toHaveAccessibleDescription( | |
export function toHaveAccessibleName( | ||
this: ExpectMatcherState, | ||
locator: LocatorEx, | ||
expected: string | RegExp, | ||
options?: { timeout?: number, ignoreCase?: boolean }, | ||
expected: string | RegExp | (string | RegExp)[], | ||
options: { timeout?: number, ignoreCase?: boolean, normalizeWhiteSpace?: boolean } = {} | ||
) { | ||
return toMatchText.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => { | ||
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase }); | ||
return await locator._expect('to.have.accessible.name', { expectedText, isNot, timeout }); | ||
}, 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer the changes to Let's keep this PR strictly about accepting an array. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I excluded the matchSubstring option from the string serialization |
||
return await locator._expect('to.have.accessible.name.array', { expectedText, isNot, timeout }); | ||
}, expected, options); | ||
} else { | ||
return toMatchText.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => { | ||
const expectedText = serializeExpectedTextValues([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); | ||
return await locator._expect('to.have.accessible.name', { expectedText, isNot, timeout }); | ||
}, expected, options); | ||
} | ||
} | ||
|
||
export function toHaveAttribute( | ||
|
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