import { describe, expect, it } from 'vitest' import { inventoryProductName, toInventoryListItem } from './inventoryPresentation' describe('overseas inventory presentation adapter', () => { it('maps the latest singular balance DTO fields without inventing position data', () => { const row = toInventoryListItem({ id: '2089652067743272963', customerId: '990018', customerName: 'Acceptance Customer', overseasWarehouseId: '990018000000000001', overseasWarehouseName: 'Acceptance US Warehouse', inboundOrderId: '2089652066950549505', inboundOrderNo: 'LIP2089652067021852673', inboundCode: 'ACCEPT-20260818-R4-IN-03B', skuCode: 'SKU-ACCEPT-1', productNameZh: '验收商品', productNameEn: 'Acceptance Product', totalPackages: 20, availablePackages: 18, holdPackages: 2, allocatedPackages: 0, pickedPackages: 0, inTransitPackages: 0, receivingPackages: 0, procurementPackages: 0, updatedAt: '2026-08-18T17:54:11', }) expect(row).toMatchObject({ id: '2089652067743272963', customerId: '990018', owner: 'Acceptance Customer', warehouse: 'Acceptance US Warehouse', sku: 'SKU-ACCEPT-1', productName: '验收商品', location: '—', onHand: 20, available: 18, held: 2, status: '存在暂扣', updatedAt: '2026-08-18 17:54:11', }) }) it('shows an unknown owner as a dash and never substitutes customerId', () => { const row = toInventoryListItem({ id: '1', customerId: '2092618717861048321', customerName: null, overseasWarehouseId: '3', inboundOrderId: '4', inboundCode: 'IN-1', totalPackages: 1, availablePackages: 1, holdPackages: 0, allocatedPackages: 0, pickedPackages: 0, inTransitPackages: 0, receivingPackages: 0, procurementPackages: 0, }) expect(row.owner).toBe('—') expect(row.owner).not.toBe(row.customerId) }) it('uses only the formal overseas warehouse name snapshot', () => { const row = toInventoryListItem({ id: '1', customerId: '2', customerName: '客户甲', overseasWarehouseId: '3', overseasWarehouseCode: 'LAX', overseasWarehouseName: null, destinationWarehouseName: 'ONT8目的仓', inboundOrderId: '4', inboundCode: 'IN-1', totalPackages: 1, availablePackages: 1, holdPackages: 0, allocatedPackages: 0, pickedPackages: 0, inTransitPackages: 0, receivingPackages: 0, procurementPackages: 0, }) expect(row.warehouse).toBe('—') expect(row.warehouse).not.toBe('LAX') expect(row.warehouse).not.toBe('ONT8目的仓') }) it('falls back to the English product name only when the Chinese name is absent', () => { expect(inventoryProductName({ id: '1', customerId: '2', overseasWarehouseId: '3', inboundOrderId: '4', inboundCode: 'IN-1', productNameEn: 'English Product', totalPackages: 0, availablePackages: 0, holdPackages: 0, allocatedPackages: 0, pickedPackages: 0, inTransitPackages: 0, receivingPackages: 0, procurementPackages: 0, })).toBe('English Product') }) })