Files
jiapuapp/tests/f08-album-detail-contract.ps1
T
2026-07-23 08:24:07 +08:00

63 lines
2.2 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 }
}
$page = Read-Utf8 'pages/family/f08-album-detail.vue'
foreach ($expected in @(
'class="album-detail-page"',
'album-state--${albumState}',
'class="album-hero-photo"',
'class="album-photo-grid"',
'class="album-preview"',
'class="album-upload-action"',
'const albumState = ref("normal");',
'const photos = ref([]);',
'findFamilyAlbumFixture(genealogyId.value, albumId.value)',
'const openPreview = (index) =>',
'const closePreview = () =>',
'const toUpload = () =>',
'"F09"',
'genealogyId: genealogyId.value, albumId: albumId.value',
'query.state === "empty"',
'query.state === "preview"',
'query.state === "expired"',
'class="album-empty-state"',
'class="album-expired-state"',
'class="album-preview__position"',
':alt="photo.alt"',
'transientOpen: previewVisible.value',
'onBackPress((event) => handleBackPress(event, requestBack));',
'ModulePageBackground',
'PageHeader',
'AppButton'
)) {
Assert-Contains $page $expected "F08 contract missing: $expected"
}
foreach ($forbidden in @('<ModulePage page-id="f08"', 'import ModulePage from', 'uni.showToast', 'uni.showModal', 'uni.navigateTo', 'uni.redirectTo', '/pages/')) {
if ($page.Contains($forbidden)) { throw "F08 retains forbidden dependency: $forbidden" }
}
foreach ($requiredPosition in @(
'(?s)\.album-photo-tile\s*\{[^}]*position:\s*relative;',
'(?s)\.album-hero-photo,\s*\.album-photo-tile__image\s*\{[^}]*position:\s*absolute;',
'(?s)\.album-photo-tile__caption\s*\{[^}]*position:\s*absolute;',
'(?s)\.album-preview\s*\{[^}]*position:\s*fixed;'
)) {
if ($page -notmatch $requiredPosition) { throw "F08 required local overlay boundary missing: $requiredPosition" }
}
if ([regex]::Matches($page, 'position\s*:').Count -ne 4) { throw 'F08 must keep only its photo-tile overlays and full-screen preview positioned' }
Write-Output 'F08-ALBUM-DETAIL-CONTRACT PASS'