- 管理台体验升级与日志分页/搜索/状态码展示 - 令牌过期与允许渠道控制,站点新增/修改自动测试 - 调用令牌按模型匹配选择,移除模型 TTL 并优化冷却逻辑 - 新增迁移与文档同步
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildUsageStatusDetail } from "../../apps/ui/src/core/utils";
|
|
|
|
const buildLog = (partial: Partial<{ status: string; upstream_status: number | null; error_code: string | null; error_message: string | null }>) => ({
|
|
id: "1",
|
|
model: "gpt-4",
|
|
channel_id: "c1",
|
|
token_id: "t1",
|
|
total_tokens: 1,
|
|
latency_ms: 100,
|
|
status: partial.status ?? "ok",
|
|
upstream_status: partial.upstream_status ?? null,
|
|
error_code: partial.error_code ?? null,
|
|
error_message: partial.error_message ?? null,
|
|
created_at: "2026-03-14T00:00:00Z",
|
|
});
|
|
|
|
describe("usage status detail", () => {
|
|
it("renders success label", () => {
|
|
const detail = buildUsageStatusDetail(buildLog({ status: "ok" }) as any);
|
|
expect(detail.label).toBe("-");
|
|
expect(detail.tone).toBe("success");
|
|
});
|
|
|
|
it("renders failure with status code", () => {
|
|
const detail = buildUsageStatusDetail(
|
|
buildLog({
|
|
status: "error",
|
|
upstream_status: 403,
|
|
error_code: "authentication_error",
|
|
error_message: "Invalid API key",
|
|
}) as any,
|
|
);
|
|
expect(detail.label).toBe("403");
|
|
expect(detail.tone).toBe("error");
|
|
});
|
|
});
|