feat(aria): get rid of the matchSubstring from the accessible name

Update accessible name check in the matchers.ts

References #32593
This commit is contained in:
anait-airiian 2024-11-17 17:30:00 +01:00
parent 0e54692d56
commit bc99d141bb
3 changed files with 2 additions and 5 deletions

View file

@ -194,7 +194,7 @@ export function toHaveAccessibleName(
) {
if (Array.isArray(expected)) {
return toEqual.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => {
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
const expectedText = serializeExpectedTextValues(expected, { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
return await locator._expect('to.have.accessible.name.array', { expectedText, isNot, timeout });
}, expected, options);
} else {

View file

@ -7899,7 +7899,7 @@ interface LocatorAssertions {
* @param name Expected accessible name.
* @param options
*/
toHaveAccessibleName(name: string|RegExp|ReadonlyArray<string>|ReadonlyArray<RegExp>, options?: {
toHaveAccessibleName(name: string|RegExp|ReadonlyArray<string|RegExp>, options?: {
/**
* Whether to perform case-insensitive match.
* [`ignoreCase`](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-accessible-name-option-ignore-case)

View file

@ -461,9 +461,6 @@ test('toHaveAccessibleName should accept array of names for multiple elements',
'Cell A2 Cell B2 Cell C2',
'Cell A3 Cell B3 Cell C3',
]);
await expect(page.getByRole('row')).toHaveAccessibleName(['Cell A1 Cell B1 Cell C1',
'Cell A2 Cell B2 Cell C2',
'Cell A3 Cell B3',]);
await expect(page.getByRole('row')).toHaveAccessibleName(['cell a1 cell b1 cell C1',
'cell A2 Cell b2 Cell c2',
'Cell a3 Cell b3 cell C3',], { ignoreCase: true });