Files
jiapuapp/tests/g11-settings-data-contract.ps1
T
2026-07-23 08:24:07 +08:00

16 lines
1.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$page = Get-Content -LiteralPath (Join-Path $root 'pages/genealogy/g11-genealogy-settings.vue') -Raw -Encoding UTF8
foreach ($token in @('findGenealogyFixture', 'getGenealogyFixtureAccess', 'isGenealogyAccessPreset', 'GENEALOGY_ACCESS_PRESET', 'GENEALOGY_ACCESS_PRESET_OPTIONS', 'genealogyDraft.accessPreset', 'genealogyDraft.name.trim().length > 20', 'originalDraft', 'isDirty')) {
if (-not $page.Contains($token)) { throw "G11 settings data contract missing: $token" }
}
if ($page.Contains('settingsFixtures')) { throw 'G11 must not retain a private genealogy settings fixture owner' }
if ($page.Contains('GENEALOGY_VISIBILITY') -or $page.Contains('genealogyDraft.visibility')) { throw 'G11 retains the deleted visibility-only contract' }
if ($page -notmatch '(?s)if \(!isGenealogyAccessPreset\(fixture\.accessPreset\)\) \{\s*settingsState\.value = "error";\s*return;\s*\}') {
throw 'G11 must fail closed before loading an unknown access preset'
}
if ($page -match '(?s)accessPreset:\s*Object\.values\(GENEALOGY_ACCESS_PRESET\).*?:\s*GENEALOGY_ACCESS_PRESET\.MEMBER_ONLY') {
throw 'G11 must not silently downgrade an unknown access preset to MEMBER_ONLY'
}
Write-Output 'G11-SETTINGS-DATA-CONTRACT PASS'