Files
agent-desktop/console/src/utils/approval.test.ts
T
Pine 8e6b3abac3 feat(channels/market): 阶段 4 渠道/市场层合并上游 v2.2.0
- 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 用例全过
2026-09-04 13:24:47 +08:00

44 lines
1.3 KiB
TypeScript

/**
* normalizeLevel maps raw tool-execution-level strings to the four
* canonical levels, falling back to "AUTO" for anything unrecognized.
* This guards settings round-trips (missing/corrupted values must never
* crash the approval UI or lock users out of tool execution).
*/
import { describe, it, expect } from "vitest";
import { LEVELS, normalizeLevel } from "./approval";
describe("LEVELS", () => {
it("exposes the four levels in strictness order", () => {
expect(LEVELS).toEqual(["STRICT", "SMART", "AUTO", "OFF"]);
});
});
describe("normalizeLevel", () => {
it.each(["STRICT", "SMART", "AUTO", "OFF"])(
"passes through the valid level %s",
(level) => {
expect(normalizeLevel(level)).toBe(level);
},
);
it("accepts lowercase input", () => {
expect(normalizeLevel("strict")).toBe("STRICT");
});
it("accepts mixed-case input", () => {
expect(normalizeLevel("Smart")).toBe("SMART");
});
it("falls back to AUTO for an unrecognized level", () => {
expect(normalizeLevel("yolo")).toBe("AUTO");
});
it("falls back to AUTO for an empty string", () => {
expect(normalizeLevel("")).toBe("AUTO");
});
it("falls back to AUTO for undefined (missing settings)", () => {
expect(normalizeLevel(undefined)).toBe("AUTO");
});
});