test(firstleg): package carrier node demo checks
This commit is contained in:
@@ -50,6 +50,18 @@ function blocker(context, name, evidence) {
|
||||
}
|
||||
|
||||
function validLongId(value) { return typeof value === 'string' && /^\d{16,}$/.test(value) }
|
||||
export function validContainerNo(value) {
|
||||
if (typeof value !== 'string' || !/^[A-Z]{3}[UJZ][0-9]{7}$/.test(value)) return false
|
||||
const letterValues = [10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38]
|
||||
let sum = 0
|
||||
for (let index = 0; index < 10; index += 1) {
|
||||
const code = value.charCodeAt(index)
|
||||
const number = code >= 48 && code <= 57 ? code - 48 : letterValues[code - 65]
|
||||
sum += number * (2 ** index)
|
||||
}
|
||||
return Number(value[10]) === (sum % 11) % 10
|
||||
}
|
||||
|
||||
export async function run(context) {
|
||||
context.addCoverageGap(MODULE, OPTIONS.scenario, 'COSCO官方API自动查询',
|
||||
@@ -84,6 +96,7 @@ export async function run(context) {
|
||||
const task = item?.query
|
||||
return id(task?.customerId) === fixture.customerId && id(task?.oceanBookingId) === fixture.oceanBookingId
|
||||
&& id(task?.containerBookingId) === fixture.containerBookingId && task?.trackingNo === fixture.trackingNo
|
||||
&& task?.trackingType === 'CONTAINER_NO' && validContainerNo(task?.trackingNo)
|
||||
&& task?.triggerSource === 'OUTBOUND_CONFIRM'
|
||||
})
|
||||
context.assert(MODULE, '本轮出仓范围唯一命中CarrierScheduleQuery', pageResponse,
|
||||
@@ -104,6 +117,8 @@ export async function run(context) {
|
||||
&& item.actualAt != null && item.estimatedAt == null)
|
||||
context.assert(MODULE, '出仓自动任务携带实际DEPARTED_WAREHOUSE事实与长ID', detailResponse,
|
||||
id(detail?.query?.query?.id) === queryId && validLongId(detail?.query?.query?.id)
|
||||
&& detail?.query?.query?.trackingType === 'CONTAINER_NO'
|
||||
&& validContainerNo(detail?.query?.query?.trackingNo)
|
||||
&& departed.length >= 1 && departed.every((item) => validLongId(item.id)
|
||||
&& item.providerCode === 'FIRSTLEG' && item.providerEventId && item.providerNodeCode
|
||||
&& typeof item.rawPayloadHash === 'string' && /^[0-9a-f]{64}$/.test(item.rawPayloadHash)),
|
||||
|
||||
Reference in New Issue
Block a user