Files
docs/悦/PDA(海外)/tests/handover-summary.test.ps1
2026-09-08 14:05:30 +08:00

28 lines
1.0 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$html = Get-Content -Raw -LiteralPath (Join-Path $PSScriptRoot '..\assets\app.js')
$required = @(
'totalWeightLb:203.0',
'totalWeightLb:99.9',
"totalBoxes:'总箱数'",
"totalWeight:'总重量'",
"totalBoxes:'Total cartons'",
"totalWeight:'Total weight'",
"totalBoxes:'Total de cajas'",
"totalWeight:'Peso total'",
'pickTasks.reduce((sum,task)=>sum+Number(task.palletCount||0),0)',
'pickTasks.reduce((sum,task)=>sum+Number(task.boxes||0),0)',
'pickTasks.reduce((sum,task)=>sum+Number(task.totalWeightLb||0),0)',
'${totalWeight.toFixed(1)} lb'
)
$missing = $required | Where-Object { -not $html.Contains($_) }
if ($missing) { throw "Missing handover summary contract: $($missing -join ', ')" }
$handoverSource = [regex]::Match($html, '(?s)function handoverView\(\).*?(?=function handleHandoverPhoto)').Value
if ($handoverSource.Contains('<span>${t(''boxes'')}</span>')) {
throw 'Handover still uses the generic cartons label'
}
Write-Output 'PASS: handover summary source contract'