Files
jiapuapp/tests/g-series-app-loading-contract.ps1
T

42 lines
3.0 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
function Read-Page([string]$Path) {
Get-Content -LiteralPath (Join-Path $root $Path) -Raw -Encoding utf8
}
function Assert-Match {
param([string]$Content, [string]$Pattern, [string]$Message)
if ($Content -notmatch $Pattern) { throw $Message }
}
$pages = @{
G05 = Read-Page 'pages/genealogy/g05-genealogy-overview.vue'
G06 = Read-Page 'pages/genealogy/g06-search-genealogies.vue'
G09 = Read-Page 'pages/genealogy/g09-my-applications.vue'
G10 = Read-Page 'pages/genealogy/g10-application-review.vue'
G11 = Read-Page 'pages/genealogy/g11-genealogy-settings.vue'
G12 = Read-Page 'pages/genealogy/g12-generation-poems.vue'
}
foreach ($entry in $pages.GetEnumerator()) {
Assert-Match -Content $entry.Value -Pattern 'import AppLoading from [''"]@/components/AppLoading\.vue[''"]' -Message "$($entry.Key) must import AppLoading"
}
Assert-Match -Content $pages.G05 -Pattern 'v-else-if="overviewState === ''loading''"\s+class="overview-state overview-state--loading"' -Message 'G05 must retain its transparent framed loading branch'
Assert-Match -Content $pages.G05 -Pattern '(?s)<AppLoading\s+[^>]*description="[^"]+"[^>]*/>' -Message 'G05 must render AppLoading with a loading description'
Assert-Match -Content $pages.G06 -Pattern '<AppLoading\s+v-if="searchState === ''loading''"\s+variant="section"[^>]+description="[^"]+"\s*/>' -Message 'G06 search results must render the section AppLoading variant'
Assert-Match -Content $pages.G06 -Pattern 'query\?\.state\s*===\s*["'']loading["'']' -Message 'G06 must expose its native section loading state for visual review'
Assert-Match -Content $pages.G09 -Pattern '<AppLoading\s+v-else-if="applicationState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'G09 must render a page AppLoading branch'
Assert-Match -Content $pages.G10 -Pattern '<AppLoading\s+v-else-if="reviewState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'G10 must render a page AppLoading branch'
Assert-Match -Content $pages.G11 -Pattern '<AppLoading\s+v-if="settingsState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'G11 must render a page AppLoading branch'
Assert-Match -Content $pages.G12 -Pattern '<AppLoading\s+v-if="poemState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'G12 must render a page AppLoading branch'
Assert-Match -Content $pages.G10 -Pattern 'query\.state\s*===\s*["'']loading["'']' -Message 'G10 must preserve its loading presentation state'
Assert-Match -Content $pages.G11 -Pattern 'query\.state\s*===\s*["'']loading["'']\s*\?\s*["'']loading["'']' -Message 'G11 must preserve its loading presentation state'
Assert-Match -Content $pages.G12 -Pattern 'query\.state\s*===\s*["'']loading["'']\s*\?\s*["'']loading["'']' -Message 'G12 must preserve its loading presentation state'
if ($pages.G06 -match 'class="search-status search-loading"') { throw 'G06 must not retain its duplicated text-only search loader' }
Write-Output 'G-SERIES-APP-LOADING-CONTRACT PASS'