2026-09-01 19:57:36 +08:00
|
|
|
import ElementPlus from 'element-plus'
|
|
|
|
|
import { flushPromises, mount } from '@vue/test-utils'
|
|
|
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
|
import { getDispatch } from '../api/dispatches'
|
|
|
|
|
import DispatchDetailView from './DispatchDetailView.vue'
|
|
|
|
|
import { DataTableStub } from './phase5TestStubs'
|
|
|
|
|
|
|
|
|
|
const routerPush = vi.hoisted(() => vi.fn())
|
|
|
|
|
vi.mock('vue-router', () => ({ useRoute: () => ({ params: { dispatchNo: 'PC/1' } }), useRouter: () => ({ push: routerPush }) }))
|
|
|
|
|
vi.mock('../api/dispatches', () => ({ getDispatch: vi.fn() }))
|
|
|
|
|
|
|
|
|
|
describe('DispatchDetailView', () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
routerPush.mockReset()
|
|
|
|
|
vi.mocked(getDispatch).mockReset().mockResolvedValue({
|
|
|
|
|
id: '1', dispatchNo: 'PC/1', vehiclePlate: 'CA-100', driverName: '张师傅', status: 'PENDING_DEPARTURE',
|
2026-09-18 14:58:40 +08:00
|
|
|
route: 'LAX → ONT8', items: [{ id: '11', planPalletId: '20', orderNo: 'LM-1', warehousePalletId: '21', fbaWarehouseCode: 'ONT8', grossWeightKg: 88.5, volumeCbm: 1.25 }],
|
2026-09-01 19:57:36 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('loads the business dispatch number and renders summary and related orders', async () => {
|
|
|
|
|
const wrapper = mount(DispatchDetailView, { global: { plugins: [ElementPlus], stubs: { DataTable: DataTableStub } } })
|
|
|
|
|
await flushPromises()
|
|
|
|
|
expect(getDispatch).toHaveBeenCalledWith('PC/1')
|
|
|
|
|
expect(wrapper.text()).toContain('PC/1')
|
|
|
|
|
expect(wrapper.text()).toContain('CA-100')
|
|
|
|
|
expect(wrapper.text()).toContain('待发车')
|
|
|
|
|
const table = wrapper.findComponent(DataTableStub)
|
2026-09-18 14:58:40 +08:00
|
|
|
expect(table.props('data')).toEqual([{ orderNo: 'LM-1', weight: 88.5, palletCount: 1, fbaWarehouse: 'ONT8', volume: 1.25, containerNo: '—' }])
|
2026-09-01 19:57:36 +08:00
|
|
|
wrapper.unmount()
|
|
|
|
|
})
|
|
|
|
|
})
|