fix(test): bind fleet statistics evidence without optional remarks

This commit is contained in:
2026-10-03 21:26:46 +08:00
parent 3987562890
commit 48faf43e37
2 changed files with 8 additions and 2 deletions
@@ -8,7 +8,7 @@ export function operationsFixtureFromHandover(bytes, { sha256, marker, runId })
const f = JSON.parse(bytes.toString('utf8')), history = f.immutableDeparture, snapshot = history?.snapshot, load = snapshot?.confirmedLoad, c = f.costs
if (f.marker !== marker || f.runId !== runId || f.status !== 'DEPART_AND_HANDOVER_VERIFIED' || !f.handoverNo
|| !f.tripNo || !f.warehouseId || history?.action !== 'DEPART' || snapshot?.trip?.tripNo !== f.tripNo
|| String(snapshot.trip.warehouseId) !== String(f.warehouseId) || !snapshot.trip.remark?.includes(marker)
|| String(snapshot.trip.warehouseId) !== String(f.warehouseId)
|| f.departure?.tripNo !== f.tripNo || f.departure.status !== 'IN_TRANSIT' || !Number.isFinite(Date.parse(f.departure.departedAt))
|| snapshot.trip.departedAt !== f.departure.departedAt || !load?.manifestHash
|| c?.status !== 'VERIFIED' || c.marker !== marker || c.tripNo !== f.tripNo
@@ -214,7 +214,7 @@ async function execute(context, { scope, writeMeasured = false, idempotencyNames
proof.tripNo = fixture.tripNo
const trip = await command('GET', `/api/platform/v1/last-leg/fleet/trips/${encode(fixture.tripNo)}`, undefined, '核对本轮真实发车车次')
check('车次属于当前场景并有真实发车时间', null, trip.trip?.tripNo === fixture.tripNo && id(trip.trip.warehouseId) === id(fixture.warehouseId)
&& trip.trip.remark?.includes(context.marker) && Date.parse(trip.trip.departedAt) === Date.parse(fixture.departedAt)
&& (fixture.immutableDeparture || trip.trip.remark?.includes(context.marker)) && Date.parse(trip.trip.departedAt) === Date.parse(fixture.departedAt)
&& ['IN_TRANSIT', 'COMPLETED'].includes(trip.trip.status))
from = new Date(Date.parse(fixture.departedAt) - 1).toISOString(); to = new Date(Date.parse(fixture.departedAt) + 1000).toISOString()
const reportPath = `${OPERATIONS}?${query({ from, to, warehouseId: fixture.warehouseId, keyword: fixture.tripNo, page: 1, size: 20 })}`
@@ -38,6 +38,12 @@ test('multi-stop costs retain full trip amounts and never infer source shares',
f.costs.expected.allocationMethod = 'SAME_ROUTE_PALLET_SPACES'
assert.throws(() => convert(f))
})
test('SHA-bound current artifact does not require optional trip remarks in the DEPART snapshot', () => {
const f = sample(); delete f.immutableDeparture.snapshot.trip.remark
assert.equal(convert(f).tripNo, f.tripNo)
f.costs.marker = 'OLD'
assert.throws(() => convert(f))
})
for (const [name, mutate] of [
['stale marker', f => { f.marker = 'OLD' }], ['stale run', f => { f.runId = 'old' }],
['unverified costs', f => { f.costs.status = 'CHECKING' }], ['wrong currency amount', f => { f.costs.expected.usd = '0' }],