Files
docs/悦/PDA(海外)/tests/unload-receiving-photo-required.test.ps1
2026-09-08 14:05:30 +08:00

27 lines
2.0 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$html = Get-Content -Raw -Encoding UTF8 -LiteralPath (Join-Path $PSScriptRoot '..\assets\app.js')
$listView = [regex]::Match($html, '(?s)function receiveListView\(\).*?(?=function plansView)').Value
$photoView = [regex]::Match($html, '(?s)function receivePhotoView\(\).*?(?=function handleUnloadPhoto)').Value
$completeUnload = [regex]::Match($html, '(?s)function completeUnload\(\).*?(?=function receiveView)').Value
$zhPalletBoxes = [string]::Concat([char]0x6258,[char]0x6570,'/',[char]0x7bb1,[char]0x6570)
$zhOther = [char]0x5176 + [char]0x4ed6
$requiredLabels = @(
"Object.assign(EXTRA_LABELS.zh,{receivePalletBoxes:'$zhPalletBoxes',other:'$zhOther'})",
"Object.assign(EXTRA_LABELS.en,{receivePalletBoxes:'Pallets/Cartons',other:'Other'})",
"Object.assign(EXTRA_LABELS.es,{receivePalletBoxes:'Pallets/Cajas',other:'Otro'})"
)
$labelMissing = $requiredLabels | Where-Object { -not $html.Contains($_) }
if ($labelMissing) { throw "Missing unload-specific labels: $($labelMissing -join ', ')" }
if (-not $listView.Contains("t('receivePalletBoxes')")) { throw 'Unload list does not use the combined count label' }
if (-not $photoView.Contains("t('receivePalletBoxes')")) { throw 'Unload detail does not use the combined count label' }
if (-not $html.Contains("const UNLOAD_PHOTO_STEPS=['licensePlate','containerSeal','doorOpen','other'];")) { throw 'Unload display steps do not include other photo' }
if (-not $html.Contains("const UNLOAD_REQUIRED_PHOTO_STEPS=['licensePlate','containerSeal','doorOpen'];")) { throw 'Required unload photo steps are missing' }
if (-not $photoView.Contains("UNLOAD_REQUIRED_PHOTO_STEPS.includes(key)?' *':''")) { throw 'Required photo marker is missing' }
if (-not $photoView.Contains('UNLOAD_REQUIRED_PHOTO_STEPS.every(key=>photos[key])')) { throw 'Detail submit state does not use required photos only' }
if (-not $completeUnload.Contains('UNLOAD_REQUIRED_PHOTO_STEPS.some(key=>!photos[key])')) { throw 'Completion validation still checks optional photos' }
Write-Output 'PASS: unload receiving photo required contract'