This commit is contained in:
2026-09-03 11:13:28 +08:00
parent 9b3664c532
commit 2f7c122c44
5 changed files with 334 additions and 66 deletions
@@ -70,8 +70,25 @@ function measurement(overrides: Partial<InboundMeasurementDetail> = {}): Inbound
actualVolumeCbm: 0.6,
volumeWeightKg: 100.2,
actualGoodsName: '蓝牙音箱',
latestDeclaration: {
referenceId: 'DOC-001',
totalPackageCount: 10,
grossWeightKg: 118.5,
volumeCbm: 0.8,
goodsName: '蓝牙音箱',
items: [{
inboundDetailId: '8101',
itemNo: 1,
cargoName: '蓝牙音箱',
packageCount: 10,
lengthCm: 50,
widthCm: 40,
heightCm: 30,
}],
},
items: [{
id: '9101',
inboundDetailId: '8101',
boxCode: 'RK202608040001#10-1',
itemNo: '001',
boxSpecification: '50×40×30cm',
@@ -162,6 +179,33 @@ describe('InboundMeasurementPanel', () => {
expect(wrapper.find('button[aria-label="预览测量图片"]').exists()).toBe(true)
})
it('warns when declared dimensions or gross weight differ from measurements by at least ten percent', async () => {
vi.mocked(getInboundMeasurement).mockResolvedValueOnce(measurement({
actualGrossWeightKg: 132,
items: [{
...measurement().items[0],
lengthCm: 55,
widthCm: 36,
}],
}))
const wrapper = await mountPanel()
const alert = wrapper.find('.measurement-deviation-alert')
expect(alert.exists()).toBe(true)
expect(alert.text()).toContain('下单箱规与测量数据差异达到 10%')
expect(alert.text()).toContain('长偏差 10%')
expect(alert.text()).toContain('下单 50 cm → 实测 55 cm')
expect(alert.text()).toContain('宽偏差 10%')
expect(alert.text()).toContain('重量偏差 11.4%')
expect(alert.text()).not.toContain('高偏差')
})
it('does not warn when every declared and measured value differs by less than ten percent', async () => {
const wrapper = await mountPanel()
expect(wrapper.find('.measurement-deviation-alert').exists()).toBe(false)
})
it('opens the manual carton entry form in an editable measurement state', async () => {
const wrapper = await mountPanel()
const button = wrapper.findAll('button').find((candidate) => candidate.text().includes('手动录入箱规'))