perf: deduplicate order product image requests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { flushPromises, shallowMount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getLoadingAssociationSummary, getOverseasInboundCodeRelationship } from '@/shared/api/inboundCodeRelations'
|
||||
import { getPlatformUnifiedOrder, listPlatformUnifiedOrders } from '@/modules/unified-orders/api/unifiedOrders'
|
||||
import { downloadPlatformProductImage, getPlatformUnifiedOrder, listPlatformUnifiedOrders } from '@/modules/unified-orders/api/unifiedOrders'
|
||||
import { getPlatformInboundHold, holdPlatformInbound, releasePlatformInbound } from '@/modules/inbounds'
|
||||
import UnifiedOrdersView from './UnifiedOrdersView.vue'
|
||||
|
||||
@@ -27,6 +27,7 @@ vi.mock('@/shared/api/inboundCodeRelations', () => ({
|
||||
}))
|
||||
vi.mock('@/modules/unified-orders/api/unifiedOrders', () => ({
|
||||
addPlatformUnifiedOrderNote: vi.fn(), approvePlatformUnifiedOrder: vi.fn(), batchApprovePlatformUnifiedOrders: vi.fn(),
|
||||
downloadPlatformProductImage: vi.fn(),
|
||||
getPlatformUnifiedOrder: vi.fn(), listPlatformUnifiedOrderFeeDetails: vi.fn(), listPlatformUnifiedOrders: vi.fn(),
|
||||
unifiedOrderStatusOptions: [],
|
||||
}))
|
||||
@@ -75,6 +76,7 @@ describe('UnifiedOrdersView downstream fulfillment detail', () => {
|
||||
vi.clearAllMocks()
|
||||
canPermission.mockImplementation(() => true)
|
||||
vi.mocked(getPlatformUnifiedOrder).mockResolvedValue(detail as never)
|
||||
vi.mocked(downloadPlatformProductImage).mockResolvedValue(new Blob(['image'], { type: 'image/png' }))
|
||||
vi.mocked(listPlatformUnifiedOrders).mockResolvedValue({ records: [], page: 1, size: 20, total: 0, pages: 0 })
|
||||
vi.mocked(getPlatformInboundHold).mockResolvedValue({
|
||||
inboundId: '7001', tenantId: '6001', holdFlag: false, currentHoldReason: null, version: 3,
|
||||
@@ -100,6 +102,20 @@ describe('UnifiedOrdersView downstream fulfillment detail', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('downloads one preview for cargo rows sharing the same product image', async () => {
|
||||
vi.mocked(getPlatformUnifiedOrder).mockResolvedValue({
|
||||
...detail,
|
||||
order: {
|
||||
...detail.order,
|
||||
cargoes: [1, 2, 3, 4].map((itemNo) => ({ itemNo, productImageFileId: '9901' })),
|
||||
},
|
||||
} as never)
|
||||
mountDetail()
|
||||
await flushPromises()
|
||||
expect(downloadPlatformProductImage).toHaveBeenCalledTimes(1)
|
||||
expect(downloadPlatformProductImage).toHaveBeenCalledWith('6001', '9901')
|
||||
})
|
||||
|
||||
it('shows a compact empty state in order detail when no downstream relationship exists', async () => {
|
||||
const wrapper = mountDetail()
|
||||
await flushPromises()
|
||||
|
||||
Reference in New Issue
Block a user