feat(aria): make assertion agile and add the tests
The expected string can be asserting softly without being equivalent to the actual string References #32593
This commit is contained in:
parent
7456dea563
commit
988c876a62
|
|
@ -194,12 +194,12 @@ export function toHaveAccessibleName(
|
|||
) {
|
||||
if (Array.isArray(expected)) {
|
||||
return toEqual.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => {
|
||||
const expectedText = serializeExpectedTextValues(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
||||
const expectedText = serializeExpectedTextValues(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
||||
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], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
||||
const expectedText = serializeExpectedTextValues([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
|
||||
return await locator._expect('to.have.accessible.name', { expectedText, isNot, timeout });
|
||||
}, expected, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,6 +458,12 @@ 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 });
|
||||
});
|
||||
|
||||
test('toHaveAccessibleDescription', async ({ page }) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue