From a945ca473be219fa2cc20219367e9ee1deea5534 Mon Sep 17 00:00:00 2001 From: Matysh Date: Sun, 30 Aug 2026 17:51:13 +0300 Subject: [PATCH] test: wait for settled camera in docs capture Issue: #82 User-Visible: no --- demo/docs/capture.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/demo/docs/capture.mjs b/demo/docs/capture.mjs index 04421697..96696379 100644 --- a/demo/docs/capture.mjs +++ b/demo/docs/capture.mjs @@ -86,6 +86,15 @@ const applyDocumentationState = (page, scenario) => page.evaluate(async (current const frame = () => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))); const card = window.__goldenCard; if (!card) throw new Error(`documentation card is missing: ${current.id}`); + const settleCamera = async () => { + const started = performance.now(); + do { await frame(); } + while (card._cameraTransition?.active && performance.now() - started < 1200); + if (card._cameraTransition?.active) + throw new Error(`documentation camera did not settle: ${current.id}`); + // One quiet pair proves that the settled reactive frame reached layout. + await frame(); + }; if (current.title) { card.setConfig({ ...card._config, title: current.title }); @@ -142,6 +151,7 @@ const applyDocumentationState = (page, scenario) => page.evaluate(async (current throw new Error('documentation viewport does not show the device presentation preview'); } + await settleCamera(); return { dialog: !!card.renderRoot.querySelector('hp-dialog') }; }, scenario);