This commit is contained in:
2026-08-18 09:09:34 +08:00
parent dcbca0bf85
commit 8046f9b9ee
27 changed files with 230 additions and 83 deletions
@@ -1,4 +1,4 @@
import ElementPlus, { ElMessageBox } from 'element-plus'
import ElementPlus, { ElMessage, ElMessageBox } from 'element-plus'
import { createPinia, setActivePinia } from 'pinia'
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils'
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -275,6 +275,7 @@ describe('InboundMeasurementPanel', () => {
})
it('shows a normal A0409 business reason instead of relabeling it as a version conflict', async () => {
const messageSpy = vi.spyOn(ElMessage, 'error')
vi.mocked(updateConfirmedPackageCount).mockRejectedValueOnce(
new ApiResponseError('该托盘已被占用,请重新选择', 'A0409', 409),
)
@@ -285,11 +286,31 @@ describe('InboundMeasurementPanel', () => {
await save?.trigger('click')
await flushPromises()
expect(wrapper.text()).toContain('该托盘已被占用,请重新选择')
expect(wrapper.text()).toContain('操作未完成')
expect(messageSpy).toHaveBeenCalledWith(expect.objectContaining({
message: '该托盘已被占用,请重新选择',
showClose: true,
duration: 4500,
}))
expect(wrapper.text()).not.toContain('操作未完成')
expect(wrapper.text()).not.toContain('数据版本已变化,当前修改尚未丢失')
})
it('reports draft validation as a dismissible light message without a fixed page alert', async () => {
const messageSpy = vi.spyOn(ElMessage, 'warning')
vi.mocked(getInboundMeasurement).mockResolvedValueOnce(measurement({ items: [] }))
const wrapper = await mountPanel()
const save = wrapper.findAll('button').find((button) => button.text().includes('保存测量数据'))
await save?.trigger('click')
await flushPromises()
expect(messageSpy).toHaveBeenCalledWith(expect.objectContaining({
message: '请至少保留一条实际扫描箱测量记录',
showClose: true,
duration: 4500,
}))
expect(wrapper.text()).not.toContain('请修正测量草稿中的问题')
})
it('requires the dirty draft to be saved before submitting for review', async () => {
const wrapper = await mountPanel()
const countInput = wrapper.find('.measurement-count-editor input')