test(shipping): validate platform customer scope separately from business IDs

This commit is contained in:
2026-09-30 13:30:27 +08:00
parent 74f0d823da
commit 7f3c0690cd
2 changed files with 63 additions and 2 deletions
@@ -16,8 +16,9 @@ function id(value) { return value == null ? '' : String(value) }
function number(value) { return Number.isFinite(Number(value)) }
function nullableText(value) { return value == null || typeof value === 'string' }
function nullableIso(value) { return value == null || (typeof value === 'string' && !Number.isNaN(Date.parse(value))) }
function validLongId(value) { return typeof value === 'string' && /^\d{16,}$/.test(value) }
function validLongId(value) { return typeof value === 'string' && /^[1-9]\d{15,}$/.test(value) }
function validNumericId(value) { return typeof value === 'string' && /^\d+$/.test(value) && value !== '0' }
function validCustomerScope(value) { return typeof value === 'string' && /^(?:0|[1-9]\d*)$/.test(value) }
function validOperatorId(value) { return value === '0' || validNumericId(value) }
function validContainerNo(value) {
if (typeof value !== 'string' || !ISO_CONTAINER_PATTERN.test(value)) return false
@@ -69,7 +70,7 @@ export function manualNodePayload({ expectedVersion, standardNode, observedAt, e
}
function validTask(task) {
return validLongId(task?.id) && Boolean(task?.queryNo) && validNumericId(task?.customerId)
return validLongId(task?.id) && Boolean(task?.queryNo) && validCustomerScope(task?.customerId)
&& validLongId(task?.oceanBookingId) && QUERY_STATUSES.includes(task?.status)
&& validLongId(task?.containerBookingId) && task?.trackingType === 'CONTAINER_NO'
&& validContainerNo(task?.trackingNo) && nullableText(task?.latestActualNode)