Files
jiapuapp/tests/f05-expired-state-contract.ps1
T
2026-07-20 17:23:13 +08:00

44 lines
1.4 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 {
param([string]$Content, [string]$Expected, [string]$Message)
if (-not $Content.Contains($Expected)) { throw $Message }
}
function Decode-Utf8Base64([string]$Value) {
[System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($Value))
}
$catalog = Read-Utf8 'data/page-catalog.js'
$module = Read-Utf8 'components/ModulePage.vue'
foreach ($expected in @(
'states: {',
"eyebrow: '$(Decode-Utf8Base64 '6LCx5paH5bey5aSx5pWI')'",
"title: '$(Decode-Utf8Base64 '6L+Z56+H6LCx5paH5bey5peg5rOV5p+l55yL')'",
"copy: '$(Decode-Utf8Base64 '5YaF5a655Y+v6IO95bey6KKr5L2c6ICF5Yig6Zmk5oiW5Y+W5raI5YWs5byA77yM6K+36L+U5Zue6LCx5paH5YiX6KGo5p+l55yL5YW25LuW5YaF5a6544CC')'",
"action: '$(Decode-Utf8Base64 '6L+U5Zue6LCx5paH5YiX6KGo')'",
"actionMode: 'back'"
)) {
Assert-Contains $catalog $expected "F05 expired-state catalog contract missing: $expected"
}
foreach ($expected in @(
'page.value.states?.[moduleState.value]',
'@click="handleStateAction"',
'const handleStateAction = () => {',
'stateCopy.value.actionMode === "back"',
'uni.navigateBack()'
)) {
Assert-Contains $module $expected "ModulePage state override contract missing: $expected"
}
Write-Output 'F05-EXPIRED-STATE-CONTRACT PASS'