This commit is contained in:
2026-09-04 11:50:34 +08:00
parent e390b88b6c
commit d5662230d5
4 changed files with 84 additions and 44 deletions
@@ -7,10 +7,11 @@ const source = readFileSync(resolve(process.cwd(), 'src/modules/unified-orders/p
const routeSource = readFileSync(resolve(process.cwd(), 'src/modules/unified-orders/routes.ts'), 'utf8')
describe('UnifiedOrdersView contract', () => {
it('blocks confirm-send when the customer has already confirmed the fee', () => {
expect(source).toContain("snapshot.customerConfirmationStatus === 'CONFIRMED'")
expect(source).toContain('客户已确认该费用,费用已锁定,不允许再修改或重新发送')
expect(source).toContain('async function openFeeConfirmDialog()')
it('shows the server confirmation lock without reading a stale fee snapshot', () => {
const openDialogSource = source.slice(source.indexOf('async function openFeeConfirmDialog()'), source.indexOf('async function executeConfirmAndSendFee()'))
const sendFeeSource = source.slice(source.indexOf('async function executeConfirmAndSendFee()'), source.indexOf('function handleOrderSelectionChange'))
expect(openDialogSource).not.toContain('getLatestInboundFee')
expect(sendFeeSource).toContain("ElMessage.error(getApiErrorDetails(error, '确认费用发送失败').message)")
})
it('only exposes the six product main statuses', () => {
@@ -88,7 +89,7 @@ describe('UnifiedOrdersView contract', () => {
})
it('covers real list states and keeps operation column first and left-fixed', () => {
expect(source).toContain("{ key: 'actions', label: '操作', width: 300, fixed: 'left'")
expect(source).toContain("{ key: 'actions', label: '操作', width: 270, fixed: 'left'")
expect(source).toContain("key: 'selection', type: 'selection'")
expect(source).not.toContain('批量审核接口待接入')
expect(source).toContain('@selection-change="handleOrderSelectionChange"')
@@ -115,7 +116,7 @@ describe('UnifiedOrdersView contract', () => {
expect(columnSource.indexOf("key: 'actions'")).toBeLessThan(columnSource.indexOf("key: 'inboundCode'"))
expect(columnSource).not.toContain("key: 'coLoadGroup'")
expect(columnSource).not.toContain("key: 'orderNo'")
expect(columnSource).toContain("key: 'inboundCode', prop: 'inboundCode', label: '入仓码', minWidth: 260, slotName: 'inboundCode'")
expect(columnSource).toContain("key: 'inboundCode', prop: 'inboundCode', label: '入仓码', minWidth: 160, slotName: 'inboundCode'")
expect(columnSource).toContain("{ key: 'mainStatus', prop: 'mainStatus', label: '订单主状态'")
expect(columnSource).not.toContain("key: 'loadingStatus'")
expect(columnSource).not.toContain("key: 'businessDate'")
@@ -124,8 +125,8 @@ describe('UnifiedOrdersView contract', () => {
expect(columnSource).not.toContain("key: 'recommendedPalletType'")
expect(columnSource).toContain("key: 'requestedPickupAt', prop: 'requestedPickupAt', label: '预约提货时间'")
expect(columnSource.match(/defaultVisible: false/g)).toHaveLength(13)
expect(columnSource).toContain("key: 'expectedArrivalAt', prop: 'expectedArrivalAt', label: '预计到货时间', minWidth: 220, slotName: 'expectedArrival' }")
expect(columnSource).toContain("key: 'estimatedVolumeCbm', prop: 'estimatedVolumeCbm', label: '预估体积(m³)', minWidth: 180, slotName: 'estimatedVolume' }")
expect(columnSource).toContain("key: 'expectedArrivalAt', prop: 'expectedArrivalAt', label: '预计到货时间', minWidth: 170, slotName: 'expectedArrival' }")
expect(columnSource).toContain("key: 'estimatedVolumeCbm', prop: 'estimatedVolumeCbm', label: '预估体积(m³)', minWidth: 120, slotName: 'estimatedVolume' }")
expect(columnSource).toContain("key: 'expectedVolumeCbm', prop: 'expectedVolumeCbm', label: '下单体积(m³)', minWidth: 130, slotName: 'field' }")
const planningColumnPositions = [
columnSource.indexOf("key: 'expectedArrivalAt'"),
@@ -391,13 +392,13 @@ describe('UnifiedOrdersView contract', () => {
it('confirms customer billing from the saved outer-carton totals', () => {
expect(source).toContain('const outerTotals = measurementTotals(outerMeasurementRows.value)')
expect(source).toContain("ElMessage.warning('外箱规数据不完整,请先保存外箱规尺寸和计算规则')")
expect(source).toContain("weightSource: 'OUTER'")
expect(source).toContain("volumeSource: 'OUTER'")
expect(source).toContain("weightSource: 'ACTUAL'")
expect(source).toContain("volumeSource: 'ACTUAL'")
expect(source).not.toContain('测量审核通过后才能确认并发送费用')
expect(source).not.toContain("reviewStatus !== 'APPROVED'")
expect(source).toContain('const hasActualMeasurementData = computed(() => (measurementDetail.value?.items?.length ?? 0) > 0)')
expect(source).toContain("暂无实际测量数据,不能确认并发送费用")
expect(source).toContain(':disabled="confirmFeeSending || measurementLoading || !hasActualMeasurementData || !canSendFeeForCurrentStatus"')
expect(source).not.toContain(':disabled="confirmFeeSending || measurementLoading || !hasActualMeasurementData"')
expect(source).toContain('selectAndSaveOuterMeasurementMode($event)')
expect(source).toContain('const saved = await updateMeasurementCalculationMode(null, mode, ruleId)')
expect(source).toContain('coefficientMode: targetIds.has(String(item.id)) ? mode')
@@ -408,13 +409,22 @@ describe('UnifiedOrdersView contract', () => {
expect(source).toContain('item.calculatedOuterLengthCm, item.calculatedOuterWidthCm, item.calculatedOuterHeightCm')
expect(source).toContain('if (dimensions.every((dimension) => dimension == null)) return true')
expect(source).toContain('已保存并绑定计算规则,体积已重新计算')
expect(source).not.toContain('feeConfirmVolume.value = Number(summary.measurement?.actualVolumeCbm)')
expect(source).toContain('const measuredGrossWeight = Number(measurementDetail.value?.actualGrossWeightKg)')
expect(source).toContain('const measuredNetWeight = Number(measurementDetail.value?.actualNetWeightKg)')
expect(source).toContain('const actualVolume = Number(measurementDetail.value?.actualVolumeCbm)')
expect(source).toContain('feeConfirmWeight.value = measuredGrossWeight > 0')
expect(source).toContain('feeConfirmVolume.value = actualVolume > 0')
const sendFeeSource = source.slice(source.indexOf('async function executeConfirmAndSendFee()'), source.indexOf('function handleOrderSelectionChange'))
expect(sendFeeSource).not.toContain('saveInboundMeasurementDraft')
expect(sendFeeSource).not.toContain('updateMeasurementCalculationMode')
expect(source.slice(source.indexOf('async function openFeeConfirmDialog()'), source.indexOf('async function executeConfirmAndSendFee()'))).not.toContain('getLatestInboundFee')
})
it('clears an invalidated measurement loading state before refreshing order details', () => {
const detailLoaderSource = source.slice(source.indexOf('async function loadDetail(force = false)'), source.indexOf('watch([page, pageSize]'))
expect(detailLoaderSource).toContain('measurementRequestSerial += 1\n measurementLoading.value = false')
})
it('restores the saved outer-carton rule and server-calculated dimensions on re-entry', () => {
expect(source).toContain('const savedModes = [...new Set(response.items.map((item) => item.coefficientMode)')
expect(source).toContain('measurementSectionModes.outer = savedModes.length === 1')
@@ -502,6 +512,9 @@ describe('UnifiedOrdersView contract', () => {
expect(source).toContain('InboundFeeDetailManager')
expect(source).toContain(':customer-id="String(detail.summary.tenantId)"')
expect(source).toContain('compact')
expect(source).toContain('display-only')
expect(source).toContain(':key="`fee-${normalizedInboundId}-${feePanelRevision}`"')
expect(source).toContain('feePanelRevision.value += 1')
expect(source).toContain('头程自动初算')
expect(source).toContain('其他费用明细')
expect(source).toContain('@changed="loadDetail(true)"')