Files
jiapuapp/tests/a06-auth-status-contract.ps1
T
2026-07-14 17:36:43 +08:00

61 lines
2.3 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
$page = Get-Content -LiteralPath (Join-Path $root 'pages/auth/a06-auth-status.vue') -Raw -Encoding utf8
$pages = Get-Content -LiteralPath (Join-Path $root 'pages.json') -Raw -Encoding utf8 | ConvertFrom-Json
$catalog = Get-Content -LiteralPath (Join-Path $root 'data/page-catalog.js') -Raw -Encoding utf8
if (-not ($pages.pages.path -contains 'pages/auth/a06-auth-status')) { throw 'A-06 route must remain declared in pages.json' }
if (-not ($pages.pages.path -contains 'pages/auth/a02-login')) { throw 'A-06 must retain the A02 return target' }
if (-not ($pages.pages.path -contains 'pages/auth/a04-register')) { throw 'A-06 must retain the A04 registration target' }
Assert-NotContains -Content $page -Unexpected 'ModulePage' -Message 'A-06 must not remain a ModulePage shell'
Assert-NotContains -Content $catalog -Unexpected 'a06:' -Message 'A-06 must not remain in the temporary page catalog'
foreach ($required in @(
"const status = ref('normal')",
"const statusConfig = {",
'normal:',
'failed:',
'restricted:',
"'register-pending':",
"'wechat-cancelled':",
"'wechat-failed':",
'const resolveStatus = () =>',
'const goLogin = () =>',
'const goRegister = () =>',
'const handlePrimary = () =>',
'const goBack = () =>',
'auth-header.png',
'brand-seal.png',
'a02-login-panel.png',
'a01-primary-button.png',
'auth-title-cloud.png',
'auth-divider-knot.png',
'chevron-right.png',
'auth-login-outline.png'
)) {
Assert-Contains -Content $page -Expected $required -Message "Missing A-06 auth-status contract: $required"
}
foreach ($forbidden in @(
'(?s)\.status-panel\s*\{[^}]*\bborder\s*:',
'(?s)\.status-panel\s*\{[^}]*\bbackground\s*:',
'(?s)\.status-primary\s*\{[^}]*\bborder\s*:',
'(?s)\.status-primary\s*\{[^}]*\bbackground\s*:'
)) {
if ($page -match $forbidden) { throw "A-06 retains forbidden CSS visual construction: $forbidden" }
}
Write-Output 'A06-AUTH-STATUS-CONTRACT PASS'