54 lines
3.1 KiB
TypeScript
54 lines
3.1 KiB
TypeScript
import { flushPromises, mount, shallowMount } from '@vue/test-utils'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import ElementPlus from 'element-plus'
|
|
import LoadingListDetailDrawer from './LoadingListDetailDrawer.vue'
|
|
import type { LoadingDetail } from '../api/platformLoadingLists'
|
|
|
|
afterEach(() => vi.restoreAllMocks())
|
|
|
|
describe('shared manifest presentation', () => {
|
|
it('names producer events and retains separate adjustments even when their visible facts match', async () => {
|
|
const actions = ['CREATE_PLAN', 'ADD_INBOUND', 'ADJUST_ITEM', 'ADJUST_ITEM', 'REMARKS', 'UPDATE_PRELOAD_TRANSPORT']
|
|
const wrapper = mount(LoadingListDetailDrawer, {
|
|
props: { mode: 'confirmed', canEdit: false, loading: false, error: null,
|
|
detail: {
|
|
summary: { planId: '1', warehouseId: '11', loadingListNo: 'LP-TEST', status: 'COMPLETED' }, items: [],
|
|
histories: actions.map((actionType, index) => ({
|
|
historyId: String(index + 1), operationId: `operation-${index + 1}`, itemId: null, actionType,
|
|
fromStatus: 'EDITING', toStatus: 'EDITING', beforeSnapshot: null, afterSnapshot: null,
|
|
operatorId: '7', operatorName: '操作员', operationReason: null, occurredAt: '2026-10-21T10:00:00',
|
|
})),
|
|
} as unknown as LoadingDetail },
|
|
global: { plugins: [ElementPlus], directives: { loading: {} }, stubs: { DataTable: true } },
|
|
})
|
|
await flushPromises()
|
|
const rows = wrapper.findAll('.history-section .el-table__body tbody tr')
|
|
expect(rows).toHaveLength(6)
|
|
expect(rows.map(row => row.findAll('td')[1]!.text())).toEqual([
|
|
'创建计划', '加入入仓货物', '调整箱数', '调整箱数', '修改备注', '修改预装运输信息',
|
|
])
|
|
expect(wrapper.get('.history-section__toggle').text()).toContain('6 条')
|
|
expect(wrapper.get('.history-section').text()).not.toContain('状态更新')
|
|
wrapper.unmount()
|
|
})
|
|
|
|
it.each([undefined, '返回货柜概览'])('keeps print in the common header and emits return for %s', async (backLabel) => {
|
|
const print = vi.spyOn(window, 'print').mockImplementation(() => {})
|
|
const wrapper = shallowMount(LoadingListDetailDrawer, {
|
|
props: { mode: 'confirmed', dense: true, backLabel, canEdit: false, loading: false, error: null,
|
|
detail: { summary: { planId: '1', warehouseId: '11', loadingListNo: 'LP-TEST', status: 'COMPLETED' }, items: [], histories: [] } as unknown as LoadingDetail },
|
|
global: { directives: { loading: {} }, stubs: { ElButton: { template: '<button><slot /></button>' } } },
|
|
})
|
|
expect(wrapper.classes()).toContain('loading-density')
|
|
expect(wrapper.get('h1').text()).toBe('装柜清单 · LP-TEST')
|
|
const button = wrapper.get('.detail-page-header__actions button')
|
|
expect(button.text()).toBe('打印装柜清单')
|
|
await button.trigger('click'); await flushPromises()
|
|
expect(print).toHaveBeenCalledTimes(1)
|
|
expect(wrapper.get('.detail-page-header__back').text()).toBe(backLabel || '返回列表')
|
|
await wrapper.get('.detail-page-header__back').trigger('click')
|
|
expect(wrapper.emitted('back')).toHaveLength(1)
|
|
wrapper.unmount()
|
|
})
|
|
})
|