Files
jiapuapp/tests/g05-overview-contract.ps1
T
2026-07-20 06:52:33 +08:00

60 lines
2.8 KiB
PowerShell

$ErrorActionPreference = 'Stop'
function Assert-Contains {
param([string]$Content, [string]$Expected, [string]$Message)
if ($Content -notmatch [regex]::Escape($Expected)) { throw $Message }
}
function Assert-NoCssSurface {
param([string]$Content, [string]$ClassName)
foreach ($property in @('border', 'background', 'border-radius')) {
if ($Content -match "(?s)\\.$ClassName\\s*\\{[^}]*\\b$property\\s*:") {
throw "G05 must not construct .$ClassName with CSS $property"
}
}
}
$root = Split-Path -Parent $PSScriptRoot
$g01 = Get-Content -LiteralPath (Join-Path $root 'pages/genealogy/g01-my-genealogies.vue') -Raw -Encoding utf8
$g05 = Get-Content -LiteralPath (Join-Path $root 'pages/genealogy/g05-genealogy-overview.vue') -Raw -Encoding utf8
$runtimeSmoke = Get-Content -LiteralPath (Join-Path $root 'tests/g05-overview-runtime-smoke.js') -Raw -Encoding utf8
$asset = Join-Path $root 'static/assets/modules/genealogy/opaque/g05-overview-surface.png'
Assert-Contains $g01 'g05-genealogy-overview?genealogyId=' 'G01 must open G05 with the genealogyId query contract'
if ($g01 -match 'g05-genealogy-overview\?id=') { throw 'G01 must not retain the obsolete G05 id query key' }
foreach ($required in @(
"const overviewState = ref('loading')",
"query.genealogyId",
"const viewMode = ref('member')",
"const accessRole = ref('owner')",
'const overviewFixture = {',
'overview-ready',
'overview-public',
'overview-state--empty',
'overview-state--error',
'overview-state--no-permission',
'g05-overview-surface.png',
'/pages/genealogy/g03-create-genealogy?step=ancestor&genealogyId=',
'/pages/tree/t01-tree-overview?genealogyId=',
'/pages/genealogy/g10-application-review?genealogyId=',
'/pages/genealogy/g11-genealogy-settings?genealogyId=',
'/pages/genealogy/g12-generation-poems?genealogyId=',
'/pages/family/f01-family-feed'
)) {
Assert-Contains $g05 $required "Missing G05 overview contract: $required"
}
foreach ($forbidden in @("from '@/utils/api.js'", 'appApi.', 'uni.showToast', 'uni.showModal', 'uni.showLoading', 'uni.showActionSheet')) {
if ($g05 -match [regex]::Escape($forbidden)) { throw "G05 retains forbidden implementation: $forbidden" }
}
if ($g05 -match 'g04-first-ancestor') { throw 'G05 must not navigate to the removed G04 route' }
if ($g05 -match 'toJoinApplication') { throw 'G05 must not mislabel the applicant join form as an owner invitation action' }
foreach ($className in @('overview-surface', 'overview-action', 'overview-state-panel')) {
Assert-NoCssSurface $g05 $className
}
if (-not (Test-Path -LiteralPath $asset)) { throw 'G05 requires final opaque asset: g05-overview-surface.png' }
Assert-Contains $runtimeSmoke 'waitForPageLoad' 'G05 runtime smoke must wait for the reload load event before DOM inspection'
Write-Output 'G05-OVERVIEW-CONTRACT PASS'