test: align live acceptance with dispatch photos and return counting

This commit is contained in:
2026-10-22 23:50:23 +08:00
parent daa5d30d16
commit f74861baea
6 changed files with 49 additions and 11 deletions
@@ -115,6 +115,12 @@ function server(fault = '') {
apiSuccess(_module, _label, response) { return response?.body?.code === '200' ? response.body.data : null },
async requestMultipart(method, path, file) {
calls.push({ method, path, file: { name: file.name, size: file.content.byteLength } })
if (path.startsWith(`${D}/evidence/`)) {
assert.equal(file.type, 'image/png')
const kind = path.split('/').at(-1)
assert.match(file.name, new RegExp(`TEST-${kind}`))
return ok({ fileId: String(101 + ['VEHICLE', 'DRIVER_PHOTO', 'DRIVER'].indexOf(kind)) })
}
assert.equal(file.type, 'image/png'); assert.match(file.name, /TEST-LICENSE/)
uploadComplete = true; driverVersion++
return ok({ id: DRIVER, licenseFileId: '9007199254740999', recordVersion: driverVersion })
@@ -178,6 +184,9 @@ function server(fault = '') {
assert.ok(driverReviewed); assert.equal(body.recordVersion, detail.recordVersion)
assert.equal(body.vehicle.mode, 'MASTER'); assert.equal(body.vehicle.vehicleId, VID)
assert.equal(body.driver.driverId, DRIVER); assert.ok(body.driver.evidence.expectedTaskEndAt)
assert.deepEqual(body.vehicle.evidenceFileIds, ['101'])
assert.deepEqual(body.driver.evidence.photoFileIds, ['102'])
assert.deepEqual(body.driver.evidence.fileIds, ['103'])
detail.vehicleInfo = { vehicle: { mode: 'MASTER', vehicleId: VID, plate: nextPlate, carrierName: 'TEST自有车', capacity: { palletSpaces: 30, maxLoadKg: 18000, maxVolumeCbm: 90 } },
driver: { mode: 'MASTER', driverId: DRIVER, name: 'TEST司机', phone: '19900000000' } }
Object.assign(trip, { vehicleId: VID, vehiclePlate: nextPlate, driverId: DRIVER })
@@ -299,7 +308,7 @@ test('native preparation edits existing master then submits both reviews, discov
assert.ok(s.assertions.every(a => a.passed))
})
test('fixed customer prepares a real trip without creating vehicles, drivers or uploading licenses', async () => {
test('fixed customer reuses master records and uploads only this dispatch review photos', async () => {
const s = server('fixed-master')
s.context.options = { fixedCustomerId: '123', fixedFleetResources: [{ vehicleId: VID, driverId: DRIVER }] }
const proof = await prepare(s)
@@ -307,7 +316,8 @@ test('fixed customer prepares a real trip without creating vehicles, drivers or
assert.equal(proof.preparation, 'VERIFIED')
assert.equal(proof.vehicleId, VID)
assert.equal(proof.driverId, DRIVER)
assert.equal(s.calls.some(call => call.file), false)
assert.deepEqual(s.calls.filter(call => call.file).map(call => call.path),
['VEHICLE', 'DRIVER_PHOTO', 'DRIVER'].map(kind => `${D}/evidence/${kind}`))
assert.ok(s.calls.filter(call => call.method !== 'GET').every(call => call.path.startsWith(D)))
})