From 3f51da147cb93b34f8769dfe3e463cfae397bfd2 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 18 Apr 2024 15:22:58 +0200 Subject: [PATCH 1/2] Remove `waitForTimeout` usage from the `clearInput` helper function We should wait until the input field's value is actually empty instead of waiting for a fixed time (which could lead to intermittent failures). --- test/integration/test_utils.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 18d8b9540..909b2e31e 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -115,8 +115,9 @@ async function clearInput(page, selector) { await page.click(selector); await kbSelectAll(page); await page.keyboard.press("Backspace"); - // eslint-disable-next-line no-restricted-syntax - await waitForTimeout(10); + await page.waitForFunction( + `document.querySelector('${selector}').value === ""` + ); } function getSelector(id) { From c2e9a6264c9cb1f4073309fd87ecfa7cc70a1068 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 18 Apr 2024 15:31:01 +0200 Subject: [PATCH 2/2] Remove `waitForTimeout` usage from the `dragAndDropAnnotation` helper function The timeout was introduced in commit 402e3fe with equal timeouts around the helper function call. In commit 55e5af2 the timeouts around the helper function call have been removed, and it looks like the helper function itself was not updated purely due to an oversight. The operations here should not require any timeouts because the promises only resolve once the action is completed, which also explains why removing the timeouts surrounding the helper function calls went without any problems. It should therefore be safe to remove this timeout too. --- test/integration/test_utils.mjs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/integration/test_utils.mjs b/test/integration/test_utils.mjs index 909b2e31e..71983fa3d 100644 --- a/test/integration/test_utils.mjs +++ b/test/integration/test_utils.mjs @@ -355,8 +355,6 @@ async function serializeBitmapDimensions(page) { async function dragAndDropAnnotation(page, startX, startY, tX, tY) { await page.mouse.move(startX, startY); await page.mouse.down(); - // eslint-disable-next-line no-restricted-syntax - await waitForTimeout(10); await page.mouse.move(startX + tX, startY + tY); await page.mouse.up(); await page.waitForSelector("#viewer:not(.noUserSelect)");