fix(aria): normalize whitespace in toMatchAccessible{Name,Description} (#33619)
This commit is contained in:
Родитель
eaf3536014
Коммит
2aa9e11a7f
|
@ -181,7 +181,7 @@ export function toHaveAccessibleDescription(
|
|||
options?: { timeout?: number, ignoreCase?: boolean },
|
||||
) {
|
||||
return toMatchText.call(this, 'toHaveAccessibleDescription', locator, 'Locator', async (isNot, timeout) => {
|
||||
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase });
|
||||
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
|
||||
return await locator._expect('to.have.accessible.description', { expectedText, isNot, timeout });
|
||||
}, expected, options);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ export function toHaveAccessibleName(
|
|||
options?: { timeout?: number, ignoreCase?: boolean },
|
||||
) {
|
||||
return toMatchText.call(this, 'toHaveAccessibleName', locator, 'Locator', async (isNot, timeout) => {
|
||||
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase });
|
||||
const expectedText = serializeExpectedTextValues([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
|
||||
return await locator._expect('to.have.accessible.name', { expectedText, isNot, timeout });
|
||||
}, expected, options);
|
||||
}
|
||||
|
|
|
@ -431,6 +431,9 @@ test('toHaveAccessibleName', async ({ page }) => {
|
|||
await expect(page.locator('div')).toHaveAccessibleName(/ell\w/);
|
||||
await expect(page.locator('div')).not.toHaveAccessibleName(/hello/);
|
||||
await expect(page.locator('div')).toHaveAccessibleName(/hello/, { ignoreCase: true });
|
||||
|
||||
await page.setContent(`<button>foo bar\nbaz</button>`);
|
||||
await expect(page.locator('button')).toHaveAccessibleName('foo bar baz');
|
||||
});
|
||||
|
||||
test('toHaveAccessibleDescription', async ({ page }) => {
|
||||
|
@ -443,6 +446,12 @@ test('toHaveAccessibleDescription', async ({ page }) => {
|
|||
await expect(page.locator('div')).toHaveAccessibleDescription(/ell\w/);
|
||||
await expect(page.locator('div')).not.toHaveAccessibleDescription(/hello/);
|
||||
await expect(page.locator('div')).toHaveAccessibleDescription(/hello/, { ignoreCase: true });
|
||||
|
||||
await page.setContent(`
|
||||
<div role="button" aria-describedby="desc"></div>
|
||||
<span id="desc">foo bar\nbaz</span>
|
||||
`);
|
||||
await expect(page.locator('div')).toHaveAccessibleDescription('foo bar baz');
|
||||
});
|
||||
|
||||
test('toHaveRole', async ({ page }) => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче