feat(admin): 优化后台运维与任务管理
完善平台、基准模型、定价规则和实时负载的紧凑查询与滚动展示,并固定关键操作列。 新增管理员任务记录、批量计费结算和用户组限流、额度及模型权限维护能力,同时补充任务脱敏、查询索引与 OpenAPI 契约。 验证:pnpm openapi、Go 全量测试、pnpm lint、pnpm test、pnpm build、gofmt 与差异格式检查均通过。
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseAppRoute, pathForApiDocSection } from './routing';
|
||||
import { defaultAdminTaskQuery, parseAppRoute, pathForAdminSection, pathForAdminTaskQuery, pathForApiDocSection } from './routing';
|
||||
|
||||
describe('API documentation routes', () => {
|
||||
it.each([
|
||||
@@ -35,3 +35,47 @@ describe('API documentation routes', () => {
|
||||
expect(parseAppRoute('/docs').apiDocSection).toBe('openApiOverview');
|
||||
});
|
||||
});
|
||||
|
||||
describe('admin task routes', () => {
|
||||
it('round-trips the complete admin task query through the URL', () => {
|
||||
const query = {
|
||||
...defaultAdminTaskQuery(),
|
||||
query: 'request-123',
|
||||
tenantId: 'tenant-id',
|
||||
userId: 'user-id',
|
||||
userGroupId: 'group-id',
|
||||
status: 'failed',
|
||||
platformId: 'platform-id',
|
||||
model: 'model-a',
|
||||
modelType: 'image_generate',
|
||||
runMode: 'production',
|
||||
billingStatus: 'settled',
|
||||
apiKey: 'ops-key',
|
||||
createdFrom: '2026-07-01T00:00:00Z',
|
||||
createdTo: '2026-07-25T00:00:00Z',
|
||||
page: 3,
|
||||
pageSize: 50,
|
||||
};
|
||||
const path = pathForAdminTaskQuery(query);
|
||||
const parsed = parseAppRoute(path);
|
||||
expect(parsed.adminSection).toBe('tasks');
|
||||
expect(parsed.adminTaskQuery).toEqual(query);
|
||||
});
|
||||
|
||||
it('uses stable defaults for the admin task page', () => {
|
||||
expect(parseAppRoute('/admin/tasks').adminTaskQuery).toEqual(defaultAdminTaskQuery());
|
||||
});
|
||||
});
|
||||
|
||||
describe('admin billing settlement route', () => {
|
||||
it('maps billing settlements to an independent admin page', () => {
|
||||
expect(pathForAdminSection('billingSettlements')).toBe('/admin/billing-settlements');
|
||||
expect(parseAppRoute('/admin/billing-settlements').adminSection).toBe('billingSettlements');
|
||||
});
|
||||
});
|
||||
|
||||
describe('legacy admin access rule route', () => {
|
||||
it('opens user groups because model permissions are configured from the group row', () => {
|
||||
expect(parseAppRoute('/admin/access-rules').adminSection).toBe('userGroups');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user