From c5af1f2414c434665a2cb61eee1fc6173b438c24 Mon Sep 17 00:00:00 2001 From: rain Date: Tue, 21 Jul 2026 10:47:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81A01=E5=A4=9A=E8=A7=86?= =?UTF-8?q?=E5=8F=A3=E8=87=AA=E9=80=82=E5=BA=94=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/a01-responsive-runtime-smoke.js | 68 +++++++++++++++++++++------ 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/tests/a01-responsive-runtime-smoke.js b/tests/a01-responsive-runtime-smoke.js index 5b92dcf..dbab385 100644 --- a/tests/a01-responsive-runtime-smoke.js +++ b/tests/a01-responsive-runtime-smoke.js @@ -3,9 +3,11 @@ const assert = require('assert') const url = 'http://localhost:5173/#/pages/auth/a01-entry' const sizes = [ { width: 320, height: 568 }, + { width: 360, height: 616 }, { width: 360, height: 640 }, { width: 360, height: 800 }, - { width: 412, height: 915 } + { width: 412, height: 915 }, + { width: 480, height: 1040 } ] const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)) @@ -83,20 +85,44 @@ const run = async () => { await send('Page.reload') await waitForFreshDocument(send, previousTimeOrigin) await waitFor(send, "document.querySelectorAll('.login-tab').length === 2", `A01 did not render at ${size.width}x${size.height}`) - if (size.width === 320 && size.height === 568) { - await waitFor(send, "document.querySelector('.auth-page')?.scrollHeight > document.querySelector('.auth-page')?.clientHeight", 'A01 did not establish natural scrolling at 320x568') - } - - const metrics = await valueOf(send, `({ - innerWidth: window.innerWidth, - innerHeight: window.innerHeight, - scrollWidth: document.documentElement.scrollWidth, - scrollHeight: document.documentElement.scrollHeight, - pageClientHeight: document.querySelector('.auth-page')?.clientHeight, - pageScrollHeight: document.querySelector('.auth-page')?.scrollHeight - })`) + await waitFor(send, "document.querySelector('.auth-header__image img')?.naturalWidth === 824", `A01 header did not load at ${size.width}x${size.height}`) + const metrics = await valueOf(send, `(() => { + const root = document.querySelector('.auth-page') + const header = document.querySelector('.auth-header') + const headerImage = document.querySelector('.auth-header__image img') + const paper = document.querySelector('.auth-paper') + const content = document.querySelector('.login-content') + const headerRect = header?.getBoundingClientRect() + const paperRect = paper?.getBoundingClientRect() + const contentRect = content?.getBoundingClientRect() + return { + innerWidth: window.innerWidth, + innerHeight: window.innerHeight, + scrollWidth: document.documentElement.scrollWidth, + documentScrollHeight: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), + rootScrollHeight: root?.scrollHeight, + headerBottom: headerRect?.bottom, + headerImageWidth: headerImage?.getBoundingClientRect().width, + headerImageHeight: headerImage?.getBoundingClientRect().height, + headerNaturalWidth: headerImage?.naturalWidth, + headerNaturalHeight: headerImage?.naturalHeight, + paperTop: paperRect?.top, + contentTop: contentRect?.top, + agreementBottom: document.querySelector('.agreement-area')?.getBoundingClientRect().bottom + } + })()`) assert.strictEqual(metrics.innerWidth, size.width, `A01 viewport width mismatch at ${size.width}x${size.height}`) assert(metrics.scrollWidth <= size.width + 1, `A01 has horizontal overflow at ${size.width}x${size.height}: ${metrics.scrollWidth}`) + assert.deepStrictEqual([metrics.headerNaturalWidth, metrics.headerNaturalHeight], [824, 340], `A01 header asset mismatch at ${size.width}x${size.height}`) + assert(Math.abs(metrics.headerImageHeight / metrics.headerImageWidth - 340 / 824) < 0.01, `A01 header is distorted at ${size.width}x${size.height}`) + assert(metrics.paperTop >= metrics.headerBottom - 1, `A01 paper overlaps the header at ${size.width}x${size.height}`) + assert(metrics.contentTop >= metrics.paperTop, `A01 content escapes paper flow at ${size.width}x${size.height}`) + if (size.width >= 360 && size.height >= 640) { + assert(metrics.rootScrollHeight <= metrics.innerHeight + 1, `A01 password state must fit at ${size.width}x${size.height}`) + assert(metrics.agreementBottom <= metrics.innerHeight + 1, `A01 password agreement must remain visible at ${size.width}x${size.height}`) + } else { + assert(metrics.agreementBottom <= metrics.documentScrollHeight + 1, `A01 password agreement must remain reachable at ${size.width}x${size.height}`) + } const buttonAssets = await valueOf(send, `Array.from(document.querySelectorAll('.button-skin img')).map((image) => ({ src: image.currentSrc || image.src, @@ -111,9 +137,21 @@ const run = async () => { [[1866, 276], [1866, 300]], `A01 v3 button assets have unexpected runtime dimensions at ${size.width}x${size.height}` ) - if (size.width === 320 && size.height === 568) { - assert(metrics.pageScrollHeight > metrics.pageClientHeight, 'A01 must scroll naturally at 320x568') + await valueOf(send, "document.querySelectorAll('.login-tab')[1].click()") + await waitFor(send, "document.querySelectorAll('.login-tab')[1].classList.contains('active')", `A01 SMS tab did not activate at ${size.width}x${size.height}`) + const smsMetrics = await valueOf(send, `({ + documentScrollHeight: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), + rootScrollHeight: document.querySelector('.auth-page')?.scrollHeight, + agreementBottom: document.querySelector('.agreement-area')?.getBoundingClientRect().bottom + })`) + if (size.width >= 360 && size.height >= 640) { + assert(smsMetrics.rootScrollHeight <= metrics.innerHeight + 1, `A01 SMS state must fit at ${size.width}x${size.height}`) + assert(smsMetrics.agreementBottom <= metrics.innerHeight + 1, `A01 SMS agreement must remain visible at ${size.width}x${size.height}`) + } else { + assert(smsMetrics.agreementBottom <= smsMetrics.documentScrollHeight + 1, `A01 SMS agreement must remain reachable at ${size.width}x${size.height}`) } + await valueOf(send, "document.querySelectorAll('.login-tab')[0].click()") + await waitFor(send, "document.querySelectorAll('.login-tab')[0].classList.contains('active')", `A01 password tab did not reactivate at ${size.width}x${size.height}`) } await valueOf(send, "document.querySelector('.login-submit').click()")