import { flushPromises, shallowMount } from '@vue/test-utils' import { afterEach, describe, expect, it, vi } from 'vitest' import LoadingListDetailDrawer from './LoadingListDetailDrawer.vue' import type { LoadingDetail } from '../api/platformLoadingLists' afterEach(() => vi.restoreAllMocks()) describe('shared manifest presentation', () => { 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: '' } } }, }) 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() }) })