test(acceptance): reuse fixed customers and align native fulfillment flows
This commit is contained in:
@@ -141,6 +141,8 @@ function server(fault = '') {
|
||||
return ok({ id: DRIVER, reviewStatus: 'APPROVED', recordVersion: ++driverVersion })
|
||||
}
|
||||
if (path.startsWith('/api/platform/v1/last-leg/fleet/trips?')) {
|
||||
if (!new URL(path, 'https://unused.test').searchParams.has('keyword'))
|
||||
return ok({ records: [], page: 1, size: 200, total: 0 })
|
||||
const rows = fault === 'missing-trip' ? [] : [trip, ...(nextTrip ? [nextTrip] : [])]
|
||||
if (fault === 'duplicate-trip') rows.push({ ...trip, tripNo: 'TR-B' })
|
||||
const wrong = { 'wrong-plate': { vehiclePlate: `${trip.vehiclePlate}-OTHER` },
|
||||
@@ -321,6 +323,18 @@ test('fixed customer reuses master records and uploads only this dispatch review
|
||||
assert.ok(s.calls.filter(call => call.method !== 'GET').every(call => call.path.startsWith(D)))
|
||||
})
|
||||
|
||||
test('review preparation preserves existing maintenance and appointment numbers while filling missing TEST destination numbers', async () => {
|
||||
const s = server()
|
||||
s.detail.vehicleInfo.maintenance = { loadType: '托盘', destinationAppointments: [{ destinationKey: 'FBA:ONT8', appointmentNo: 'ORIGINAL' }] }
|
||||
s.detail.dispatchInfo.fbaAppointments = [{ destinationKey: 'FBA:ONT8', destinationWarehouseCode: 'ONT8', appointmentNo: 'ORIGINAL' },
|
||||
{ destinationKey: 'FBA:ABE3', destinationWarehouseCode: 'ABE3', status: 'PENDING' }]
|
||||
const proof = await prepare(s)
|
||||
assert.equal(proof.updateRequest.maintenance.loadType, '托盘')
|
||||
assert.equal(proof.updateRequest.maintenance.destinationAppointments[0].appointmentNo, 'ORIGINAL')
|
||||
assert.match(proof.updateRequest.maintenance.destinationAppointments[1].appointmentNo, /^TEST-/)
|
||||
assert.equal(proof.updateRequest.maintenance.destinationAppointments[1].destinationKey, 'FBA:ABE3')
|
||||
})
|
||||
|
||||
test('fixed fleet resources block missing, locally occupied and ineligible pairs without master writes', async () => {
|
||||
const pair = { vehicleId: VID, driverId: DRIVER }
|
||||
for (const fault of ['missing', 'occupied', 'vehicle-status', 'driver-qualification']) {
|
||||
@@ -329,6 +343,7 @@ test('fixed fleet resources block missing, locally occupied and ineligible pairs
|
||||
createdResources: { fleetTrips: fault === 'occupied' ? [{ ...pair }] : [proof] },
|
||||
async request(method, path) {
|
||||
calls.push(path); assert.equal(method, 'GET')
|
||||
if (path.includes('/fleet/trips?')) return ok({ records: [], page: 1, size: 200, total: 0 })
|
||||
return path.includes('/vehicles/') ? ok({ id: VID, status: fault === 'vehicle-status' ? 'DISPATCHED' : 'IN_SERVICE', region: 'OVERSEAS', ownership: 'OWNED' })
|
||||
: ok({ id: DRIVER, active: true, reviewStatus: 'APPROVED', details: { ownership: 'OWNED' }, qualification: { canDispatch: fault !== 'driver-qualification', reason: 'ELIGIBLE' } })
|
||||
}, apiSuccess(_m, _l, response) { return response.body.data } }
|
||||
@@ -343,6 +358,7 @@ test('verified resource closure makes a fixed pair available again', async () =>
|
||||
createdResources: { fleetTrips: [{ vehicleId: VID, driverId: DRIVER, closure: { status: 'CARGO_COMPLETED_AND_RESOURCES_RELEASED' } }, proof] },
|
||||
async request(method, path) {
|
||||
assert.equal(method, 'GET')
|
||||
if (path.includes('/fleet/trips?')) return ok({ records: [], page: 1, size: 200, total: 0 })
|
||||
return path.includes('/vehicles/') ? ok({ id: VID, status: 'IN_SERVICE', region: 'OVERSEAS', ownership: 'OWNED' })
|
||||
: ok({ id: DRIVER, active: true, reviewStatus: 'APPROVED', details: { ownership: 'OWNED' }, qualification: { canDispatch: true, reason: 'ELIGIBLE' } })
|
||||
}, apiSuccess(_m, _l, response) { return response.body.data } }
|
||||
@@ -351,6 +367,25 @@ test('verified resource closure makes a fixed pair available again', async () =>
|
||||
assert.equal(proof.driverId, DRIVER)
|
||||
})
|
||||
|
||||
test('fixed pool skips externally occupied resources, even completed trips without release', async () => {
|
||||
for (const status of ['PLANNED', 'COMPLETED']) {
|
||||
const proof = {}, calls = []
|
||||
const context = { options: { fixedFleetResources: [{ vehicleId: '11', driverId: '12' }, { vehicleId: VID, driverId: DRIVER }] },
|
||||
createdResources: { fleetTrips: [proof] }, apiSuccess(_m, _l, response) { return response.body.data },
|
||||
async request(method, path) {
|
||||
calls.push(path); assert.equal(method, 'GET')
|
||||
if (path.includes('/fleet/trips?')) return ok({ records: [{ tripNo: 'FOREIGN', status, vehicleId: '11', driverId: '12' }], page: 1, size: 200, total: 1 })
|
||||
return path.includes('/vehicles/') ? ok({ id: VID, status: 'IN_SERVICE', region: 'OVERSEAS', ownership: 'OWNED' })
|
||||
: ok({ id: DRIVER, active: true, reviewStatus: 'APPROVED', details: { ownership: 'OWNED' }, qualification: { canDispatch: true, reason: 'ELIGIBLE' } })
|
||||
} }
|
||||
await reuseFleetResources(context, 'test', proof)
|
||||
assert.equal(proof.vehicleId, VID); assert.equal(proof.driverId, DRIVER)
|
||||
assert.ok(calls.every(path => !path.includes('/vehicles/11') && !path.includes('/drivers/12')))
|
||||
context.options.fixedFleetResources.pop()
|
||||
await assert.rejects(reuseFleetResources(context, 'test', {}), /固定车辆司机/)
|
||||
}
|
||||
})
|
||||
|
||||
test('zero-scan LOADING must explicitly return to review before editing and pass a new review round', async () => {
|
||||
const s = server(); s.detail.stage = 'LOADING'; s.detail.reviewState = 'APPROVED'
|
||||
const proof = await prepare(s)
|
||||
|
||||
Reference in New Issue
Block a user