test(fleet): verify vehicle care lifecycle independently

This commit is contained in:
2026-10-03 10:54:03 +08:00
parent d4d5d79070
commit ba7dcd39f2
5 changed files with 102 additions and 7 deletions
@@ -56,19 +56,23 @@ export async function verifyVehicleCare(context, module, vehicle, proof) {
fuelQuantity: null, fuelUnit: null, verificationStatus: null, remark: context.marker,
incident: { description: `${context.marker} 受控故障处置记录`, item: priced ? '更换轮胎' : null, place: priced ? '本轮测试作业点' : null,
handler: null, processingStatus: 'PENDING', exceptionType: type === 'EXCEPTION' ? 'VEHICLE_BREAKDOWN' : null,
reportedCost: priced ? 0 : null, currency: priced ? 'USD' : null } }
reportedCost: type === 'REPAIR' ? 125.5 : priced ? 0 : null, currency: priced ? 'USD' : null } }
const initial = { idempotencyKey: `${context.marker}:${type}`, details }
let incident = await command('POST', base, initial, `创建本轮${type}记录`)
proof.records.push({ recordNo: incident.recordNo, createRequest: initial })
check('事件项目地点和分类完整回显', null, incident.vehicleId === id && incident.details?.incident?.item === details.incident.item
&& incident.details.incident.place === details.incident.place && incident.details.incident.exceptionType === details.incident.exceptionType)
check('事件项目地点和分类完整回显', null, incident.vehicleId === id && (incident.details?.incident?.item ?? null) === details.incident.item
&& (incident.details.incident.place ?? null) === details.incident.place && (incident.details.incident.exceptionType ?? null) === details.incident.exceptionType)
incident = await command('PUT', `${base}/${incident.recordNo}`, { recordVersion: Number(incident.recordVersion), reason: '受控任务实际处理完成',
details: { ...details, incident: { ...details.incident, handler: '本轮测试处理人', processingStatus: 'COMPLETED' } } }, `完成本轮${type}处理记录`)
check('处理完成保持独立的费用及付款事实', null, incident.details.incident.processingStatus === 'COMPLETED'
&& (!priced || (Number(incident.details.incident.reportedCost) === 0 && incident.paymentStatus === 'UNLINKED')))
&& (!priced || (Number(incident.details.incident.reportedCost) === details.incident.reportedCost && incident.paymentStatus === 'UNLINKED')))
const refreshed = await command('GET', `${base}/${incident.recordNo}`, undefined, `重新读取本轮${type}记录`)
check('处理记录重新读取保持全部现场字段', null, refreshed.details.incident.item === details.incident.item
&& refreshed.details.incident.place === details.incident.place && refreshed.details.incident.handler === '本轮测试处理人')
check('处理记录重新读取保持全部现场字段', null, (refreshed.details.incident.item ?? null) === details.incident.item
&& (refreshed.details.incident.place ?? null) === details.incident.place && refreshed.details.incident.handler === '本轮测试处理人')
const changes = await command('GET', `${base}/${incident.recordNo}/history?page=1&size=20`, undefined, `核对本轮${type}处理历史`)
check('处理历史保留原待处理事实及完成结果', null, changes.records?.length === 2
&& changes.records[0].snapshot?.details?.incident?.processingStatus === 'COMPLETED'
&& changes.records[1].snapshot?.details?.incident?.processingStatus === 'PENDING')
}
let other
try {