修改
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import ElementPlus from 'element-plus'
|
||||
import ElementPlus, { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { AxiosError } from 'axios'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import QueryToolbar from '@/shared/components/QueryToolbar.vue'
|
||||
import GlobalSmartLoadingView from './GlobalSmartLoadingView.vue'
|
||||
import {
|
||||
getSmartLoadingPlanByBooking,
|
||||
listContainers,
|
||||
listSmartLoadingCandidates,
|
||||
recommendSmartLoading,
|
||||
removeSmartLoadingItem,
|
||||
} from '../api/platformContainerLoading'
|
||||
|
||||
vi.mock('@/core/access/accessPreview', () => ({
|
||||
@@ -67,6 +69,14 @@ describe('GlobalSmartLoadingView', () => {
|
||||
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
|
||||
const statusField = wrapper.findComponent(QueryToolbar).props('fields')
|
||||
.find((field: { key: string }) => field.key === 'status')
|
||||
expect(statusField?.options).toEqual([
|
||||
{ label: '待装柜', value: 'WAIT_LOADING' },
|
||||
{ label: '预装柜中', value: 'EDITING' },
|
||||
{ label: '拣货中', value: 'LOADING' },
|
||||
])
|
||||
|
||||
expect(wrapper.text()).not.toContain('税率')
|
||||
expect(wrapper.text()).not.toContain('是否退税')
|
||||
expect(wrapper.text()).not.toContain('美森正班')
|
||||
@@ -93,7 +103,7 @@ describe('GlobalSmartLoadingView', () => {
|
||||
|
||||
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledWith(loadingContainer.id)
|
||||
expect(wrapper.text()).toContain('CB-LOADING')
|
||||
expect(wrapper.text()).toContain('装柜中')
|
||||
expect(wrapper.text()).toContain('拣货中')
|
||||
expect(wrapper.text()).not.toContain('CB-COMPLETED')
|
||||
expect(wrapper.text()).toContain('智能推荐')
|
||||
expect(wrapper.text()).toContain('加入')
|
||||
@@ -123,4 +133,31 @@ describe('GlobalSmartLoadingView', () => {
|
||||
expect(wrapper.text()).toContain('已刷新最新版本')
|
||||
expect(wrapper.text()).toContain('request-1')
|
||||
})
|
||||
|
||||
it('shows a picking-specific message when a picked order cannot be removed', async () => {
|
||||
const loadingContainer = { ...container, planStatus: 'LOADING' as const }
|
||||
const loadingPlan = { ...plan, status: 'LOADING' as const }
|
||||
vi.mocked(listContainers).mockResolvedValue({ records: [loadingContainer], page: 1, size: 100, total: 1, pages: 1 })
|
||||
vi.mocked(getSmartLoadingPlanByBooking).mockResolvedValue(loadingPlan)
|
||||
vi.mocked(removeSmartLoadingItem).mockRejectedValue(new AxiosError(
|
||||
'conflict',
|
||||
'ERR_BAD_REQUEST',
|
||||
undefined,
|
||||
undefined,
|
||||
{ data: { code: 'A0409', message: '已有拣货记录的明细不能删除' }, status: 200, statusText: 'OK', headers: {}, config: {} as never },
|
||||
))
|
||||
vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm' as never)
|
||||
const errorMessage = vi.spyOn(ElMessage, 'error').mockImplementation(() => undefined as never)
|
||||
|
||||
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
const removeButton = wrapper.find('.row-actions .el-button--danger')
|
||||
expect(removeButton.exists()).toBe(true)
|
||||
await removeButton.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(removeSmartLoadingItem).toHaveBeenCalled()
|
||||
expect(errorMessage).toHaveBeenCalledWith('该订单在拣货中不许删除')
|
||||
expect(wrapper.text()).toContain('该订单在拣货中不许删除')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user