优化
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { applyIndependentFees, feeCents, assertDualDestinationFixture, extensionMatrix, verifyLoadingReplayRace, executeFirstLoadingRace, assertBolPages, assertConfirmedRelabelCancellation } from './dispatch-workflow-extension-acceptance.mjs'
|
||||
import { feeCents, assertDualDestinationFixture, extensionMatrix, verifyLoadingReplayRace, executeFirstLoadingRace, assertBolPages, assertConfirmedRelabelCancellation } from './dispatch-workflow-extension-acceptance.mjs'
|
||||
import { parseExtensionArguments, runDispatchExtensions } from '../dispatch-workflow-extensions-test-env.mjs'
|
||||
|
||||
test('default plan imports without credentials/network and keeps all unexecuted gaps explicit', async () => {
|
||||
@@ -24,26 +24,6 @@ test('terminal continuation requires an explicit original report hash and is nev
|
||||
'--resume-report', 'reports/current/report.json', '--resume-report-sha256', 'a'.repeat(64)])
|
||||
assert.equal(config.scenario, 'review-terminal'); assert.equal(config.resumeReportSha256, 'a'.repeat(64))
|
||||
})
|
||||
test('actual group owner controls distinct cents even when server group ordering differs', () => {
|
||||
const groups = [{ groupKey: 'B-GROUP', customerId: 'B' }, { groupKey: 'A-GROUP', customerId: 'A' }]
|
||||
const body = { recordVersion: '9007199254740993', idempotencyKey: 'ORIGINAL', groups: groups.map(row => ({ groupKey: row.groupKey,
|
||||
fees: [{ feeType: 'DELIVERY_FEE', currency: 'CNY', amount: 30 }] })) }
|
||||
const expected = applyIndependentFees(body, groups, [{ customerId: 'A' }, { customerId: 'B' }], 'CURRENT')
|
||||
assert.deepEqual(body.groups.map(row => row.fees[0].amount), [47.75, 31.25])
|
||||
assert.equal(expected.A[0].cents, 3125); assert.equal(expected.B[0].cents, 4775)
|
||||
assert.equal(body.recordVersion, '9007199254740993'); assert.equal(body.idempotencyKey, 'ORIGINAL')
|
||||
assert(body.groups.every(row => row.fees[0].feeName.includes('TEST合成')))
|
||||
})
|
||||
test('unknown customers, repeated groups and missing real required fees fail before transport', () => {
|
||||
const members = [{ customerId: 'A' }, { customerId: 'B' }]
|
||||
for (const groups of [[{ groupKey: 'G', customerId: 'A' }, { groupKey: 'G', customerId: 'B' }],
|
||||
[{ groupKey: 'A', customerId: 'A' }, { groupKey: 'X', customerId: 'FOREIGN' }]]) {
|
||||
const body = { groups: groups.map(row => ({ groupKey: row.groupKey, fees: [{ feeType: 'DELIVERY_FEE', currency: 'CNY' }] })) }
|
||||
assert.throws(() => applyIndependentFees(body, groups, members, 'CURRENT'))
|
||||
}
|
||||
assert.throws(() => applyIndependentFees({ groups: [{ groupKey: 'A', fees: [] }, { groupKey: 'B', fees: [] }] },
|
||||
[{ groupKey: 'A', customerId: 'A' }, { groupKey: 'B', customerId: 'B' }], members, 'CURRENT'))
|
||||
})
|
||||
test('dual destination proof rejects reused customer, collapsed destination and missing route stop', () => {
|
||||
const fixture = { members: [{ customerId: 'A', destination: { key: 'FBA:ONE' }, receiptVerified: true },
|
||||
{ customerId: 'B', destination: { key: 'FBA:TWO' }, receiptVerified: true }],
|
||||
@@ -120,10 +100,10 @@ for (const winner of ['PDA', 'ADMIN']) test(`first valid loading CAS race record
|
||||
const context = { marker: 'CURRENT', createdResources: { dispatchWorkflowCompetition: { status: 'CHECKING' } }, checkpoint: async () => {}, assert: () => {} }
|
||||
const fixture = { dispatchNo: 'OWN', tripNo: 'TRIP', warehouseId: 'W', pdaToken: 'OWN_PDA', members: [{ customerId: 'A' }, { customerId: 'B' }] }
|
||||
const body = { recordVersion: '7', idempotencyKey: 'ORIGINAL_PDA', manifestHash: 'ACTUAL_HASH' }
|
||||
const success = { http: 200, body: { code: '200', data: { stage: 'AFTER_LOADING', recordVersion: '8', result: { confirmedLoad: { manifestHash: 'ACTUAL_HASH' } } } } }
|
||||
const success = { http: 200, body: { code: '200', data: { stage: 'DELIVERING', recordVersion: '8', result: { confirmedLoad: { manifestHash: 'ACTUAL_HASH' } } } } }
|
||||
const rejected = { http: 200, body: { code: 'A0409' } }, pending = []; let completed = false
|
||||
const send = async (method, path, payload, token) => {
|
||||
if (method === 'GET') return { http: 200, body: { code: '200', data: { stage: completed ? 'AFTER_LOADING' : 'LOADING',
|
||||
if (method === 'GET') return { http: 200, body: { code: '200', data: { stage: completed ? 'DELIVERING' : 'LOADING',
|
||||
recordVersion: completed ? '8' : '7', counts: { packageCount: 2, pickedPackageCount: 2 } } } }
|
||||
return new Promise(resolve => {
|
||||
pending.push({ resolve, token, payload })
|
||||
|
||||
Reference in New Issue
Block a user