style(admin): unify dialog layouts and dense readonly presentation
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import ElementPlus from 'element-plus'
|
||||
import AppDialog from '@/shared/components/AppDialog.vue'
|
||||
import { nextTick } from 'vue'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import PalletLabelPrintDialog from './PalletLabelPrintDialog.vue'
|
||||
|
||||
const preparePalletLabels = vi.fn()
|
||||
const printPalletLabels = vi.fn()
|
||||
|
||||
vi.mock('../api/platformLoadingLists', () => ({
|
||||
preparePalletLabels: (...args: unknown[]) => preparePalletLabels(...args),
|
||||
printPalletLabels: vi.fn(),
|
||||
printPalletLabels: (...args: unknown[]) => printPalletLabels(...args),
|
||||
}))
|
||||
|
||||
describe('PalletLabelPrintDialog', () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('ResizeObserver', class { observe() {} unobserve() {} disconnect() {} })
|
||||
preparePalletLabels.mockReset().mockResolvedValue({
|
||||
planId: '10', planNo: 'LP-1', containerNo: 'HLCU1723867', totalCount: 2,
|
||||
groups: [{
|
||||
@@ -25,6 +29,35 @@ describe('PalletLabelPrintDialog', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.each([false, true])('保留按仓补打的PDF范围和文件名,dense=%s', async (dense) => {
|
||||
URL.createObjectURL = vi.fn(() => 'blob:pallet-labels')
|
||||
URL.revokeObjectURL = vi.fn()
|
||||
const downloads: string[] = []
|
||||
const click = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(function (this: HTMLAnchorElement) { downloads.push(this.download) })
|
||||
printPalletLabels.mockReset().mockResolvedValue(new Blob(['pdf'], { type: 'application/pdf' }))
|
||||
const wrapper = mount(PalletLabelPrintDialog, { props: { planId: '10', warehouseId: '20', dense }, global: { plugins: [ElementPlus] } })
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
const dialog = wrapper.getComponent(AppDialog)
|
||||
expect(dialog.props('title')).toBe(dense ? '散货托盘码 · HLCU1723867' : '散货托盘码')
|
||||
wrapper.getComponent({ name: 'ElRadioGroup' }).vm.$emit('update:modelValue', 'WAREHOUSE')
|
||||
await flushPromises()
|
||||
wrapper.getComponent({ name: 'ElInputNumber' }).vm.$emit('update:modelValue', 1)
|
||||
if (dense) {
|
||||
await dialog.get('[aria-label="展开全屏"]').trigger('click')
|
||||
expect(dialog.find('.el-dialog.is-fullscreen').exists()).toBe(true)
|
||||
expect(wrapper.getComponent({ name: 'ElInputNumber' }).props('modelValue')).toBe(1)
|
||||
}
|
||||
expect(dialog.props('confirmDisabled')).toBe(false)
|
||||
dialog.vm.$emit('confirm')
|
||||
await flushPromises()
|
||||
expect(printPalletLabels).toHaveBeenCalledWith('10', '20', 'ACY2', 1)
|
||||
expect(downloads).toEqual(['HLCU1723867-托盘码.pdf'])
|
||||
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:pallet-labels')
|
||||
wrapper.unmount()
|
||||
click.mockRestore()
|
||||
})
|
||||
|
||||
it('shows the server-generated internal code rule and both warehouse codes', async () => {
|
||||
const wrapper = mount(PalletLabelPrintDialog, {
|
||||
props: { planId: '10', warehouseId: '20' },
|
||||
|
||||
Reference in New Issue
Block a user