优化
This commit is contained in:
@@ -9,10 +9,11 @@ import { listPlatformTenants, type PlatformTenantResource } from '@/modules/iam'
|
||||
import QueryToolbar from '@/shared/components/QueryToolbar.vue'
|
||||
import DataTable from '@/shared/components/DataTable.vue'
|
||||
import { listPlatformWarehouses } from '@/modules/warehouses'
|
||||
import { getPlatformInbound, listPlatformInbounds } from '../core/api'
|
||||
import { downloadInboundCartonLabels, getPlatformInbound, listPlatformInbounds } from '../core/api'
|
||||
import type { InboundOrderDetail, InboundOrderSummary } from '../core/types'
|
||||
|
||||
vi.mock('../core/api', () => ({
|
||||
downloadInboundCartonLabels: vi.fn(),
|
||||
getPlatformInbound: vi.fn(),
|
||||
listPlatformInbounds: vi.fn(),
|
||||
}))
|
||||
@@ -74,6 +75,7 @@ describe('InboundOrdersView', () => {
|
||||
setActivePinia(createPinia())
|
||||
vi.mocked(listPlatformInbounds).mockResolvedValue({ records: [summary], page: 1, size: 20, total: 1, pages: 1 })
|
||||
vi.mocked(getPlatformInbound).mockResolvedValue(detail)
|
||||
vi.mocked(downloadInboundCartonLabels).mockResolvedValue(new Blob(['pdf'], { type: 'application/pdf' }))
|
||||
vi.mocked(listPlatformTenants).mockResolvedValue({ records: customers, page: 1, size: 200, total: 2, pages: 1 })
|
||||
vi.mocked(listPlatformWarehouses).mockResolvedValue({
|
||||
records: [
|
||||
@@ -171,6 +173,25 @@ describe('InboundOrdersView', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('downloads carton labels from the stable server-side mapping', async () => {
|
||||
const createObjectURL = vi.fn(() => 'blob:labels')
|
||||
const revokeObjectURL = vi.fn()
|
||||
vi.stubGlobal('URL', { createObjectURL, revokeObjectURL })
|
||||
const click = vi.spyOn(HTMLAnchorElement.prototype, 'click').mockImplementation(() => {})
|
||||
const wrapper = mountPage()
|
||||
await flushPromises()
|
||||
|
||||
await wrapper.findAll('button').find((button) => button.text().includes('打印箱唛'))?.trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(downloadInboundCartonLabels).toHaveBeenCalledWith('10002', '19001')
|
||||
expect(createObjectURL).toHaveBeenCalledOnce()
|
||||
expect(revokeObjectURL).toHaveBeenCalledWith('blob:labels')
|
||||
expect(click).toHaveBeenCalledOnce()
|
||||
click.mockRestore()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
it('uses the app header as the page title and exposes compact accessible status tabs', async () => {
|
||||
const wrapper = mountPage()
|
||||
await flushPromises()
|
||||
|
||||
Reference in New Issue
Block a user