import { describe, expect, it } from 'vitest' import { businessOrderLink } from './businessOrderLink' import { toLastMileOrderListItem } from './lastMilePresentation' describe('tail order business source', () => { it('keeps physical fulfillment type and uses only formal business references', () => { const row = toLastMileOrderListItem({ id: '1', customerId: 'A', orderNo: 'WT-1', orderType: 'WAREHOUSE_TRANSFER', customerRemark: '外接预订 FB-WRONG', businessSource: { businessType: 'LOCAL_LOOSEBOARD', label: '本土散板 · 拼车需求池', businessOrderNo: 'LB-1', externalBookingNo: 'FB-1' } }) expect(row).toMatchObject({ orderTypeCode: 'WAREHOUSE_TRANSFER', orderType: '仓储转运', businessSource: '本土散板 · 拼车需求池', businessOrderNo: 'LB-1', externalBookingNo: 'FB-1' }) const unlinked = toLastMileOrderListItem({ id: '2', customerId: 'A', orderNo: 'WT-2', customerRemark: '外接预订 FB-WRONG' }) expect(unlinked.businessOrderNo).toBe('—') expect(unlinked.externalBookingNo).toBe('—') }) it('links only known business numbers with the target list permission', () => { expect(businessOrderLink('LOCAL_LOOSEBOARD', 'LB-1', p => p.endsWith('looseboard:list'))).toEqual({ name: 'overseas-business-looseboards', query: { orderNo: 'LB-1' } }) expect(businessOrderLink('US_TRUCK', 'TRUCK-1', p => p.endsWith('truck:list'))).toEqual({ name: 'overseas-business-trucks', query: { orderNo: 'TRUCK-1' } }) expect(businessOrderLink('LOCAL_LOOSEBOARD', 'LB-1', () => false)).toBeUndefined() expect(businessOrderLink('LOCAL_LOOSEBOARD', null, () => true)).toBeUndefined() expect(businessOrderLink('WAREHOUSE_TRANSFER', 'WT-1', () => true)).toBeUndefined() }) })