This commit is contained in:
2026-10-21 14:30:41 +08:00
parent 0af977bdef
commit 40a03978cd
53 changed files with 1004 additions and 1291 deletions
@@ -130,16 +130,12 @@ test('UI fixture prepares one shared native main and an explicitly planned 18-of
})
test('native GRAY delivery window preserves per-customer group identity and never adds a retired top-level ETA', () => {
test('GRAY dispatch resource update carries its ETA into automatic delivery without changing the command identity', () => {
const schedule = grayUiSchedule(Date.parse('2030-01-01T00:00:00Z'))
const body = { recordVersion: '0', idempotencyKey: 'same-command', cargoHash: 'real-cargo', loadingCompletionHash: 'real-load',
groups: [{ groupKey: 'A:FBA:1', plannedDeliveryAt: 'old', fees: [{ amount: 30 }] }, { groupKey: 'B:FBA:1', plannedDeliveryAt: 'old', fees: [] }] }
const applied = applyGrayUiTransportWindow('POST', '/api/platform/v1/last-leg/dispatches/DS-1/transfer-delivery', body, schedule)
assert.equal(applied.recordVersion, '0'); assert.equal(applied.idempotencyKey, body.idempotencyKey)
assert.equal(Object.hasOwn(applied, 'plannedDeliveryAt'), false)
assert.deepEqual(applied.groups.map(group => group.groupKey), body.groups.map(group => group.groupKey))
assert.ok(applied.groups.every(group => group.plannedDeliveryAt === new Date(schedule.plannedDeliveryAt).toISOString()))
assert.deepEqual(applied.groups[0].fees, body.groups[0].fees)
assert.equal(body.groups[0].plannedDeliveryAt, 'old')
assert.throws(() => applyGrayUiTransportWindow('POST', '/api/platform/v1/last-leg/dispatches/DS-1/transfer-delivery', { plannedDeliveryAt: 'old' }, schedule), /NATIVE_DELIVERY_WINDOW_REQUIRED/)
const body = { recordVersion: '0', idempotencyKey: 'same-command', vehicle: { plate: 'TEST' } }
const applied = applyGrayUiTransportWindow('PUT', '/api/platform/v1/last-leg/dispatches/DS-1', body, schedule)
assert.equal(applied.recordVersion, body.recordVersion); assert.equal(applied.idempotencyKey, body.idempotencyKey)
assert.equal(applied.estimatedArrivalAt, new Date(schedule.plannedDeliveryAt).toISOString()); assert.deepEqual(applied.vehicle, body.vehicle)
assert.equal(Object.hasOwn(body, 'estimatedArrivalAt'), false)
assert.throws(() => applyGrayUiTransportWindow('PUT', '/api/platform/v1/last-leg/dispatches/DS-1', body, null), /NATIVE_DELIVERY_WINDOW_REQUIRED/)
})