Wait for selector instead of timeout in the freetext double click move integration test

This integration test currently fails intermittently on the bots because
of the fixed timeout in the test, which is sometimes too low on slower
systems. The issue can be reproduced 100% of the time by introducing a
delay just before dispatching the `switchannotationeditormode` event.

Puppeteer also discourages this and instead recommends waiting for a
selector instead, which we now do here. This ensures that the test only
continues if the element under test is available and therefore prevents
any timing problems.
This commit is contained in:
Tim van der Meij 2023-09-17 18:49:11 +02:00
parent 97819891b6
commit 1b3ccf1321
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

@ -1176,7 +1176,7 @@ describe("FreeText Editor", () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.click("[data-annotation-id='26R']", { clickCount: 2 });
await page.waitForTimeout(10);
await page.waitForSelector(`${getEditorSelector(0)}-editor`);
const [focusedId, editable] = await page.evaluate(() => {
const el = document.activeElement;