This commit is contained in:
2026-10-22 11:56:54 +08:00
parent 090431b409
commit 3e77c3976e
40 changed files with 976 additions and 241 deletions
@@ -33,6 +33,7 @@ describe('OceanBookingPrintDialog', () => {
await flushPromises()
expect(downloadOceanBookingPrint).toHaveBeenCalledWith('123', 'SHIPPING_INSTRUCTION')
expect(wrapper.emitted('previewed')).toEqual([[{ bookingId: '123', type: 'SHIPPING_INSTRUCTION' }]])
expect(document.body.querySelector('iframe')?.getAttribute('src')).toBe('blob:booking-print')
expect(document.body.querySelector('.el-dialog__title')?.textContent).toBe('出口货物托运单 · OB-123')
document.querySelector<HTMLButtonElement>('[aria-label="展开全屏"]')!.click()
@@ -144,4 +145,24 @@ describe('OceanBookingPrintDialog identity and resource lifecycle', () => {
wrapper.unmount()
expect(URL.revokeObjectURL).toHaveBeenCalledExactlyOnceWith('blob:current-print')
})
it('opens the selected document directly and reloads the other type after closing', async () => {
vi.stubGlobal('URL', { createObjectURL: vi.fn(() => 'blob:booking-print'), revokeObjectURL: vi.fn() })
vi.mocked(downloadOceanBookingPrint).mockResolvedValue(new Blob(['pdf'], { type: 'application/pdf' }))
const wrapper = mount(OceanBookingPrintDialog, {
props: { modelValue: true, bookingId: '123', bookingNo: 'OB-123', allowed: true, initialType: 'SHIPPING_INSTRUCTION' },
global: { plugins: [ElementPlus] }, attachTo: document.body,
})
await flushPromises()
expect(downloadOceanBookingPrint).toHaveBeenLastCalledWith('123', 'SHIPPING_INSTRUCTION')
expect(document.body.querySelector('iframe')).not.toBeNull()
await wrapper.setProps({ modelValue: false })
await flushPromises()
expect(URL.revokeObjectURL).toHaveBeenCalledWith('blob:booking-print')
await wrapper.setProps({ initialType: 'BILL_OF_LADING_CONFIRMATION', modelValue: true })
await flushPromises()
expect(downloadOceanBookingPrint).toHaveBeenLastCalledWith('123', 'BILL_OF_LADING_CONFIRMATION')
expect(document.body.querySelector('.el-dialog__title')?.textContent).toBe('提单确认件 · OB-123')
wrapper.unmount()
})
})