diff --git a/tests/a05-reset-password-contract.ps1 b/tests/a05-reset-password-contract.ps1 index ccceb3d..832a1d3 100644 --- a/tests/a05-reset-password-contract.ps1 +++ b/tests/a05-reset-password-contract.ps1 @@ -29,8 +29,8 @@ $sliderPendingCopy = ConvertFrom-Utf8Base64 '5ruR5Yqo6aqM6K+B5b6F5o6l5Y+j5o6l5YW if (-not ($pages.pages.path -contains 'pages/auth/a05-reset-password')) { throw 'A-05 route must remain declared in pages.json' } Assert-NotContains -Content $page -Unexpected 'ModulePage' -Message 'A-05 must not remain a ModulePage shell' foreach ($required in @( - 'a01-red-hall-ink-backdrop-v1.png', - 'brand-seal.png', + '.*?)^\}') +if (-not $contentRule.Success) { throw 'A05 reset content rule is missing.' } +foreach ($required in @('display: flex;', 'flex: 1;', 'flex-direction: column;', 'max-width: 480px;', 'margin: 0 auto;')) { + Assert-Contains -Content $contentRule.Groups['Body'].Value -Expected $required -Message "A05 reset content must use document flow: $required" +} + +$headingRule = [regex]::Match($page, '(?ms)^\.page-heading\s*\{(?.*?)^\}') +if (-not $headingRule.Success) { throw 'A05 page heading rule is missing.' } +Assert-Contains -Content $headingRule.Groups['Body'].Value -Expected 'grid-template-columns: minmax(0, 1fr);' -Message 'A05 heading must center against the full content width.' +foreach ($selector in @('page-title', 'page-subtitle', 'reset-divider')) { + $rule = [regex]::Match($page, "(?ms)^\.$selector\s*\{(?.*?)^\}") + if (-not $rule.Success) { throw "A05 heading child rule is missing: $selector" } + Assert-Contains -Content $rule.Groups['Body'].Value -Expected 'grid-column: 1;' -Message "A05 heading child must remain in the full-width grid column: $selector" +} + Write-Output 'A05-RESET-PASSWORD-CONTRACT PASS' diff --git a/tests/a05-reset-password-runtime-smoke.js b/tests/a05-reset-password-runtime-smoke.js index 92a7be8..91af0f0 100644 --- a/tests/a05-reset-password-runtime-smoke.js +++ b/tests/a05-reset-password-runtime-smoke.js @@ -78,16 +78,42 @@ const run = async () => { await valueOf(send, "document.querySelector('.forgot-password').click()") await waitFor(send, "location.href.includes('/pages/auth/a05-reset-password')", 'A01 forgot-password entry did not open A05') - for (const size of [{ width: 320, height: 568 }, { width: 360, height: 640 }, { width: 360, height: 800 }, { width: 412, height: 915 }]) { + for (const size of [ + { width: 320, height: 568 }, + { width: 360, height: 616 }, + { width: 360, height: 640 }, + { width: 360, height: 800 }, + { width: 412, height: 915 }, + { width: 480, height: 1040 } + ]) { await send('Emulation.setDeviceMetricsOverride', { ...size, deviceScaleFactor: 1, mobile: true }) await navigate(send, a05Url, '.reset-submit') - const metrics = await valueOf(send, `({ - width: document.documentElement.scrollWidth, - pageClientHeight: document.querySelector('.auth-page').clientHeight, - pageScrollHeight: document.querySelector('.auth-page').scrollHeight - })`) + await waitFor(send, "document.querySelector('.auth-shell__header-image img')?.naturalWidth === 824", `A05 header did not load at ${size.width}x${size.height}`) + const metrics = await valueOf(send, `(() => { + const header = document.querySelector('.auth-shell__header') + const headerImage = document.querySelector('.auth-shell__header-image img') + const paper = document.querySelector('.auth-shell__paper') + const title = document.querySelector('.page-title') + const loginEntry = document.querySelector('.login-entry') + return { + width: document.documentElement.scrollWidth, + documentScrollHeight: Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), + headerBottom: header?.getBoundingClientRect().bottom, + headerImageWidth: headerImage?.getBoundingClientRect().width, + headerImageHeight: headerImage?.getBoundingClientRect().height, + headerNaturalWidth: headerImage?.naturalWidth, + headerNaturalHeight: headerImage?.naturalHeight, + paperTop: paper?.getBoundingClientRect().top, + titleCenter: title ? title.getBoundingClientRect().left + title.getBoundingClientRect().width / 2 : null, + loginEntryBottom: loginEntry?.getBoundingClientRect().bottom + window.scrollY + } + })()`) assert(metrics.width <= size.width + 1, `A05 has horizontal overflow at ${size.width}x${size.height}`) - if (size.width === 320) assert(metrics.pageScrollHeight > metrics.pageClientHeight, 'A05 must scroll naturally at 320x568') + assert.deepStrictEqual([metrics.headerNaturalWidth, metrics.headerNaturalHeight], [824, 340], `A05 header asset changed at ${size.width}x${size.height}`) + assert(Math.abs(metrics.headerImageHeight / metrics.headerImageWidth - 340 / 824) < 0.01, `A05 header is distorted at ${size.width}x${size.height}`) + assert(metrics.paperTop >= metrics.headerBottom - 1, `A05 paper overlaps its header at ${size.width}x${size.height}`) + assert(Math.abs(metrics.titleCenter - size.width / 2) <= 1, `A05 title is not centered at ${size.width}x${size.height}: ${metrics.titleCenter}`) + assert(metrics.loginEntryBottom <= metrics.documentScrollHeight + 1, `A05 last action is unreachable at ${size.width}x${size.height}`) } await valueOf(send, "document.querySelector('.get-code').click()")