优化
This commit is contained in:
@@ -87,6 +87,36 @@ describe('TruckAppointmentForm booking-only behavior', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('ignores stale booking details when the user switches selections quickly', async () => {
|
||||
let resolveFirst!: (value: ReturnType<typeof detail>) => void
|
||||
let resolveSecond!: (value: ReturnType<typeof detail>) => void
|
||||
vi.mocked(getOceanBooking).mockImplementation((id) => new Promise((resolve) => {
|
||||
if (id === 'booking-1') resolveFirst = resolve as typeof resolveFirst
|
||||
else resolveSecond = resolve as typeof resolveSecond
|
||||
}) as never)
|
||||
const wrapper = mount(TruckAppointmentForm, { props: { modelValue: { ...model } }, global: { plugins: [ElementPlus] } })
|
||||
await flushPromises()
|
||||
const bookingSelect = wrapper.findAllComponents({ name: 'ElSelect' })[0]!
|
||||
bookingSelect.vm.$emit('update:modelValue', 'booking-1')
|
||||
await flushPromises()
|
||||
bookingSelect.vm.$emit('update:modelValue', 'booking-2')
|
||||
await flushPromises()
|
||||
|
||||
resolveSecond(detail('booking-2'))
|
||||
await flushPromises()
|
||||
resolveFirst({ ...detail('booking-1'), documents: [] })
|
||||
await flushPromises()
|
||||
|
||||
const labels = wrapper.findAllComponents({ name: 'ElOption' }).map((option) => String(option.props('label') || ''))
|
||||
expect(labels.some((label) => label.includes('CAB-2'))).toBe(true)
|
||||
expect(labels.some((label) => label.includes('CAB-1'))).toBe(false)
|
||||
expect(wrapper.text()).not.toContain('所选订舱缺少有效的订舱确认文件或提单文件')
|
||||
const emitted = wrapper.emitted('update:modelValue')?.at(-1)?.[0] as SaveTruckAppointmentRequest
|
||||
expect(emitted.oceanBookingId).toBe('booking-2')
|
||||
expect(emitted.billOfLadingNo).toBe('BL-2')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('preserves the business code and request trace when booking readiness fails', async () => {
|
||||
vi.mocked(getOceanBooking).mockRejectedValueOnce(new ApiResponseError('订舱版本冲突', 'A0409', 409, undefined, 'req-booking', 'trace-booking'))
|
||||
const wrapper = mount(TruckAppointmentForm, { props: { modelValue: { ...model } }, global: { plugins: [ElementPlus] } })
|
||||
|
||||
Reference in New Issue
Block a user