Files
jiapuapp/tests/native-route-query-contract.ps1
T

30 lines
1.2 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$activeFiles = @(
'pages/genealogy/g01-my-genealogies.vue',
'pages/genealogy/g03-create-genealogy.vue',
'pages/genealogy/g06-search-genealogies.vue'
)
foreach ($file in $activeFiles) {
$source = Get-Content $file -Raw -Encoding UTF8
foreach ($forbidden in @('location.hash', 'new URLSearchParams', 'hashchange')) {
if ($source.Contains($forbidden)) {
throw "$file must not read native route state through $forbidden"
}
}
if ($source -notmatch 'onLoad\s*\(\s*\(?\s*query\b') {
throw "$file must consume its native query through onLoad(query)"
}
}
$g01 = Get-Content 'pages/genealogy/g01-my-genealogies.vue' -Raw -Encoding UTF8
$g03 = Get-Content 'pages/genealogy/g03-create-genealogy.vue' -Raw -Encoding UTF8
$g06 = Get-Content 'pages/genealogy/g06-search-genealogies.vue' -Raw -Encoding UTF8
if ($g01 -notmatch 'query\?\.state') { throw 'G01 must normalize presentation state from onLoad query' }
if ($g03 -notmatch 'query\?\.step\s*===\s*"ancestor"') { throw 'G03 must whitelist the ancestor step from onLoad query' }
if ($g06 -notmatch 'query\?\.mode\s*===\s*"invite"') { throw 'G06 must whitelist invite mode from onLoad query' }
Write-Output 'NATIVE-ROUTE-QUERY-CONTRACT PASS'