116 lines
6.6 KiB
TypeScript
116 lines
6.6 KiB
TypeScript
import { flushPromises, shallowMount } from '@vue/test-utils'
|
|||
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||
|
|
import { getLoadingAssociationSummary, getOverseasInboundCodeRelationship } from '@/shared/api/inboundCodeRelations'
|
||
|
|
import { getPlatformUnifiedOrder } from '@/modules/unified-orders/api/unifiedOrders'
|
||
|
|
import UnifiedOrdersView from './UnifiedOrdersView.vue'
|
||
|
|
|
||
|
|
vi.mock('vue-router', () => ({
|
||
|
|
useRoute: () => ({ params: { orderId: '5001' }, query: { tenantId: '6001' } }),
|
||
|
|
useRouter: () => ({ push: vi.fn() }),
|
||
|
|
}))
|
||
|
|
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: () => true }) }))
|
||
|
|
vi.mock('@/modules/iam', () => ({ listPlatformTenants: vi.fn().mockResolvedValue({ records: [], page: 1, size: 200, total: 0, pages: 0 }) }))
|
||
|
|
vi.mock('@/modules/warehouses', () => ({ listAllPlatformWarehouses: vi.fn().mockResolvedValue([]) }))
|
||
|
|
vi.mock('@/modules/inbounds', () => ({
|
||
|
|
downloadWeightImage: vi.fn(), getInboundMeasurement: vi.fn(),
|
||
|
|
InboundFeePanel: { template: '<div />' }, InboundMeasurementDialog: { template: '<div />' }, MeasurementEvidenceThumbnail: { template: '<div />' },
|
||
|
|
}))
|
||
|
|
vi.mock('@/modules/unified-orders/workflows', () => ({ UnifiedOrderWorkflowPanel: { template: '<div />' } }))
|
||
|
|
vi.mock('@/modules/unified-orders/api/coLoadGroups', () => ({
|
||
|
|
createPlatformCoLoadGroup: vi.fn(), getPlatformCoLoadGroupByInboundCode: vi.fn(),
|
||
|
|
}))
|
||
|
|
vi.mock('@/shared/api/inboundCodeRelations', () => ({
|
||
|
|
getLoadingAssociationSummary: vi.fn(), getOverseasInboundCodeRelationship: vi.fn(),
|
||
|
|
}))
|
||
|
|
vi.mock('@/modules/unified-orders/api/unifiedOrders', () => ({
|
||
|
|
addPlatformUnifiedOrderNote: vi.fn(), approvePlatformUnifiedOrder: vi.fn(), batchApprovePlatformUnifiedOrders: vi.fn(),
|
||
|
|
getPlatformUnifiedOrder: vi.fn(), listPlatformUnifiedOrderFeeDetails: vi.fn(), listPlatformUnifiedOrders: vi.fn(),
|
||
|
|
unifiedOrderStatusOptions: [],
|
||
|
|
}))
|
||
|
|
|
||
|
|
const detail = {
|
||
|
|
summary: {
|
||
|
|
orderId: '5001', tenantId: '6001', orderNo: 'ORD-HIDDEN', mainStatus: 'WAIT_SPLIT', nextAction: null, relation: null,
|
||
|
|
internalOrderStatus: 'WAIT_SPLIT', customerId: '6001', customerName: '测试客户', channelName: '纽约渠道',
|
||
|
|
receivingWarehouseId: '8', receivingWarehouseName: '义乌仓', destinationWarehouseId: '9', destinationWarehouseName: 'ONT8',
|
||
|
|
inboundId: '7001', inboundVersion: 1, inboundCode: 'NYEXX2608310001', expectedShipDate: null, totalPackageCount: 2,
|
||
|
|
locationCodes: null, actualGrossWeightKg: null, actualVolumeCbm: null, measurement: null, preload: null, loading: null, delivery: null, transport: null,
|
||
|
|
coLoadGroup: null, createdAt: null, updatedAt: null, expectedArrivalAt: null, feeReviewStatus: null, requestedPickupAt: null,
|
||
|
|
totalPalletCount: null, chargeableVolumeCbm: null, volumetricWeightKg: null, totalNetWeightKg: null,
|
||
|
|
measurementCompletedAt: null, inboundCompletedAt: null, expressCompany: null, expressTrackingNo: null, skuNos: null,
|
||
|
|
totalQuantity: null, shipmentId: null, referenceId: null,
|
||
|
|
},
|
||
|
|
order: { order: null, cargoes: [], parties: [], internalNotes: [], statusHistory: [] },
|
||
|
|
timeline: [],
|
||
|
|
}
|
||
|
|
|
||
|
|
function mountDetail() {
|
||
|
|
return shallowMount(UnifiedOrdersView, {
|
||
|
|
global: {
|
||
|
|
directives: { loading: () => undefined },
|
||
|
|
stubs: {
|
||
|
|
AdminPage: { template: '<main><slot /></main>' },
|
||
|
|
DetailPageLayout: { template: '<section><slot /></section>' },
|
||
|
|
OrderFulfillmentTreePanel: { template: '<div data-testid="fulfillment-tree" />' },
|
||
|
|
LoadErrorState: { props: ['title', 'message'], template: '<div>{{ title }} {{ message }}<slot name="details" /></div>' },
|
||
|
|
ApiErrorMeta: true,
|
||
|
|
StatusBadge: true,
|
||
|
|
'el-button': { template: '<button @click="$emit(\'click\')"><slot /></button>' },
|
||
|
|
},
|
||
|
|
},
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
describe('UnifiedOrdersView downstream fulfillment detail', () => {
|
||
|
|
beforeEach(() => {
|
||
|
|
vi.clearAllMocks()
|
||
|
|
vi.mocked(getPlatformUnifiedOrder).mockResolvedValue(detail as never)
|
||
|
|
vi.mocked(getLoadingAssociationSummary).mockResolvedValue({
|
||
|
|
inboundId: '7001', inboundCode: 'NYEXX2608310001', loadingPlanId: null, loadingPlanNo: null,
|
||
|
|
containerBookingId: null, cabinetNo: null, containerNo: null, loadingStatus: null, taskId: null,
|
||
|
|
pdaTaskStatus: null, coLoadGroupId: null, coLoadGroupNo: null, items: [],
|
||
|
|
})
|
||
|
|
vi.mocked(getOverseasInboundCodeRelationship).mockResolvedValue({
|
||
|
|
inboundCode: 'NYEXX2608310001', found: false, customer: null, overseasWarehouse: null,
|
||
|
|
overseasReceivingStatus: null, taillegOrders: [], inboundPlans: [], palletCodes: [], inventory: [],
|
||
|
|
})
|
||
|
|
})
|
||
|
|
|
||
|
|
it('shows a compact empty state in order detail when no downstream relationship exists', async () => {
|
||
|
|
const wrapper = mountDetail()
|
||
|
|
await flushPromises()
|
||
|
|
await wrapper.findAll('.detail-tabs button').find((button) => button.text().includes('拆分履约'))!.trigger('click')
|
||
|
|
await flushPromises()
|
||
|
|
expect(getLoadingAssociationSummary).toHaveBeenCalledWith('NYEXX2608310001')
|
||
|
|
expect(getOverseasInboundCodeRelationship).toHaveBeenCalledWith('NYEXX2608310001')
|
||
|
|
expect(wrapper.text()).toContain('暂无后续履约数据')
|
||
|
|
expect(wrapper.text()).not.toContain('新增关联')
|
||
|
|
})
|
||
|
|
|
||
|
|
it('renders actual loading and overseas business identifiers inside order detail', async () => {
|
||
|
|
vi.mocked(getLoadingAssociationSummary).mockResolvedValue({
|
||
|
|
inboundId: '7001', inboundCode: 'NYEXX2608310001', loadingPlanId: '9001', loadingPlanNo: 'LP-260831-001',
|
||
|
|
containerBookingId: '9002', cabinetNo: 'CAB-260831-001', containerNo: 'MSCU1234567', loadingStatus: 'LOADING',
|
||
|
|
taskId: '9003', pdaTaskStatus: 'IN_PROGRESS', coLoadGroupId: null, coLoadGroupNo: null, items: [],
|
||
|
|
})
|
||
|
|
vi.mocked(getOverseasInboundCodeRelationship).mockResolvedValue({
|
||
|
|
inboundCode: 'NYEXX2608310001', found: true, customer: null,
|
||
|
|
overseasWarehouse: { warehouseId: '9004', warehouseCode: 'LAX', warehouseName: '洛杉矶海外仓' },
|
||
|
|
overseasReceivingStatus: 'RECEIVING', taillegOrders: [{ orderNo: 'LL-260831-001' }],
|
||
|
|
inboundPlans: [{ planNo: 'IP-260831-001' }], palletCodes: ['PLT-LAX-001'],
|
||
|
|
inventory: [{ skuCode: 'SKU-001', packageCount: 2 }],
|
||
|
|
})
|
||
|
|
const wrapper = mountDetail()
|
||
|
|
await flushPromises()
|
||
|
|
await wrapper.findAll('.detail-tabs button').find((button) => button.text().includes('拆分履约'))!.trigger('click')
|
||
|
|
await flushPromises()
|
||
|
|
expect(wrapper.text()).toContain('LP-260831-001')
|
||
|
|
expect(wrapper.text()).toContain('MSCU1234567')
|
||
|
|
expect(wrapper.text()).toContain('LL-260831-001')
|
||
|
|
expect(wrapper.text()).toContain('IP-260831-001')
|
||
|
|
expect(wrapper.text()).toContain('PLT-LAX-001')
|
||
|
|
expect(wrapper.text()).not.toContain('9001')
|
||
|
|
expect(wrapper.text()).not.toContain('9004')
|
||
|
|
})
|
||
|
|
})
|