Files
jiapuapp/tests/r02-person-detail-contract.ps1
T

36 lines
2.6 KiB
PowerShell

$ErrorActionPreference = 'Stop'
function Read-Utf8([string]$Path) { [System.IO.File]::ReadAllText((Join-Path (Join-Path $PSScriptRoot '..') $Path), [System.Text.Encoding]::UTF8) }
function Assert-Contains([string]$Content,[string]$Expected) { if (-not $Content.Contains($Expected)) { throw "R02 contract missing: $Expected" } }
$page = Read-Utf8 'pages/records/r02-person-detail.vue'
$profiles = Read-Utf8 'styles/adaptive-frame-profiles.scss'
$catalog = Read-Utf8 'data/page-catalog.js'
foreach ($expected in @(
'class="person-detail-page"','person-detail-state--','class="person-identity-card"',
'class="person-edit-action"','class="person-save-action"','class="person-cancel-action"',
'shortFields','longFields','person-field__label','person-long-field__label','const enterEdit = () =>','const savePerson = () =>',
'const returnToPeople = () =>','@include adaptive.adaptive-records-person;','@include adaptive.adaptive-records-content;','@include adaptive.adaptive-records-field;',
'ModulePageBackground','PageHeader','AppButton','AppLoading','AppToast'
)) { Assert-Contains $page $expected }
foreach ($forbidden in @('<ModulePage page-id="r02"','import ModulePage from')) { if ($page.Contains($forbidden)) { throw "R02 retains forbidden dependency: $forbidden" } }
if ($catalog -match '(?m)^\s*r02\s*:') { throw 'R02 obsolete page-catalog owner must be removed' }
foreach ($forbidden in @('<image class="person-card-skin"','.person-card-skin')) {
if ($page.Contains($forbidden)) { throw "R02 must use container backgrounds instead of positioned decorative skins: $forbidden" }
}
if ($page -match '(?im)(?<![-\w])position\s*:') {
throw 'R02 must not contain position declarations'
}
foreach ($rule in @(
'(?s)\.person-detail-page\s*\{[^}]*display:\s*flex;[^}]*flex-direction:\s*column;',
'(?s)\.person-detail-header,\.person-detail-loading,\.person-detail-content\s*\{[^}]*z-index:\s*1;',
'(?s)\.person-identity-card\s*\{[^}]*@include\s+adaptive\.adaptive-records-person\s*;',
'(?s)\.person-archive-card,\.person-long-field,\.person-state-card\s*\{[^}]*@include\s+adaptive\.adaptive-records-content\s*;',
'(?s)\.person-field\s*\{[^}]*@include\s+adaptive\.adaptive-records-field\s*;'
)) {
if ($page -notmatch $rule) { throw "R02 adaptive document-flow rule missing: $rule" }
}
foreach ($owner in @('r01-person-name-card.png','module-content-frame.png','module-field-frame.png')) {
if (-not $profiles.Contains($owner)) { throw "R02 adaptive profile owner missing: $owner" }
}
if ($page -match '100%\s+100%\s+no-repeat|border-image-slice\s*:') { throw 'R02 must consume adaptive frame geometry without page-local stretching or slicing' }
Write-Output 'R02-PERSON-DETAIL-CONTRACT PASS'