import { describe, expect, it } from "vitest"; import { BUILTIN_AGENT_CHECKS, renderGoal } from "../../src/modules/schedules/agent-checks.ts"; // FIX-7:界面上看到的 {{now}} / {{openDecisions}} 是模板本身;执行时必须全部替换成实际值。 describe("renderGoal(巡检目标模板)", () => { const now = new Date("2026-09-28T18:53:50.468Z"); const facts = { openDecisions: 3, stalledDownloads: 1, activeSubscriptions: 5 }; it("内置巡检的模板执行时不留占位符", () => { for (const c of BUILTIN_AGENT_CHECKS) { const goal = renderGoal(c.config.goalTemplate, now, facts); expect(goal).not.toMatch(/\{\{/); } const pending = BUILTIN_AGENT_CHECKS.find((c) => c.key === "check.pending"); expect(renderGoal(pending?.config.goalTemplate ?? "", now, facts)).toContain( "巡检事项(2026-09-28T18:53:50.468Z):有 3 条未关闭的需要处理的事项", ); }); it("容许空格;不认识的占位符原样保留", () => { expect(renderGoal("{{ date }} 待处理 {{openDecisions}} 条 {{other}}", now, facts)).toBe( "2026-09-28 待处理 3 条 {{other}}", ); }); });