From 286c26d18b10caedf83191affd296fdeacb0b458 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 20 Sep 2026 13:51:05 +0300 Subject: [PATCH] =?UTF-8?q?test(docs):=20=D0=BF=D1=80=D0=BE=D0=BA=D1=80?= =?UTF-8?q?=D1=83=D1=87=D0=B8=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=8F=D1=89=D0=B8=D0=B9=20=D1=81=D0=BA=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D0=BB=D0=B5=D1=80=20=D0=BF=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= =?UTF-8?q?=20(#600)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit После #600 единственный скроллер диалога находится в shadow-root .content. Съёмка продолжала менять scrollTop у старой .body, поэтому обычный кадр устройства и кадр Display preview получались побайтово одинаковыми. Тест фиксирует владельца скролла и запрещает возврат к неработающей .body. Issue: #600 User-Visible: no --- demo/docs/capture.mjs | 12 ++++++------ test/capture-determinism-args.test.mjs | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/demo/docs/capture.mjs b/demo/docs/capture.mjs index ec2cd67b..0e65fd91 100644 --- a/demo/docs/capture.mjs +++ b/demo/docs/capture.mjs @@ -144,18 +144,18 @@ const applyDocumentationState = (page, scenario) => page.evaluate(async (current if (current.devicePresentationPreview) { const dialog = card.renderRoot.querySelector('hp-dialog'); - const body = dialog?.querySelector('.body'); + const scroller = dialog?.renderRoot?.querySelector('.content'); const preview = dialog?.querySelector('hp-device-preview'); await preview?.updateComplete; - if (!body || !preview) + if (!scroller || !preview) throw new Error('documentation device presentation preview is missing'); - const bodyRect = body.getBoundingClientRect(); + const scrollerRect = scroller.getBoundingClientRect(); const previewRect = preview.getBoundingClientRect(); - body.scrollTop += previewRect.top - bodyRect.top - 180; + scroller.scrollTop += previewRect.top - scrollerRect.top - 180; await frame(); - const visibleBody = body.getBoundingClientRect(); + const visibleScroller = scroller.getBoundingClientRect(); const visiblePreview = preview.getBoundingClientRect(); - if (visiblePreview.top < visibleBody.top - 1 || visiblePreview.bottom > visibleBody.bottom + 1) + if (visiblePreview.top < visibleScroller.top - 1 || visiblePreview.bottom > visibleScroller.bottom + 1) throw new Error('documentation viewport does not show the device presentation preview'); } diff --git a/test/capture-determinism-args.test.mjs b/test/capture-determinism-args.test.mjs index 5020b7e4..ee7019b1 100644 --- a/test/capture-determinism-args.test.mjs +++ b/test/capture-determinism-args.test.mjs @@ -36,3 +36,13 @@ test('съёмка берёт набор из этого модуля, а не assert.doesNotMatch(source, /const DETERMINISTIC_ARGS\s*=/, 'собственное объявление в capture.mjs разошлось бы с проверяемым набором'); }); + +test('#600 кадр превью крутит единственный скроллер hp-dialog', () => { + const source = readFileSync(new URL('../demo/docs/capture.mjs', import.meta.url), 'utf8'); + const block = source.match(/if \(current\.devicePresentationPreview\) \{([\s\S]*?)\n \}/)?.[1] || ''; + assert.match(block, /dialog\?\.renderRoot\?\.querySelector\('\.content'\)/, + 'после #600 скроллом владеет .content в shadow root оболочки'); + assert.match(block, /scroller\.scrollTop\s*\+=/); + assert.doesNotMatch(block, /querySelector\('\.body'\)/, + '.body больше не скроллер: такая съёмка даёт два одинаковых кадра'); +});