费用优化
This commit is contained in:
@@ -1,10 +1,41 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import ElementPlus from 'element-plus'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { getRelabelOrder, getRelabelQuantities } from '../api/relabelOrders'
|
||||
import RelabelOrderDetailView from './RelabelOrderDetailView.vue'
|
||||
|
||||
vi.mock('vue-router', () => ({ useRoute: () => ({ params: { orderId: 'RELABEL-1' } }), useRouter: () => ({ push: vi.fn() }) }))
|
||||
vi.mock('@/core/access/accessPreview', () => ({ useAccessPreviewStore: () => ({ can: () => false }) }))
|
||||
vi.mock('../api/relabelOrders', async importOriginal => ({
|
||||
...await importOriginal<typeof import('../api/relabelOrders')>(), getRelabelOrder: vi.fn(), getRelabelQuantities: vi.fn(),
|
||||
}))
|
||||
vi.mock('@/modules/overseas-business', () => ({ BusinessDocumentFees: {
|
||||
name: 'BusinessDocumentFees', props: ['businessType', 'businessNo', 'customerId', 'businessId'], template: '<section>本单费用</section>',
|
||||
} }))
|
||||
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/overseas-warehouse/pages/RelabelOrderDetailView.vue'), 'utf8')
|
||||
|
||||
describe('RelabelOrderDetailView', () => {
|
||||
it('resolves fees by the relabel identity without reusing the original customer order', async () => {
|
||||
vi.mocked(getRelabelOrder).mockResolvedValue({
|
||||
application: { id: '9007199254741004', relabelNo: 'RELABEL-1', lastlegOrderId: '9007199254741005', customerOrderNo: 'RETURN-1', chargeAmount: 25, chargeCurrency: 'CNY', walletStatus: 'NOT_REQUIRED' },
|
||||
items: [], history: [],
|
||||
})
|
||||
vi.mocked(getRelabelQuantities).mockRejectedValue(new Error('数量暂不可用'))
|
||||
const wrapper = mount(RelabelOrderDetailView, { global: { plugins: [ElementPlus], stubs: { AppDialog: true, RelabelDocumentsPanel: true } } })
|
||||
await flushPromises()
|
||||
expect(wrapper.findComponent({ name: 'BusinessDocumentFees' }).props()).toEqual({
|
||||
businessType: 'RELABEL_ORDER', businessNo: 'RELABEL-1', customerId: undefined, businessId: '9007199254741004',
|
||||
})
|
||||
expect(wrapper.text()).toContain('原换标费')
|
||||
expect(wrapper.text()).toContain('25.00 CNY')
|
||||
expect(wrapper.text()).toContain('无需冻结或扣款')
|
||||
expect(wrapper.text()).not.toContain('NOT_REQUIRED')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('renders carton relabel mappings as a row list instead of summary form fields', () => {
|
||||
expect(source).toContain('<template #content-after>')
|
||||
expect(source).toContain('<h2>箱唛换标信息</h2>')
|
||||
|
||||
Reference in New Issue
Block a user