test(admin): harden booking document workflows

This commit is contained in:
2026-08-31 21:05:03 +08:00
parent 623dfce255
commit 49babd731a
5 changed files with 79 additions and 28 deletions
@@ -54,4 +54,26 @@ describe('OceanBookingPrintDialog', () => {
expect(document.body.textContent).toContain('trace-print')
failed.unmount()
})
it('suppresses duplicate preview clicks and restores loading after completion', async () => {
let resolvePrint!: (blob: Blob) => void
vi.mocked(downloadOceanBookingPrint).mockImplementation(() => new Promise<Blob>((resolve) => { resolvePrint = resolve }))
const wrapper = mount(OceanBookingPrintDialog, {
props: { modelValue: true, bookingId: '123', bookingNo: 'OB-123', allowed: true },
global: { plugins: [ElementPlus] },
attachTo: document.body,
})
await flushPromises()
await wrapper.findAll('.booking-print-option')[0]!.trigger('click')
const preview = Array.from(document.body.querySelectorAll('button')).find((button) => button.textContent?.includes('预览 PDF'))!
preview.click()
preview.click()
await flushPromises()
expect(downloadOceanBookingPrint).toHaveBeenCalledTimes(1)
expect(preview.disabled).toBe(true)
resolvePrint(new Blob(['pdf'], { type: 'application/pdf' }))
await flushPromises()
expect(document.body.querySelector('iframe')).not.toBeNull()
wrapper.unmount()
})
})