chore: deflake textarea test (#10983)
This commit is contained in:
parent
02a9917d16
commit
464386ecf5
@ -4,7 +4,7 @@
|
|||||||
<title>Textarea test</title>
|
<title>Textarea test</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<textarea></textarea>
|
<textarea rows="5" cols="20"></textarea>
|
||||||
<script src='mouse-helper.js'></script>
|
<script src='mouse-helper.js'></script>
|
||||||
<script>
|
<script>
|
||||||
globalThis.result = '';
|
globalThis.result = '';
|
||||||
|
@ -97,29 +97,30 @@ describe('Mouse', function () {
|
|||||||
it('should select the text with mouse', async () => {
|
it('should select the text with mouse', async () => {
|
||||||
const {page, server} = await getTestState();
|
const {page, server} = await getTestState();
|
||||||
|
|
||||||
await page.goto(server.PREFIX + '/input/textarea.html');
|
|
||||||
await page.focus('textarea');
|
|
||||||
const text =
|
const text =
|
||||||
"This is the text that we are going to try to select. Let's see how it goes.";
|
"This is the text that we are going to try to select. Let's see how it goes.";
|
||||||
|
|
||||||
|
await page.goto(`${server.PREFIX}/input/textarea.html`);
|
||||||
|
await page.focus('textarea');
|
||||||
await page.keyboard.type(text);
|
await page.keyboard.type(text);
|
||||||
// Firefox needs an extra frame here after typing or it will fail to set the scrollTop
|
using handle = await page
|
||||||
await page.evaluate(() => {
|
.locator('textarea')
|
||||||
return new Promise(requestAnimationFrame);
|
.filterHandle(async element => {
|
||||||
});
|
return await element.evaluate((element, text) => {
|
||||||
await page.evaluate(() => {
|
return element.value === text;
|
||||||
return (document.querySelector('textarea')!.scrollTop = 0);
|
}, text);
|
||||||
});
|
})
|
||||||
|
.waitHandle();
|
||||||
const {x, y} = await page.evaluate(dimensions);
|
const {x, y} = await page.evaluate(dimensions);
|
||||||
await page.mouse.move(x + 2, y + 2);
|
await page.mouse.move(x + 2, y + 2);
|
||||||
await page.mouse.down();
|
await page.mouse.down();
|
||||||
await page.mouse.move(100, 100);
|
await page.mouse.move(100, 100);
|
||||||
await page.mouse.up();
|
await page.mouse.up();
|
||||||
expect(
|
expect(
|
||||||
await page.evaluate(() => {
|
await handle.evaluate(element => {
|
||||||
const textarea = document.querySelector('textarea')!;
|
return element.value.substring(
|
||||||
return textarea.value.substring(
|
element.selectionStart,
|
||||||
textarea.selectionStart,
|
element.selectionEnd
|
||||||
textarea.selectionEnd
|
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
).toBe(text);
|
).toBe(text);
|
||||||
|
Loading…
Reference in New Issue
Block a user