update order page
This commit is contained in:
@@ -19,6 +19,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(),
|
||||
@@ -313,6 +319,7 @@ describe('OrdersPage', () => {
|
||||
setActivePinia(createPinia())
|
||||
vi.restoreAllMocks()
|
||||
document.body.innerHTML = ''
|
||||
mockRouteQuery = {}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
@@ -665,4 +672,37 @@ describe('OrdersPage', () => {
|
||||
|
||||
expect(writeTextMock).toHaveBeenCalledWith('ORD-20260101-001')
|
||||
})
|
||||
|
||||
// ─── P18.2 URL 参数自动填充测试 ───────────────────────────
|
||||
|
||||
it('fills filter and fetches when auto_submit=1 with platform_order_id', async () => {
|
||||
mockRouteQuery = { platform_order_id: 'ORD-FROM-URL', auto_submit: '1' }
|
||||
const { api } = await mountPage()
|
||||
|
||||
const store = useOrderStore()
|
||||
expect(store.filters.platform_order_id).toBe('ORD-FROM-URL')
|
||||
expect(api.get).toHaveBeenCalledWith(
|
||||
'/api/v1/orders',
|
||||
expect.objectContaining({
|
||||
platform_order_id: 'ORD-FROM-URL',
|
||||
page: 1,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('does not fill filter when platform_order_id present but no auto_submit', async () => {
|
||||
mockRouteQuery = { platform_order_id: 'ORD-FROM-URL' }
|
||||
await mountPage()
|
||||
|
||||
const store = useOrderStore()
|
||||
expect(store.filters.platform_order_id).toBe('')
|
||||
})
|
||||
|
||||
it('does not fill filter when only auto_submit is present without platform_order_id', async () => {
|
||||
mockRouteQuery = { auto_submit: '1' }
|
||||
await mountPage()
|
||||
|
||||
const store = useOrderStore()
|
||||
expect(store.filters.platform_order_id).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -91,8 +91,21 @@ const paidDateRange = computed({
|
||||
},
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
store.loadLookups()
|
||||
const route = useRoute()
|
||||
|
||||
onMounted(async () => {
|
||||
const hasAutoSubmit = route.query.auto_submit === '1'
|
||||
|
||||
if (hasAutoSubmit) {
|
||||
await store.loadLookups()
|
||||
if (route.query.platform_order_id) {
|
||||
store.filters.platform_order_id = route.query.platform_order_id as string
|
||||
}
|
||||
store.pagination.page = 1
|
||||
} else {
|
||||
store.loadLookups()
|
||||
}
|
||||
|
||||
store.fetchOrders()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user