This commit is contained in:
2026-11-05 17:46:01 +08:00
parent 40095a749b
commit 8d80074266
6 changed files with 61 additions and 4 deletions
@@ -54,7 +54,7 @@ it('hides the single delivery selector and saves receipt files to that delivery
await wrapper.get('.save').trigger('click'); await flushPromises()
expect(saveDeliveryDocuments).toHaveBeenCalledWith('DL-1', '101', expect.objectContaining({ bolNo: 'BOL-ORIGINAL', documents: [{ category: 'LOADING_PHOTO', fileIds: [] }, { category: 'BOL', fileIds: [] }, { category: 'RECEIPT', fileIds: ['99'] }] }))
expect(wrapper.emitted('saved')).toHaveLength(1)
expect(wrapper.getComponent(DeliveryDocumentsDialog).props('modelValue')).toBe(true)
expect(wrapper.emitted('update:modelValue')).toEqual([[false]])
wrapper.unmount()
})
it('switches customer scope exactly and keeps unsaved delivery edits when switching tabs', async () => {
@@ -91,6 +91,18 @@ it('switches customer scope exactly and keeps unsaved delivery edits when switch
expect(saveDeliveryDocuments).not.toHaveBeenCalled()
confirmation.mockRestore(); wrapper.unmount()
})
it('keeps the management dialog and draft open when saving fails', async () => {
vi.mocked(saveDeliveryDocuments).mockRejectedValue(new Error('保存失败'))
const wrapper = setup(); await flushPromises()
const receipt = wrapper.getComponent(DeliveryDocumentsDialog)
await receipt.findAll('button').find(button => button.text() === '删除')!.trigger('click')
await wrapper.get('.save').trigger('click'); await flushPromises()
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
expect(wrapper.emitted('saved')).toBeUndefined()
expect(receipt.text()).not.toContain('existing-pod.pdf')
expect(wrapper.text()).toContain('保存失败')
wrapper.unmount()
})
it('does not request delivery documents without delivery list permission', async () => {
can.mockImplementation((value?: string) => value !== 'platform:overseas-warehouse:delivery:list')
const wrapper = setup(); await flushPromises()
@@ -55,7 +55,7 @@ async function canLeave() {
async function selectDelivery(value: string) { if (value !== selected.value && await canLeave()) selected.value = value }
async function beforeClose(done: () => void) { if (await canLeave()) done() }
function selectTab(value: string) { if (!busy.value) { tab.value = value } }
function saved() { emit('saved') }
function saved() { open.value = false; emit('saved') }
function pickupCompleted() { open.value = false; emit('saved') }
async function loadingSaved() { emit('saved'); await load() }
watch(() => [open.value, props.dispatchNo] as const, ([visible]) => {