import assert from 'node:assert/strict' import test from 'node:test' import { readFileSync } from 'node:fs' function source(name) { return readFileSync(new URL(name, import.meta.url), 'utf8') } test('measurement HTTP acceptance preserves whole-ticket slot identities across confirmations', () => { const measurement = source('./inbound-measurement.mjs') assert.match(measurement, /逐张确认后回查整票库位块/) assert.match(measurement, /扩容只追加且既有槽身份不漂移/) assert.match(measurement, /asId\(verified\.guide\?\.blockId\) === previous\.blockId/) assert.match(measurement, /verified\.slots\.length >= previous\.slots\.length && priorSlotsStable/) assert.match(measurement, /asId\(current\.reservationId\) === asId\(prior\.reservationId\)/) assert.match(measurement, /asId\(current\.locationId\) === asId\(prior\.locationId\)/) }) test('smart-loading HTTP acceptance uses authoritative totals and proves over-allocation zero drift', () => { const loading = source('./phase3-loading.mjs') assert.match(loading, /计划详情由服务端返回权威总箱数和剩余箱数/) assert.match(loading, /authoritativeRemaining === authoritativeTotal - assignedPackageCount/) assert.match(loading, /packageCount: authoritativeTotal \+ 1/) assert.match(loading, /调整箱数超过服务端权威总箱数返回A0400/) assert.match(loading, /Number\(afterOverAuthority\?\.version\) === Number\(reassignedPlan\?\.version\)/) assert.match(loading, /Number\(afterOverAuthorityItem\?\.remainingPackageCount\) === authoritativeRemaining/) })