优化
This commit is contained in:
@@ -12,13 +12,25 @@ vi.mock('@/core/auth/auth', () => ({ useAuthStore: () => ({ user: identity }) })
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: () => true }) }))
|
||||
vi.mock('./DispatchResourceFields.vue', () => ({ default: { template: '<div />' } }))
|
||||
vi.mock('../api/dispatches', () => ({ markDispatchException: vi.fn(), getDispatch: vi.fn(), getDispatchItems: vi.fn(), getDispatchRoute: vi.fn(), reorderDispatchRoute: vi.fn(), removeDispatchItem: vi.fn(), getDispatchLoading: vi.fn(), getDispatchCommand: vi.fn(), listDispatches: vi.fn(), listDispatchCandidates: vi.fn(), completeDispatchLoading: vi.fn(), reviewDispatch: vi.fn(), reviewDispatchLoading: vi.fn(), returnDispatchToReview: vi.fn(), cancelDispatch: vi.fn(), updateDispatch: vi.fn(), addDispatchCargo: vi.fn(), submitDispatchReview: vi.fn() }))
|
||||
vi.mock('../api/transportTasks', () => ({ getTransport: vi.fn() }))
|
||||
import * as transportApi from '../api/transportTasks'
|
||||
interface State { exception: { exceptionType: string; returnDirection: string; description: string; imageFileIds: string[] }; submit(submitReviewAfterSave?: boolean): Promise<void>; retryError(): Promise<void>; measurements: Array<{ weightKg: number | null; volumeCbm: number | null; deliveryIndex: number | null; palletSpaces: number | null }>; form: { reason: string; decision: string; remark: string }; detail: DispatchDetail }
|
||||
async function open(action: DispatchAction, allowed = true) {
|
||||
vi.mocked(api.getDispatch).mockResolvedValue(detail({ actions: { [action]: { allowed, blockCode: null, blockReason: allowed ? null : '前置审核未通过' } } }))
|
||||
async function open(action: DispatchAction, allowed = true, overrides: Partial<DispatchDetail> = {}) {
|
||||
vi.mocked(api.getDispatch).mockResolvedValue(detail({ ...overrides, actions: { [action]: { allowed, blockCode: null, blockReason: allowed ? null : '前置审核未通过' } } }))
|
||||
const wrapper = mount(DispatchWorkflowDialog, { props: { modelValue: true, dispatchNo: 'PC/1', action }, global: { plugins: [ElementPlus] } }); await flushPromises()
|
||||
return { wrapper, state: wrapper.vm as unknown as State }
|
||||
}
|
||||
beforeEach(() => { vi.resetAllMocks(); sessionStorage.clear(); identity.id = crypto.randomUUID(); vi.stubGlobal('ResizeObserver', class { observe() {} unobserve() {} disconnect() {} }); vi.mocked(api.getDispatchLoading).mockResolvedValue(loadingPreview()) })
|
||||
it('shows only source pickup destinations in warehouse-transfer review submission', async () => {
|
||||
vi.mocked(transportApi.getTransport).mockResolvedValue({ dispatchNo: 'PC/1', taskType: 'PICKUP', execution: {} as never, customerId: null, orderNo: null, pickups: [{ pickupAddress: 'US-LAX-01 · 123 Warehouse Ave' }, { pickupAddress: 'US-LAX-01 · 123 Warehouse Ave' }] as never, completionEvidence: [], dispatchRecordVersion: 0, resources: null })
|
||||
const { wrapper } = await open('SUBMIT_REVIEW', true, { taskType: 'PICKUP', dispatchInfo: { ...detail().dispatchInfo, route: '到仓取货 · 1单 · US-LAX-01' } })
|
||||
const text = wrapper.getComponent({ name: 'ElDialogContent' }).text()
|
||||
expect(text).toContain('取货目的地')
|
||||
expect(text).toContain('US-LAX-01 · 123 Warehouse Ave')
|
||||
expect(text).not.toContain('起运地')
|
||||
expect(transportApi.getTransport).toHaveBeenCalledExactlyOnceWith('PC/1')
|
||||
wrapper.unmount()
|
||||
})
|
||||
it('confirms scanned cargo without requesting measurements and preserves native version zero', async () => {
|
||||
const value = loadingPreview(); value.pallets[0]!.weightKg = 100; value.pallets[0]!.volumeCbm = 2
|
||||
vi.mocked(api.getDispatchLoading).mockResolvedValue(value)
|
||||
|
||||
Reference in New Issue
Block a user