8e6b3abac3
- PluginManager: 采用上游 useMarketPlugins(300行: 分页append/loadingMore/autoLoadBlocked/竞态AbortController/highlightFilter) + MarketPluginList(无限滚动LoadMoreSentinel+PluginViewToggle卡片/列表切换); OfficialPluginList.module.less 保留三处 var(--color-border) 定制+追加上游移动端@media; index.module.less 三向并合; 本地 index.tsx 保留(operator 权限 gate) - Market: MarketPanel(新 install: MarketInstallController 接口)/useMarketInstall/useMarketSearch/SkillIcon/ResultCard 采用上游 - Channels: ChannelDrawer/channelConfig/constants 上游版; 定制点保留(channelIcons console=var(--color-primary)、PendingApprovalsDrawer var(--color-success)) - api/types/chat.ts 采用上游(ChatGroup/ChatSource/ChatGroupKind/group_id); pages/Agent/Skills/index.tsx 适配 useMarketInstall - utils: chatGroups.ts + 14 个上游缺失工具测试补齐; CronJobs 测试补齐 - 测试修复: design-mock 补 Tabs 桩(上游 PluginViewToggle 依赖); MarketPluginList.test 采用上游版; skill.test 品牌映射云超服; lazyWithRetry.test 适配本地 dev-server 回退 - 验证: tsc 0 错误、build 通过、阶段 4 相关 45 测试文件 427 用例全过
24 lines
754 B
TypeScript
24 lines
754 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cacheHitRate, formatPercent } from "./cacheUsage";
|
|
|
|
describe("cache usage helpers", () => {
|
|
it("calculates a token-weighted hit rate", () => {
|
|
expect(cacheHitRate(80, 100)).toBe(80);
|
|
});
|
|
|
|
it("returns no rate when the provider has no eligible input", () => {
|
|
expect(cacheHitRate(0, 0)).toBeNull();
|
|
});
|
|
|
|
it("formats cold misses and unavailable data distinctly", () => {
|
|
expect(formatPercent(0)).toBe("0%");
|
|
expect(formatPercent(null)).toBe("—");
|
|
});
|
|
|
|
it("does not display a partial cache hit as 100 percent", () => {
|
|
expect(formatPercent(99.5)).toBe("99.5%");
|
|
expect(formatPercent(99.95)).toBe("99.95%");
|
|
expect(formatPercent(100)).toBe("100%");
|
|
});
|
|
});
|