This commit is contained in:
2026-08-07 20:07:37 +08:00
parent 28d0b81c5a
commit 99413ee155
27 changed files with 1065 additions and 595 deletions
@@ -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')
})
})