39 lines
2.6 KiB
PowerShell
39 lines
2.6 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 = @{
|
|
T01 = Read-Page 'pages/tree/t01-tree-overview.vue'
|
|
T03 = Read-Page 'pages/tree/t03-member-profile.vue'
|
|
T07 = Read-Page 'pages/tree/t07-member-directory.vue'
|
|
F01 = Read-Page 'pages/family/f01-family-feed.vue'
|
|
N01 = Read-Page 'pages/notification/n01-message-center.vue'
|
|
}
|
|
|
|
foreach ($entry in $pages.GetEnumerator()) {
|
|
Assert-Match -Content $entry.Value -Pattern 'import AppLoading from\s*[''"]@/components/AppLoading\.vue[''"]' -Message "$($entry.Key) must import AppLoading"
|
|
}
|
|
|
|
Assert-Match -Content $pages.T01 -Pattern '<AppLoading\s+v-if="treeState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'T01 must render AppLoading before its tree and state cards'
|
|
Assert-Match -Content $pages.T03 -Pattern '<AppLoading\s+v-if="memberState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'T03 must render AppLoading before detail and error states'
|
|
Assert-Match -Content $pages.T07 -Pattern '<AppLoading\s+v-if="directoryState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'T07 must render AppLoading before list and state cards'
|
|
Assert-Match -Content $pages.F01 -Pattern '<AppLoading\s+v-if="feedState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'F01 must render AppLoading before feed content'
|
|
Assert-Match -Content $pages.N01 -Pattern '<AppLoading\s+v-if="noticeState === ''loading''"[^>]+description="[^"]+"\s*/>' -Message 'N01 must render AppLoading before message content'
|
|
|
|
Assert-Match -Content $pages.T01 -Pattern 'query\.state\s*===\s*["'']loading["'']' -Message 'T01 must preserve its loading presentation state'
|
|
Assert-Match -Content $pages.T03 -Pattern '(?s)if\s*\(query\.state\s*===\s*["'']loading["'']\)\s*\{[^}]*memberState\.value\s*=\s*["'']loading["'']' -Message 'T03 must preserve its loading presentation state'
|
|
Assert-Match -Content $pages.T07 -Pattern 'query\.state\s*===\s*["'']loading["'']\s*\?\s*["'']loading["'']' -Message 'T07 must preserve its loading presentation state'
|
|
Assert-Match -Content $pages.F01 -Pattern 'query\.state\s*===\s*["'']loading["'']\s*\?\s*["'']loading["'']' -Message 'F01 must preserve its loading presentation state'
|
|
Assert-Match -Content $pages.N01 -Pattern 'query\.state\s*===\s*["'']loading["'']\s*\?\s*["'']loading["'']' -Message 'N01 must preserve its loading presentation state'
|
|
|
|
Write-Output 'MODULE-APP-LOADING-CONTRACT PASS'
|