- 版本目标 → 收录版本(前后端用户可见字符串、能力描述、给模型的提示) - Agent 上游 / 上游 → 模型服务;界面上的 Agent / Agent 会话 → 智能体 / 智能体会话 - 身份歧义 / 识别有歧义 / 无法确定作品 → 没识别出作品;待识别(池) → 未识别 - 建档 → 加入媒体库;资产 → 文件;库根 → 媒体库目录;纳管 → 本工具 / 外部任务; 哨兵 → 标记文件 / 检查目录;站点快照 → 抓取;Feed / RSS 订阅 / 来源健康 → RSS - 代码标识符、API 字段名、迁移文件不改;glossary.md 同步;smoke 选择器跟随 Co-Authored-By: Claude Opus 5.5 <[email protected]>
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { agentMockAllowed, resolveAgentMock } from "./agent.ts";
|
|
|
|
class MemStore {
|
|
m = new Map<string, string>();
|
|
getItem(k: string) {
|
|
return this.m.get(k) ?? null;
|
|
}
|
|
setItem(k: string, v: string) {
|
|
this.m.set(k, v);
|
|
}
|
|
removeItem(k: string) {
|
|
this.m.delete(k);
|
|
}
|
|
}
|
|
|
|
// 验收 S7:生产构建里 ?mock=1 不得把演示数据当真实运行展示
|
|
describe("智能体演示开关", () => {
|
|
it("只在开发构建或后端 provider=fake 时允许", () => {
|
|
expect(agentMockAllowed({ dev: true })).toBe(true);
|
|
expect(agentMockAllowed({ dev: false, provider: "fake" })).toBe(true);
|
|
expect(agentMockAllowed({ dev: false, provider: "anthropic" })).toBe(false);
|
|
expect(agentMockAllowed({ dev: false })).toBe(false);
|
|
});
|
|
|
|
it("生产 + 真实模型:?mock=1 与 VITE_AGENT_MOCK 都被忽略,并清掉记住的开关", () => {
|
|
const storage = new MemStore();
|
|
storage.setItem("umt-agent-mock", "1");
|
|
expect(resolveAgentMock({ allowed: false, envFlag: "1", search: "?mock=1", storage })).toBe(false);
|
|
expect(storage.getItem("umt-agent-mock")).toBeNull();
|
|
});
|
|
|
|
it("允许时:?mock=1 记住,?mock=0 退出,构建期开关直接打开", () => {
|
|
const storage = new MemStore();
|
|
expect(resolveAgentMock({ allowed: true, search: "?mock=1", storage })).toBe(true);
|
|
expect(resolveAgentMock({ allowed: true, search: "", storage })).toBe(true);
|
|
expect(resolveAgentMock({ allowed: true, search: "?mock=0", storage })).toBe(false);
|
|
expect(resolveAgentMock({ allowed: true, envFlag: "1", search: "", storage })).toBe(true);
|
|
expect(resolveAgentMock({ allowed: true, search: "?mock=1", storage: null })).toBe(true);
|
|
});
|
|
});
|