Files
docs/悦/PDA(海外)/tests/fba-pallet-scan-quantity.test.ps1
T
2026-09-08 14:05:30 +08:00

19 lines
1.6 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$html = Get-Content -Raw -Encoding UTF8 -LiteralPath (Join-Path $PSScriptRoot '..\assets\app.js')
$palletView = [regex]::Match($html, '(?s)function palletView\(\).*?(?=function startPallet\()').Value
$scanHandler = [regex]::Match($html, '(?s)function handlePalletScan\(\).*?(?=function addPalletItem)').Value
if (-not $html.Contains("palletScanQty:'1'")) { throw 'Pallet scan quantity state is missing' }
$inputCartonQty = [char]0x8f93 + [char]0x5165 + [char]0x7bb1 + [char]0x6570
if (-not $html.Contains("inputCartonQty:'$inputCartonQty'")) { throw 'FBA carton quantity label is missing' }
if (-not $palletView.Contains("state.palletOrderType==='fba'")) { throw 'FBA scan quantity block is missing' }
if (-not $palletView.Contains('id="pallet-scan-qty"')) { throw 'FBA carton quantity input is missing' }
if (-not $palletView.Contains('id="pallet-scan-remaining"')) { throw 'FBA remaining carton display is missing' }
if (-not $html.Contains('function updatePalletScanQty(value)')) { throw 'FBA carton quantity handler is missing' }
if (-not $scanHandler.Contains('if(!value){return}')) { throw 'Empty pallet scan still reports a required-value error' }
if (-not $scanHandler.Contains('requestedQty')) { throw 'Pallet scan does not read the requested carton quantity' }
if (-not $scanHandler.Contains('.slice(0,requestedQty)')) { throw 'Pallet scan does not add the requested carton quantity' }
if (-not $html.Contains("state.palletOrderType!=='overseas'")) { throw 'Quantity modal guard is missing' }
Write-Output 'PASS: FBA pallet scan quantity contract'