This commit is contained in:
2026-08-20 18:02:52 +08:00
parent 4ae5e7c672
commit 80947cd9ce
65 changed files with 1386 additions and 1083 deletions
@@ -0,0 +1,10 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { overseasHttp } from '@/shared/api/overseasHttp'
import { getInventorySummary, listInventoryBalances, listInventoryLedger, listInventoryPositions } from './inventory'
vi.mock('@/shared/api/overseasHttp', () => ({ overseasHttp: { get: vi.fn() } }))
describe('inventory overseas API', () => {
beforeEach(() => vi.mocked(overseasHttp.get).mockReset())
it('queries SKU balances with explicit customer scope', async () => { vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'ok', data: { records: [], page: 1, size: 20, total: 0, pages: 0 } }); await listInventoryBalances({ customerId: '9', page: 1, size: 20, skuCode: 'SKU-1', productName: '产品' }); expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/last-leg/inventory/balances', { params: { customerId: '9', page: 1, size: 20, skuCode: 'SKU-1', productName: '产品' } }) })
it('uses read-only summary, positions and ledger endpoints', async () => { vi.mocked(overseasHttp.get).mockResolvedValue({ code: '200', message: 'ok', data: {} }); await getInventorySummary({ customerId: '9', skuCode: 'SKU-1' }); await listInventoryPositions('190000000000000099', '9'); await listInventoryLedger({ customerId: '9', page: 1, size: 20 }); expect(vi.mocked(overseasHttp.get).mock.calls.map((call) => call[0])).toEqual(['/platform/v1/last-leg/inventory/summary', '/platform/v1/last-leg/inventory/balances/190000000000000099/positions', '/platform/v1/last-leg/inventory/ledger']) })
it('does not expose stock-leaving commands', () => { const source = `${listInventoryBalances}${getInventorySummary}${listInventoryPositions}${listInventoryLedger}`; expect(source).not.toMatch(/allocate|unallocate|pick|ship/) })
})