完善平台、基准模型、定价规则和实时负载的紧凑查询与滚动展示,并固定关键操作列。 新增管理员任务记录、批量计费结算和用户组限流、额度及模型权限维护能力,同时补充任务脱敏、查询索引与 OpenAPI 契约。 验证:pnpm openapi、Go 全量测试、pnpm lint、pnpm test、pnpm build、gofmt 与差异格式检查均通过。
82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { defaultAdminTaskQuery, parseAppRoute, pathForAdminSection, pathForAdminTaskQuery, pathForApiDocSection } from './routing';
|
|
|
|
describe('API documentation routes', () => {
|
|
it.each([
|
|
['openApiOverview', '/docs/open-api'],
|
|
['compatApiOverview', '/docs/compatible-api'],
|
|
['compatGemini', '/docs/compatible-api/gemini'],
|
|
['compatKling', '/docs/compatible-api/kling'],
|
|
['compatVolces', '/docs/compatible-api/volces'],
|
|
['compatServerMain', '/docs/compatible-api/server-main'],
|
|
['guideBaseUrl', '/docs/auth'],
|
|
['guideWebhook', '/docs/webhook'],
|
|
['guideErrors', '/docs/errors'],
|
|
['guideTesting', '/docs/testing'],
|
|
['responses', '/docs/responses'],
|
|
['videoGeneration', '/docs/videos/generations'],
|
|
['asyncMode', '/docs/async'],
|
|
['taskRetrieve', '/docs/tasks/retrieve'],
|
|
] as const)('maps %s to a stable documentation URL', (section, path) => {
|
|
expect(pathForApiDocSection(section)).toBe(path);
|
|
expect(parseAppRoute(path).apiDocSection).toBe(section);
|
|
});
|
|
|
|
it.each([
|
|
['/docs/playground', 'guideTesting'],
|
|
['/docs/api/responses', 'responses'],
|
|
['/docs/api/videos', 'videoGeneration'],
|
|
['/docs/api/tasks', 'taskRetrieve'],
|
|
] as const)('keeps the legacy documentation URL %s working', (path, section) => {
|
|
expect(parseAppRoute(path).apiDocSection).toBe(section);
|
|
});
|
|
|
|
it('uses the common open API catalog as the documentation landing page', () => {
|
|
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');
|
|
});
|
|
});
|