From 1c949ae49d6793a9df7c2b045015059a1287fa44 Mon Sep 17 00:00:00 2001 From: Matysh Date: Fri, 7 Aug 2026 14:39:24 +0300 Subject: [PATCH] test: poll navigation background transitions --- demo/smoke_bg_color.mjs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/demo/smoke_bg_color.mjs b/demo/smoke_bg_color.mjs index cba903c3..e830e27b 100644 --- a/demo/smoke_bg_color.mjs +++ b/demo/smoke_bg_color.mjs @@ -13,6 +13,15 @@ const res = await page.evaluate(async () => { await c.updateComplete; return getComputedStyle(sr().querySelector('.stage')).backgroundColor; }; + const waitStageBg = async (accept) => { + const deadline = performance.now() + 700; + let value = await stageBg(); + while (!accept(value) && performance.now() < deadline) { + await new Promise((resolve) => setTimeout(resolve, 25)); + value = await stageBg(); + } + return value; + }; const rgb = (hex) => `rgb(${parseInt(hex.slice(1, 3), 16)}, ${parseInt(hex.slice(3, 5), 16)}, ${parseInt(hex.slice(5, 7), 16)})`; const themeBg = await stageBg(); // theme default from the stylesheet @@ -81,12 +90,10 @@ const res = await page.evaluate(async () => { // 8) editors keep their own canvas (inline bg only in view/kiosk) c._setMode('decor'); - await new Promise((resolve) => setTimeout(resolve, 220)); - const editorBg = await stageBg(); + const editorBg = await waitStageBg((value) => value !== rgb('#0a2a4a')); out.editorUnpainted = editorBg !== rgb('#0a2a4a'); c._setMode('view'); - await new Promise((resolve) => setTimeout(resolve, 220)); - out.viewPaintedAgain = (await stageBg()) === rgb('#0a2a4a'); + out.viewPaintedAgain = (await waitStageBg((value) => value === rgb('#0a2a4a'))) === rgb('#0a2a4a'); // 9) kiosk instance respects the setting const k = document.createElement('houseplan-card');