Add admin dashboard filtering and sorting
Provide stable server-side list queries and focused chart controls so operators can inspect large datasets without misleading partial-page ordering.
This commit is contained in:
@@ -105,6 +105,42 @@ describe("adminApi", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("typed query 编码日期、筛选、排序与布尔值", async () => {
|
||||
const fetchMock = vi.fn().mockImplementation(async () =>
|
||||
new Response(JSON.stringify({ items: [] }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
}),
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await adminApi.users({
|
||||
q: "user + value",
|
||||
from: "2026-08-01T00:00:00.000Z",
|
||||
until: "2026-08-20T23:59:59.999Z",
|
||||
status: "suspended",
|
||||
sort: "createdAt",
|
||||
order: "asc",
|
||||
limit: 25,
|
||||
});
|
||||
await adminApi.operators({
|
||||
enabled: false,
|
||||
locked: true,
|
||||
sort: "username",
|
||||
order: "desc",
|
||||
});
|
||||
|
||||
expect(fetchMock.mock.calls[0]?.[0]).toContain(
|
||||
"q=user+%2B+value&from=2026-08-01T00%3A00%3A00.000Z",
|
||||
);
|
||||
expect(fetchMock.mock.calls[0]?.[0]).toContain(
|
||||
"status=suspended&sort=createdAt&order=asc&limit=25",
|
||||
);
|
||||
expect(fetchMock.mock.calls[1]?.[0]).toBe(
|
||||
"/v1/admin/operators?enabled=false&locked=true&sort=username&order=desc",
|
||||
);
|
||||
});
|
||||
|
||||
it("缺少 CSRF 时在发送变更请求前失败", async () => {
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
Reference in New Issue
Block a user