优化
This commit is contained in:
@@ -336,4 +336,33 @@ describe('LocationsView', () => {
|
||||
status: '',
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps the latest detail when an older location request finishes last', async () => {
|
||||
const secondLocation = { ...availableLocation, id: '9223372036854775800', locationCode: 'A1-03' }
|
||||
const firstDetail = { location: availableLocation, warehouseCode: warehouse.warehouseCode, warehouseName: warehouse.warehouseName }
|
||||
const secondDetail = { location: secondLocation, warehouseCode: warehouse.warehouseCode, warehouseName: warehouse.warehouseName }
|
||||
let resolveFirst!: (value: typeof firstDetail) => void
|
||||
let resolveSecond!: (value: typeof secondDetail) => void
|
||||
vi.mocked(getPlatformLocation).mockImplementation((_warehouseId, locationId) => new Promise((resolve) => {
|
||||
if (String(locationId) === String(availableLocation.id)) resolveFirst = resolve
|
||||
else resolveSecond = resolve
|
||||
}))
|
||||
const wrapper = await mountView()
|
||||
const vm = wrapper.vm as unknown as {
|
||||
drawerOpen: boolean
|
||||
detail: typeof firstDetail | null
|
||||
loadDetail(row: PlatformLocationResource, mode: 'view' | 'edit'): Promise<void>
|
||||
}
|
||||
|
||||
void vm.loadDetail(availableLocation, 'view')
|
||||
vm.drawerOpen = false
|
||||
await wrapper.vm.$nextTick()
|
||||
void vm.loadDetail(secondLocation, 'view')
|
||||
resolveSecond(secondDetail)
|
||||
await flushPromises()
|
||||
resolveFirst(firstDetail)
|
||||
await flushPromises()
|
||||
|
||||
expect(vm.detail?.location.locationCode).toBe('A1-03')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user