Files
jiapuapp/tests/auth-page-shell-contract.ps1
T
2026-07-21 12:08:15 +08:00

42 lines
1.6 KiB
PowerShell

$ErrorActionPreference = 'Stop'
function Assert-Contains {
param([string]$Content, [string]$Expected, [string]$Message)
if ($Content -notmatch [regex]::Escape($Expected)) { throw $Message }
}
function Assert-NotContains {
param([string]$Content, [string]$Unexpected, [string]$Message)
if ($Content -match [regex]::Escape($Unexpected)) { throw $Message }
}
$root = Split-Path -Parent $PSScriptRoot
$shellPath = Join-Path $root 'components/AuthPageShell.vue'
if (-not (Test-Path -LiteralPath $shellPath)) { throw 'AuthPageShell is missing' }
$shell = Get-Content -LiteralPath $shellPath -Raw -Encoding utf8
foreach ($required in @(
'class="auth-shell__header"',
'class="auth-shell__header-image"',
'a01-vnext-header-v1.png',
'mode="widthFix"',
'class="auth-shell__paper"',
'a01-red-hall-ink-backdrop-v1.png',
'auth-page-paper.jpg',
'background-position: center calc(-48.18vw), center top;',
'background-repeat: no-repeat, repeat-y;',
'<slot />',
'<slot name="overlay" />',
'min-height: var(--app-viewport-height);'
)) {
Assert-Contains -Content $shell -Expected $required -Message "AuthPageShell is missing: $required"
}
$page = Get-Content -LiteralPath (Join-Path $root 'pages/auth/a01-entry.vue') -Raw -Encoding utf8
Assert-Contains -Content $page -Expected '<AuthPageShell' -Message 'A01 must consume AuthPageShell'
foreach ($forbidden in @('class="page-canvas"', 'class="page-backdrop"', 'mode="scaleToFill"', '1665rpx')) {
Assert-NotContains -Content $page -Unexpected $forbidden -Message "A01 retains rejected page coordinates: $forbidden"
}
Write-Output 'AUTH-PAGE-SHELL-CONTRACT PASS'