import { mount } from '@vue/test-utils' import { nextTick } from 'vue' import { beforeEach, describe, expect, it, vi } from 'vitest' import PalletLabelPrintDialog from './PalletLabelPrintDialog.vue' const preparePalletLabels = vi.fn() vi.mock('../api/platformLoadingLists', () => ({ preparePalletLabels: (...args: unknown[]) => preparePalletLabels(...args), printPalletLabels: vi.fn(), })) describe('PalletLabelPrintDialog', () => { beforeEach(() => { preparePalletLabels.mockReset().mockResolvedValue({ planId: '10', planNo: 'LP-1', containerNo: 'HLCU1723867', totalCount: 2, groups: [{ destinationWarehouseCode: 'ACY2', destinationWarehouseInternalCode: '101', destinationWarehouseName: 'ACY2', totalCount: 2, labels: [ { palletCode: 'HLCU1723867-101-001' }, { palletCode: 'HLCU1723867-101-002' }, ], }], }) }) it('shows the server-generated internal code rule and both warehouse codes', async () => { const wrapper = mount(PalletLabelPrintDialog, { props: { planId: '10', warehouseId: '20' }, global: { stubs: { AppDialog: { template: '
' }, LoadErrorState: true, Printer: true, 'el-button': { template: '' }, 'el-alert': { props: ['title'], template: '

{{ title }}

' }, 'el-radio-group': { template: '
' }, 'el-radio': { template: '' }, 'el-select': { template: '
' }, 'el-option': true, 'el-input-number': true, 'el-table': { props: ['data'], template: '
{{ data }}
' }, 'el-table-column': true, }, }, }) await wrapper.get('button').trigger('click') await nextTick() await nextTick() expect(preparePalletLabels).toHaveBeenCalledWith('10', '20') expect(wrapper.text()).toContain('HLCU1723867-FBA地址内部编号-三位序号') expect(wrapper.text()).toContain('ACY2') expect(wrapper.text()).toContain('101') expect(wrapper.text()).toContain('HLCU1723867-101-001') }) })