feat(admin-users): 支持按创建时间排序

This commit is contained in:
Entropy.Xu
2026-05-25 12:21:58 +08:00
parent 505d9fd8bc
commit aaad113190
13 changed files with 401 additions and 20 deletions
+52
View File
@@ -0,0 +1,52 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const { getMock, cachedRequestMock } = vi.hoisted(() => ({
getMock: vi.fn(),
cachedRequestMock: vi.fn(async (_key: string, fn: () => Promise<unknown>) => fn()),
}))
vi.mock('@/api/client', () => ({
default: {
get: getMock,
},
}))
vi.mock('@/utils/cache', () => ({
cachedRequest: cachedRequestMock,
}))
import { usersApi } from '@/api/users'
describe('usersApi admin list query', () => {
beforeEach(() => {
getMock.mockReset()
cachedRequestMock.mockClear()
getMock.mockResolvedValue({
data: {
items: [],
total: 0,
skip: 0,
limit: 20,
has_more: false,
},
})
})
it('passes creation-time sort parameters to the admin users endpoint', async () => {
await usersApi.getAllUsersPage({
skip: 20,
limit: 10,
sort_by: 'created_at',
sort_order: 'desc',
})
expect(getMock).toHaveBeenCalledWith('/api/admin/users', {
params: {
skip: 20,
limit: 10,
sort_by: 'created_at',
sort_order: 'desc',
},
})
})
})