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 больше не скроллер: такая съёмка даёт два одинаковых кадра'); +});