diff --git a/src/modules/loading-lists/components/PalletLabelPrintDialog.test.ts b/src/modules/loading-lists/components/PalletLabelPrintDialog.test.ts new file mode 100644 index 00000000..71e0822b --- /dev/null +++ b/src/modules/loading-lists/components/PalletLabelPrintDialog.test.ts @@ -0,0 +1,58 @@ +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') + }) +}) diff --git a/src/modules/loading-lists/components/PalletLabelPrintDialog.vue b/src/modules/loading-lists/components/PalletLabelPrintDialog.vue index 9ec548b9..46910295 100644 --- a/src/modules/loading-lists/components/PalletLabelPrintDialog.vue +++ b/src/modules/loading-lists/components/PalletLabelPrintDialog.vue @@ -50,7 +50,7 @@ async function print() {