test(firstleg): harden pallet option page contract

This commit is contained in:
2026-09-01 11:03:40 +08:00
parent 7ace1ded56
commit 4991536065
6 changed files with 57 additions and 8 deletions
@@ -7,6 +7,7 @@ const read = (relativeUrl) => readFileSync(new URL(relativeUrl, import.meta.url)
const controller = read('../../firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformInboundMeasurementController.java')
const service = read('../../firstleg/src/main/java/com/baiyue/firstleg/service/InboundMeasurementService.java')
const warehouseClient = read('../../firstleg/src/main/java/com/baiyue/firstleg/client/WarehousePalletLocationClient.java')
const serviceTests = read('../../firstleg/src/test/java/com/baiyue/firstleg/service/InboundMeasurementServiceTest.java')
const openapi = read('../../firstleg/src/main/resources/openapi/firstleg-v1.yaml')
const adminApi = read('../../../apps/admin-web/src/modules/inbounds/weight/api/weightOcr.ts')
const adminPanel = read('../../../apps/admin-web/src/modules/inbounds/weight/components/WeightOcrPanel.vue')
@@ -112,3 +113,16 @@ test('historical pallet snapshot remains read-only visible when it is no longer
assert.match(cards, /row\.palletTareWeightKg/)
assert.match(adminBehavior, /(?:historical|history|历史|失去候选|no longer eligible).{0,220}(?:palletCode|托盘编码|TP-)/is)
})
test('backend detail reads the stored historical pallet snapshot without revalidating current eligibility', () => {
assert.match(serviceTests, /detailUsesStoredPalletSnapshotAfterCandidateBecomesUnavailable/)
assert.match(serviceTests, /verify\(warehousePallets, never\(\)\)\.palletSnapshot/)
assert.match(serviceTests, /verify\(warehousePallets, never\(\)\)\.palletSnapshots/)
})
test('backend evidence fails closed for Warehouse non-2xx and network errors', () => {
assert.match(serviceTests, /weightPalletOptionsFailsClosedOnWarehouseNon2xxResponse/)
assert.match(serviceTests, /weightPalletOptionsFailsClosedOnWarehouseNetworkError/)
assert.match(serviceTests, /FeignException/)
assert.match(serviceTests, /RetryableException/)
})
@@ -8,6 +8,7 @@ const read = (relativeUrl) => readFileSync(new URL(relativeUrl, import.meta.url)
const controller = read('../../firstleg/src/main/java/com/baiyue/firstleg/controller/PlatformInboundMeasurementController.java')
const pageResult = read('../../common-core/src/main/java/com/baiyue/common/core/api/PageResult.java')
const longJackson = read('../../common-web/src/main/java/com/baiyue/common/web/LongIdJacksonConfiguration.java')
const serviceTests = read('../../firstleg/src/test/java/com/baiyue/firstleg/service/InboundMeasurementServiceTest.java')
const openapi = read('../../firstleg/src/main/resources/openapi/firstleg-v1.yaml')
const adminApi = read('../../../apps/admin-web/src/modules/inbounds/weight/api/weightOcr.ts')
const adminApiTests = read('../../../apps/admin-web/src/modules/inbounds/weight/api/weightOcr.test.ts')
@@ -84,3 +85,9 @@ test('Admin behavior separately covers a non-2xx HTTP or network error', () => {
test('Admin aborts and ignores an expired candidate response', () => {
assert.match(adminBehavior, /in-flight pallet request[\s\S]{0,900}signal\?\.aborted[\s\S]{0,300}过期托盘/)
})
test('backend preserves failure evidence for Warehouse non-2xx and network errors', () => {
assert.match(serviceTests, /weightPalletOptionsFailsClosedOnWarehouseNon2xxResponse/)
assert.match(serviceTests, /weightPalletOptionsFailsClosedOnWarehouseNetworkError/)
assert.match(serviceTests, /仓库服务暂不可用/)
})