Files
jiapuapp/tests/f09-media-upload-contract.ps1
T

83 lines
2.7 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/f09-media-upload.vue'
$catalog = Read-Utf8 'data/page-catalog.js'
foreach ($expected in @(
'class="media-upload-page"',
'media-upload-state--${uploadState}',
'class="media-album-card"',
'class="media-photo-grid"',
'class="media-add-tile"',
'class="media-batch-field"',
'class="media-photo-field"',
'class="media-photo-editor"',
'class="media-photo-editor__thumb"',
'class="media-photo-editor__position"',
'<textarea',
'auto-height',
'const MAX_PHOTOS = 9;',
'const selectMockPhotos = () =>',
'const selectPhoto = (index) =>',
'const removePhoto = (index) =>',
'const addMockPhoto = () =>',
'const updateActiveNote = (event) =>',
'const startUpload = () =>',
'const retryFailed = () =>',
'const returnToAlbum = () =>',
'["permission", "selected", "uploading", "error", "success"].includes(query.state)',
'class="media-permission-action"',
'class="media-photo-status media-photo-status--error"',
'class="media-success-title"',
'class="media-progress-copy"',
'class="media-primary-action"',
'class="media-retry-action"',
'f08-reunion-hero.png',
'f08-family-portrait.png',
'f08-reunion-table.png',
'f08-ancestral-home.png',
'f08-ancestral-portrait.png',
'ModulePageBackground',
'PageHeader',
'AppButton'
)) {
Assert-Contains $page $expected "F09 contract missing: $expected"
}
foreach ($forbidden in @(
'<ModulePage page-id="f09"',
'import ModulePage from',
'uni.chooseMedia',
'uni.showModal'
)) {
if ($page.Contains($forbidden)) { throw "F09 retains forbidden dependency: $forbidden" }
}
foreach ($requiredPosition in @(
'(?s)\.media-photo-tile\s*\{[^}]*position:\s*relative;',
'(?s)\.media-photo-order,\s*\.media-photo-current,\s*\.media-photo-status\s*\{[^}]*position:\s*absolute;',
'(?s)\.media-photo-remove\s*\{[^}]*position:\s*absolute;'
)) {
if ($page -notmatch $requiredPosition) { throw "F09 required thumbnail overlay boundary missing: $requiredPosition" }
}
if ([regex]::Matches($page, 'position\s*:').Count -ne 3) { throw 'F09 must keep only thumbnail badges and their local photo boundary positioned' }
if ([regex]::Matches($page, '<textarea(?=[^>]*\sauto-height(?:\s|>))').Count -ne 2) { throw 'F09 batch and per-photo descriptions must both grow with content' }
if ($catalog -match '(?m)^\s*f09\s*:') {
throw 'F09 obsolete page-catalog owner must be removed'
}
Write-Output 'F09-MEDIA-UPLOAD-CONTRACT PASS'