From 6c49c2aa227e2fc2f215a226ddd965808f5cf436 Mon Sep 17 00:00:00 2001 From: Tom-Neverwinter <3943634+Tom-Neverwinter@users.noreply.github.com> Date: Thu, 10 Sep 2026 15:10:05 -0500 Subject: [PATCH] fix(qa): de-flake the Esri fallback check's fixed 50ms DOM settle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last fixed sleep in this harness: after the controller commits `activeId = 'osm'`, the fallback callback re-syncs the chips and Cesium drops the "Powered by Esri" credit on a later render frame again. A flat 50ms covered that most runs and not a slow one — observed failing once in 12 runs on Windows with `creditVisible: true` after the fallback. Same root cause and same remedy as the tray timers above: poll the observable truth (credit gone AND the pressed chip is osm), bounded at 3s, instead of guessing a duration. 0 failures in 15 consecutive runs after this, against 1-in-12 before. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01C3eGYgDYBo2BCUeDGwGvrp --- scripts/qa-map-source-tray.mjs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/qa-map-source-tray.mjs b/scripts/qa-map-source-tray.mjs index 9826b952e..76e88fb42 100644 --- a/scripts/qa-map-source-tray.mjs +++ b/scripts/qa-map-source-tray.mjs @@ -158,9 +158,18 @@ try { await new Promise((resolve) => setTimeout(resolve, 25)); } // The controller commits `activeId` before its fallback promise callback - // emits the terminal error state that re-syncs the chips. Give that - // callback one turn so the DOM assertion observes the completed contract. - await new Promise((resolve) => setTimeout(resolve, 50)); + // emits the terminal error state that re-syncs the chips, and Cesium drops + // the Esri credit on a later render frame again. A fixed delay races both: + // 50ms was enough most runs and not enough on a slow one, which is the same + // flake as the tray timers above (#54). Poll the observable truth instead. + const domDeadline = performance.now() + 3000; + const settled = () => !document.body.innerText.includes('Powered by Esri') + && [...document.querySelectorAll('.map-stack-chip')] + .filter((chip) => chip.getAttribute('aria-pressed') === 'true') + .every((chip) => chip.dataset.stackId === 'osm'); + while (!settled() && performance.now() < domDeadline) { + await new Promise((resolve) => setTimeout(resolve, 25)); + } const afterTwo = { activeId: controller.getActiveId(), lastError: controller.getState().lastError,