Files
jiapuapp/tests/a02-route-removal-contract.ps1
T
2026-07-15 17:23:33 +08:00

33 lines
1.3 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$pages = Get-Content -LiteralPath (Join-Path $root 'pages.json') -Raw -Encoding utf8 | ConvertFrom-Json
$legacyPage = Join-Path $root 'pages/auth/a02-login.vue'
if ($pages.pages.Count -ne 53) { throw "Expected 53 routes, found $($pages.pages.Count)." }
if ($pages.pages.path -contains 'pages/auth/a02-login') { throw 'Legacy A02 route still exists.' }
if (Test-Path -LiteralPath $legacyPage) { throw 'Legacy A02 page file still exists.' }
$ownedFiles = @(
'pages/auth/a01-entry.vue',
'pages/auth/a04-register.vue',
'pages/auth/a05-reset-password.vue',
'pages/auth/a06-auth-status.vue',
'scripts/capture-chrome-page.js'
)
foreach ($relativePath in $ownedFiles) {
$content = Get-Content -LiteralPath (Join-Path $root $relativePath) -Raw -Encoding utf8
if ($content -match '/pages/auth/a02-login') {
throw "Legacy A02 navigation remains in $relativePath."
}
}
foreach ($returnPage in @('pages/auth/a04-register.vue', 'pages/auth/a05-reset-password.vue', 'pages/auth/a06-auth-status.vue')) {
$content = Get-Content -LiteralPath (Join-Path $root $returnPage) -Raw -Encoding utf8
if ($content -notmatch [regex]::Escape("url: '/pages/auth/a01-entry'")) {
throw "$returnPage must return to A01."
}
}
Write-Output 'A02-ROUTE-REMOVAL-CONTRACT PASS'