feat(appointment): integrate work calendar and original business actions
This commit is contained in:
@@ -2,8 +2,9 @@ import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { beforeEach, expect, it, vi } from 'vitest'
|
||||
import { onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
|
||||
import InboundOrdersView from './InboundOrdersView.vue'
|
||||
import { getFbaAppointment, updateFbaAppointment } from '../api/inboundOrders'
|
||||
vi.mock('vue-router', () => ({ useRouter: () => ({push: vi.fn()}), onBeforeRouteLeave: vi.fn(), onBeforeRouteUpdate: vi.fn() }))
|
||||
import { getFbaAppointment, updateFbaAppointment, listInboundOrders } from '../api/inboundOrders'
|
||||
const routing = vi.hoisted(() => ({ push: vi.fn() }))
|
||||
vi.mock('vue-router', () => ({ useRouter: () => routing, onBeforeRouteLeave: vi.fn(), onBeforeRouteUpdate: vi.fn() }))
|
||||
const access=vi.hoisted(()=>({canWrite:true}))
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({can: (permission:string) => !permission.endsWith(':fba-appointment') || access.canWrite}) }))
|
||||
vi.mock('../api/inboundOrders', () => ({
|
||||
@@ -48,3 +49,22 @@ it('keeps the inbound appointment retry across close, reopen and route attempts'
|
||||
expect((vi.mocked(onBeforeRouteLeave).mock.calls[0]![0] as () => boolean)()).toBe(true)
|
||||
wrapper.unmount()
|
||||
})
|
||||
it('renders MULTIPLE as multiple appointments and opens the exact source/customer instead of choosing an arbitrary appointment', async () => {
|
||||
vi.mocked(listInboundOrders).mockResolvedValueOnce({records:[{lineId:'1',planId:'plan-1',planNo:'IP-1',orderId:'9007199254740993',customerId:'customer-a',appointmentNo:null,appointmentStatus:'MULTIPLE',fbaWarehouseCode:'ONT8'}],total:1,page:1,size:10,pages:1})
|
||||
const wrapper = render(); await flushPromises()
|
||||
const button = wrapper.findAll('button').find(button => button.text() === '管理多批预约')!
|
||||
expect(button.exists()).toBe(true)
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '查看预约' || button.text() === '预约')).toBe(false)
|
||||
await button.trigger('click'); await flushPromises()
|
||||
expect(routing.push).toHaveBeenCalledWith({path:'/appointment-calendar',query:{orderId:'9007199254740993',customerId:'customer-a',destinationKey:'FBA:ONT8'}})
|
||||
expect(getFbaAppointment).not.toHaveBeenCalled(); wrapper.unmount()
|
||||
})
|
||||
it('keeps replaced appointment snapshots read-only in the inbound dialog', async () => {
|
||||
vi.mocked(getFbaAppointment).mockResolvedValueOnce({id:'1',appointmentNo:'AP-1',batchKey:'FBA_APPOINTMENT:1',replacementBatchKeys:['FBA_APPOINTMENT:2'],replacementAppointmentNos:['AP-NEW'],version:3,originWarehouseId:'100',fbaWarehouseCode:'ONT8',appointmentStatus:'PENDING',selectedCount:1,items:[]})
|
||||
const wrapper=render(); await flushPromises()
|
||||
await wrapper.findAll('button').find(button=>button.text()==='预约')!.trigger('click'); await flushPromises()
|
||||
expect(wrapper.text()).toContain('替代预约:AP-NEW')
|
||||
expect(wrapper.find('[data-save]').exists()).toBe(false)
|
||||
wrapper.findComponent({name:'AppDialog'}).vm.$emit('confirm'); await flushPromises()
|
||||
expect(updateFbaAppointment).not.toHaveBeenCalled(); wrapper.unmount()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user