test(fleet): verify same-route costs from three real pallet sources

This commit is contained in:
2026-10-04 12:07:37 +08:00
parent dc993c9713
commit 791d1a650f
5 changed files with 177 additions and 3 deletions
+12 -1
View File
@@ -27,8 +27,9 @@ function harness(root, fail = false) {
return { pdaToken: options.pdaToken, marker: context.marker, tripNo: 'TR-OFFLINE', members: [{ customerId: '42' }, { customerId: '43' }] }
}, verify: async (_context, _fixture, options) => {
await options.readInventory({ marker: context.marker, customerId: '42', warehouseId: '900' })
context.createdResources.fleetCrossCustomer = { status: 'VERIFIED' }
context.createdResources.fleetCrossCustomer = { status: 'VERIFIED', tripNo: 'TR-OFFLINE' }
context.createdResources.fleetTrips = [{ tripNo: 'TR-OFFLINE' }]
return context.createdResources.fleetCrossCustomer
},
finish: async (_context, _module, trip) => { trip.closure = { status: 'CARGO_COMPLETED_AND_RESOURCES_RELEASED' } },
} }
@@ -39,6 +40,16 @@ test('plan is network-free and execution requires explicit TEST, unique run and
for (const args of [['--execute'], ['--execute', '--environment', 'PROD', '--run-id', 'one', '--warehouse-id', '900'], ['--run-id', '../outside'], ['--plan', '--execute'], ['--warehouse-id', '1 OR 1=1']]) assert.throws(() => parseCrossCustomerArguments(args))
await assert.rejects(runCrossCustomer(config(), { env: { ...env, CHONGCHONG_ENV: 'prod' } }), /TEST/)
})
for (const result of [undefined,{status:'FAILED',tripNo:'TR-OFFLINE'},{status:'VERIFIED',tripNo:'TR-OTHER'}]) test('unverified or foreign result cannot close fixture resources',async()=>{
const root=mkdtempSync(join(tmpdir(),'fleet-cross-contract-'))
try {
const h=harness(root);let finished=false
h.options.verify=async()=>result;h.options.finish=async()=>{finished=true}
const report=await runCrossCustomer(config(),h.options)
assert.equal(report.success,false);assert.equal(finished,false);assert.deepEqual(h.cleanup,['81'])
}finally{assert.equal(dirname(resolve(root)),resolve(tmpdir()));assert.ok(basename(root).startsWith('fleet-cross-contract-'));rmSync(root,{recursive:true,force:true})}
})
for (const fail of [false, true]) test(`execution ${fail ? 'failure' : 'success'} preserves evidence, closes session and disables only its operator`, async () => {
const root = mkdtempSync(join(tmpdir(), 'fleet-cross-contract-'))
try {