fix(fleet): preserve retry intent and restore inquiry editing

This commit is contained in:
2026-10-03 13:00:32 +08:00
parent 0b5094dd8f
commit 3440f9dd11
9 changed files with 152 additions and 14 deletions
@@ -16,7 +16,7 @@ function mount() {
const field = { props: ['modelValue'], emits: ['update:modelValue'], template: '<input />' }
const wrapper = shallowMount(TripBookingPanel, { props: { trip }, global: { stubs: {
DataTable: { props: ['data'], template: '<div><slot name="toolbar-actions"/><div v-for="row in data" :key="row.bookingNo"><slot name="actions" :row="row"/></div></div>' },
AppDialog: { name: 'AppDialog', props: ['modelValue'], emits: ['confirm'], template: '<div v-if="modelValue"><slot/></div>' },
AppDialog: { name: 'AppDialog', props: ['modelValue', 'showConfirm'], emits: ['confirm', 'update:modelValue'], template: '<div v-if="modelValue"><slot/></div>' },
ElButton: { props: ['disabled'], template: '<button :disabled="disabled"><slot/></button>' },
ElForm: { template: '<div><slot/></div>' }, ElFormItem: { template: '<div><slot/></div>' },
ElSelect: { ...field, name: 'ElSelect' }, ElInputNumber: { ...field, name: 'ElInputNumber' }, ElInput: field, ElOption: true,
@@ -55,3 +55,20 @@ it('opens reactive booking data for editing and read-only details without losing
wrapper.findComponent({ name: 'AppDialog' }).vm.$emit('confirm'); await flushPromises()
expect(api.updateTripBooking).not.toHaveBeenCalled(); expect(api.createTripBooking).not.toHaveBeenCalled()
})
it('can edit an inquiry after closing its read-only details', async () => {
const wrapper = mount(); await flushPromises()
await button(wrapper, '详情').trigger('click'); await flushPromises()
const dialog = wrapper.findComponent({ name: 'AppDialog' })
expect(dialog.props('showConfirm')).toBe(false)
dialog.vm.$emit('update:modelValue', false); await flushPromises()
expect(button(wrapper, '编辑').attributes('disabled')).toBeUndefined()
await button(wrapper, '编辑').trigger('click'); await flushPromises()
expect(dialog.props('showConfirm')).toBe(true)
vi.mocked(api.updateTripBooking).mockResolvedValue({ tripRecordVersion: 5, booking: { ...row, recordVersion: 1 }, replayed: false })
dialog.vm.$emit('confirm'); await flushPromises()
expect(api.updateTripBooking).toHaveBeenCalledWith('TR-1', 'FB-1', {
tripRecordVersion: 4, recordVersion: 0, cargo: row.cargo,
})
expect(api.listTripBookings).toHaveBeenCalledOnce()
})