From c94723563e516cd4561ca97e8511f2f01ea15658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Thu, 20 Mar 2025 21:37:41 +0100 Subject: [PATCH] Fix icons flaky --- packages/gitbook/e2e/util.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/gitbook/e2e/util.ts b/packages/gitbook/e2e/util.ts index ff9555c5ea..1307125c86 100644 --- a/packages/gitbook/e2e/util.ts +++ b/packages/gitbook/e2e/util.ts @@ -330,11 +330,6 @@ async function waitForIcons(page: Page) { throw new Error('Icon is not an SVGElement'); } - // If not visible, we don't care about loading state - if (!icon.checkVisibility()) { - return true; - } - // If loaded, good it passes the test. if (icon.dataset.loadingState === 'loaded') { return true; @@ -370,7 +365,12 @@ async function waitForIcons(page: Page) { const img = new Image(); img.src = url; img.decode().then(() => { - icon.dataset.loadingState = 'loaded'; + // Wait two frames to let the time to the icon to repaint. + requestAnimationFrame(() => { + requestAnimationFrame(() => { + icon.dataset.loadingState = 'loaded'; + }); + }); }); return false;