From 48faf43e3702b649f2a2b85ed7563f96bb55387a Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 3 Oct 2026 21:26:46 +0800 Subject: [PATCH] fix(test): bind fleet statistics evidence without optional remarks --- scripts/admin-test-env-modules/fleet-quotes-operations.mjs | 4 ++-- scripts/fleet-operations-test-env-contract.test.mjs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/admin-test-env-modules/fleet-quotes-operations.mjs b/scripts/admin-test-env-modules/fleet-quotes-operations.mjs index 694f8a10c..1e8d132e8 100644 --- a/scripts/admin-test-env-modules/fleet-quotes-operations.mjs +++ b/scripts/admin-test-env-modules/fleet-quotes-operations.mjs @@ -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 })}` diff --git a/scripts/fleet-operations-test-env-contract.test.mjs b/scripts/fleet-operations-test-env-contract.test.mjs index d8d8aa68f..55f3942ad 100644 --- a/scripts/fleet-operations-test-env-contract.test.mjs +++ b/scripts/fleet-operations-test-env-contract.test.mjs @@ -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' }],