fix(appointments): open canonical dispatch details from calendar

This commit is contained in:
2026-10-20 16:36:21 +08:00
parent 291535e242
commit da4cb9c8ad
7 changed files with 78 additions and 26 deletions
@@ -19,6 +19,21 @@ vi.mock('@/modules/overseas-master-data', async () => ({
const options = { global: { plugins: [ElementPlus], stubs: { DataTable: DataTableStub, DispatchWorkflowDialog: true } } }
beforeEach(() => { vi.clearAllMocks(); vi.mocked(getDispatch).mockResolvedValue(detail()); can.mockReturnValue(false); push.mockReset(); Object.keys(query).forEach(key => delete query[key]) })
describe('whole-dispatch four-tab detail', () => {
it('returns to the original appointment date and view from the dispatch detail', async () => {
query.appointmentReturn = '/appointment-calendar?date=2026-10-21&mode=week'
const wrapper = mount(DispatchDetailView, options); await flushPromises()
expect(wrapper.get('button.density-back').text()).toContain('返回预约日历')
await wrapper.get('button.density-back').trigger('click')
expect(push).toHaveBeenCalledWith('/appointment-calendar?date=2026-10-21&mode=week')
wrapper.unmount()
})
it('ignores an external calendar return URL and keeps the normal dispatch-list return', async () => {
query.appointmentReturn = 'https://outside.invalid/appointment-calendar?date=2026-10-21'
const wrapper = mount(DispatchDetailView, options); await flushPromises()
await wrapper.get('button.density-back').trigger('click')
expect(push).toHaveBeenCalledWith({ name: 'overseas-dispatches' })
wrapper.unmount()
})
it('uses only four accessible colored tabs and switches without another network read', async () => {
const value = detail(); value.dispatchInfo.fbaAppointments = [{ batchKey: 'FBA_APPOINTMENT:1', batchNo: 'BATCH-1', appointmentNo: 'FBA-AP-1', destinationKey: 'FBA:ONT8', destinationWarehouseCode: 'ONT8', status: 'CONFIRMED', confirmedAt: null, blockReason: null }]
vi.mocked(getDispatch).mockResolvedValueOnce(value)