优化
This commit is contained in:
@@ -4,11 +4,13 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getOutbound } from '../api/outbounds'
|
||||
import OutboundDetailView from './OutboundDetailView.vue'
|
||||
import StatusBadge from '@/shared/components/StatusBadge.vue'
|
||||
import { getPlatformWarehouse } from '@/modules/warehouses'
|
||||
|
||||
const canPermission = vi.hoisted(() => vi.fn((_code: string) => false))
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: canPermission }) }))
|
||||
vi.mock('vue-router', () => ({ useRoute: () => ({ params: { outboundNo: 'OUT/1' } }), useRouter: () => ({ push: vi.fn() }) }))
|
||||
vi.mock('../api/outbounds', () => ({ getOutbound: vi.fn(), cancelOutbound: vi.fn() }))
|
||||
vi.mock('@/modules/warehouses', () => ({ getPlatformWarehouse: vi.fn() }))
|
||||
|
||||
describe('OutboundDetailView', () => {
|
||||
it.each([
|
||||
@@ -25,6 +27,7 @@ describe('OutboundDetailView', () => {
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
vi.mocked(getPlatformWarehouse).mockReset().mockRejectedValue(new Error('Warehouse unavailable'))
|
||||
canPermission.mockReset().mockReturnValue(false)
|
||||
vi.mocked(getOutbound).mockReset().mockResolvedValue({
|
||||
outbound: { id: '1', outboundNo: 'OUT/1', dispatchNo: 'PC-1', status: 'PICKED', palletCount: 2, packageCount: 20, createdAt: '2026-09-01T10:00:00' },
|
||||
@@ -87,6 +90,24 @@ describe('OutboundDetailView', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('resolves the warehouse for a discard outbound without deliveries', async () => {
|
||||
vi.mocked(getOutbound).mockResolvedValueOnce({
|
||||
outbound: { id: '1', outboundNo: 'OB-WH-20261019-151681', outboundType: 'DISCARD_OUTBOUND', overseasWarehouseId: 'warehouse-internal-id', packageCount: 1 },
|
||||
deliveries: [],
|
||||
})
|
||||
vi.mocked(getPlatformWarehouse).mockResolvedValueOnce({
|
||||
warehouse: { id: 'warehouse-internal-id', tenantId: '0', warehouseCode: 'LAX', internalCode: null, warehouseName: '洛杉矶仓', warehouseType: 'OVERSEAS', countryCode: 'US', timezone: 'America/Los_Angeles', contactName: null, contactPhone: null, contactEmail: null, status: 'ACTIVE', remark: null },
|
||||
addresses: [], capabilities: [],
|
||||
})
|
||||
const wrapper = mount(OutboundDetailView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
expect(getPlatformWarehouse).toHaveBeenCalledWith('warehouse-internal-id')
|
||||
const label = wrapper.findAll('.el-descriptions__label').find(item => item.text() === '海外仓')!
|
||||
expect(label.element.nextElementSibling?.textContent?.trim()).toBe('洛杉矶仓')
|
||||
expect(wrapper.text()).not.toContain('warehouse-internal-id')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it.each([
|
||||
['warehouse-internal-id', '洛杉矶仓', '洛杉矶仓'],
|
||||
['warehouse-internal-id', null, '—'],
|
||||
|
||||
Reference in New Issue
Block a user