update refunds
This commit is contained in:
@@ -20,6 +20,12 @@ Object.defineProperty(window, 'matchMedia', {
|
||||
}),
|
||||
})
|
||||
|
||||
let mockRouteQuery: Record<string, string> = {}
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => ({ query: mockRouteQuery }),
|
||||
useRouter: () => ({ push: vi.fn() }),
|
||||
}))
|
||||
|
||||
vi.mock('@/utils/request', () => ({
|
||||
api: {
|
||||
get: vi.fn(),
|
||||
@@ -88,7 +94,7 @@ const mockLookupCompanies = [
|
||||
{ id: 1, name: 'Company A', label: '公司A' },
|
||||
{ id: 2, name: 'Company B', label: '公司B' },
|
||||
]
|
||||
const mockLookupPlatforms = [{ id: 1, developer_id: 1 }]
|
||||
const mockLookupPlatforms = [{ id: 1, name: 'Tmall', label: '天猫', developer_id: 1 }]
|
||||
const mockLookupStores = [
|
||||
{ id: 1, company_id: 1, platform_id: 1, name: 'Store 1', label: '店铺1' },
|
||||
{ id: 2, company_id: 2, platform_id: 1, name: 'Store 2', label: '店铺2' },
|
||||
@@ -245,7 +251,7 @@ describe('useRefundStore', () => {
|
||||
await store.loadLookups()
|
||||
|
||||
expect(store.companyMap.get(1)).toBe('公司A')
|
||||
expect(store.platformMap.get(1)).toBe('平台 #1')
|
||||
expect(store.platformMap.get(1)).toBe('天猫')
|
||||
expect(store.storeMap.get(1)).toBe('店铺1')
|
||||
})
|
||||
|
||||
@@ -272,6 +278,7 @@ describe('RefundsPage', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
vi.restoreAllMocks()
|
||||
mockRouteQuery = {}
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
@@ -513,4 +520,37 @@ describe('RefundsPage', () => {
|
||||
|
||||
expect(errorSpy).toHaveBeenCalledWith('获取退款详情失败')
|
||||
})
|
||||
|
||||
// ─── P19.2 URL 参数自动填充测试 ───────────────────────────
|
||||
|
||||
it('fills filter and fetches when auto_submit=1 with platform_refund_id', async () => {
|
||||
mockRouteQuery = { platform_refund_id: 'RF-FROM-URL', auto_submit: '1' }
|
||||
const { api } = await mountPage()
|
||||
|
||||
const store = useRefundStore()
|
||||
expect(store.filters.platform_refund_id).toBe('RF-FROM-URL')
|
||||
expect(api.get).toHaveBeenCalledWith(
|
||||
'/api/v1/refunds',
|
||||
expect.objectContaining({
|
||||
platform_refund_id: 'RF-FROM-URL',
|
||||
page: 1,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('does not fill filter when platform_refund_id present but no auto_submit', async () => {
|
||||
mockRouteQuery = { platform_refund_id: 'RF-FROM-URL' }
|
||||
await mountPage()
|
||||
|
||||
const store = useRefundStore()
|
||||
expect(store.filters.platform_refund_id).toBe('')
|
||||
})
|
||||
|
||||
it('does not fill filter when only auto_submit is present without platform_refund_id', async () => {
|
||||
mockRouteQuery = { auto_submit: '1' }
|
||||
await mountPage()
|
||||
|
||||
const store = useRefundStore()
|
||||
expect(store.filters.platform_refund_id).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from '@ant-design/icons-vue'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const store = useRefundStore()
|
||||
|
||||
// Detail drawer
|
||||
@@ -71,8 +72,19 @@ const createdDateRange = computed({
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
const hasAutoSubmit = route.query.auto_submit === '1'
|
||||
|
||||
if (hasAutoSubmit) {
|
||||
await store.loadLookups()
|
||||
if (route.query.platform_refund_id) {
|
||||
store.filters.platform_refund_id = route.query.platform_refund_id as string
|
||||
}
|
||||
store.pagination.page = 1
|
||||
} else {
|
||||
store.loadLookups()
|
||||
}
|
||||
|
||||
store.fetchRefunds()
|
||||
})
|
||||
|
||||
@@ -112,7 +124,10 @@ async function handleCopyId(text: string, label: string) {
|
||||
}
|
||||
|
||||
function handleGoToOrder(platformOrderId: string) {
|
||||
router.push({ path: '/orders', query: { platform_order_id: platformOrderId } })
|
||||
router.push({
|
||||
path: '/orders',
|
||||
query: { platform_order_id: platformOrderId, auto_submit: '1' },
|
||||
})
|
||||
}
|
||||
|
||||
async function handleViewDetail(record: { id: number }) {
|
||||
|
||||
Reference in New Issue
Block a user