Files
jiapuapp/tests/g11-g12-settings-poems-contract.ps1
T
2026-07-21 07:53:08 +08:00

76 lines
2.9 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', 'border-radius')) {
if ($Content -match "(?s)\\.$ClassName\\s*\\{[^}]*\\b$property\\s*:") {
throw "G11-G12 must not construct .$ClassName with CSS $property"
}
}
}
$root = Split-Path -Parent $PSScriptRoot
$g11 = Get-Content -LiteralPath (Join-Path $root 'pages/genealogy/g11-genealogy-settings.vue') -Raw -Encoding utf8
$g12 = Get-Content -LiteralPath (Join-Path $root 'pages/genealogy/g12-generation-poems.vue') -Raw -Encoding utf8
$catalog = Get-Content -LiteralPath (Join-Path $root 'data/page-catalog.js') -Raw -Encoding utf8
foreach ($page in @($g11, $g12)) {
if ($page -match '<ModulePage') { throw 'G11-G12 must not retain the generic ModulePage shell' }
Assert-Contains $page '<GenealogyPageBackground />' 'G11-G12 must use the accepted shared genealogy background'
Assert-Contains $page 'g01-empty-panel-frame.png' 'G11-G12 forms must reuse the complete genealogy paper panel'
if ($page -match "@/utils/api\.js|\bappApi\b") { throw 'G11-G12 design phase must not connect the API layer' }
}
foreach ($required in @(
'const settingsState = ref("loading")',
'settings-state--form',
'settings-state--success',
'settings-state--error',
'settings-state--no-permission',
'const nameError = ref',
'class="settings-feedback"',
'g-form-field-frame.png',
'a01-scroll-primary-v3.png',
'const genealogyDraft',
'query.genealogyId',
'"MEMBER_ONLY"',
'"PUBLIC_APPLY"'
)) { Assert-Contains $g11 $required "Missing G11 settings contract: $required" }
foreach ($required in @(
'const poemState = ref("loading")',
'poem-state--list',
'poem-state--empty',
'poem-state--edit',
'poem-state--error',
'poem-state--no-permission',
'const poemError = ref',
'class="poem-feedback"',
'g-form-field-frame.png',
'a01-scroll-primary-v3.png',
'a01-scroll-secondary-v3.png',
'const poemRows',
'stopMissingOldGeneration',
'query.genealogyId'
)) { Assert-Contains $g12 $required "Missing G12 generation-poem contract: $required" }
foreach ($page in @($g11, $g12)) {
foreach ($nativeUi in @('uni.showToast', 'uni.showModal', 'uni.showLoading', 'uni.showActionSheet')) {
if ($page -match [regex]::Escape($nativeUi)) { throw "G11-G12 must not use native UniApp UI: $nativeUi" }
}
}
foreach ($className in @('settings-panel', 'settings-action', 'poem-row', 'poem-editor', 'poem-action')) {
foreach ($page in @($g11, $g12)) { Assert-NoCssSurface $page $className }
}
foreach ($entry in @('g11:', 'g12:')) {
if ($catalog -match [regex]::Escape($entry)) { throw "Page catalog must remove migrated generic entry: $entry" }
}
Write-Output 'G11-G12-SETTINGS-POEMS-CONTRACT PASS'