diff --git a/src/auto-reply/reply/reply-utils.test.ts b/src/auto-reply/reply/reply-utils.test.ts index 743568b38c1..bff7e300814 100644 --- a/src/auto-reply/reply/reply-utils.test.ts +++ b/src/auto-reply/reply/reply-utils.test.ts @@ -780,27 +780,15 @@ describe("resolveResponsePrefixTemplate", () => { describe("extractShortModelName", () => { it("strips provider prefix", () => { expect(extractShortModelName("openai/gpt-5.2")).toBe("gpt-5.2"); - expect(extractShortModelName("anthropic/claude-opus-4-5")).toBe("claude-opus-4-5"); expect(extractShortModelName("openai-codex/gpt-5.2-codex")).toBe("gpt-5.2-codex"); }); it("strips date suffix", () => { expect(extractShortModelName("claude-opus-4-5-20251101")).toBe("claude-opus-4-5"); - expect(extractShortModelName("gpt-5.2-20250115")).toBe("gpt-5.2"); }); it("strips -latest suffix", () => { expect(extractShortModelName("gpt-5.2-latest")).toBe("gpt-5.2"); - expect(extractShortModelName("claude-sonnet-latest")).toBe("claude-sonnet"); - }); - - it("handles model without provider", () => { - expect(extractShortModelName("gpt-5.2")).toBe("gpt-5.2"); - expect(extractShortModelName("claude-opus-4-5")).toBe("claude-opus-4-5"); - }); - - it("handles full path with provider and date suffix", () => { - expect(extractShortModelName("anthropic/claude-opus-4-5-20251101")).toBe("claude-opus-4-5"); }); it("preserves version numbers that look like dates but are not", () => { @@ -811,28 +799,10 @@ describe("extractShortModelName", () => { }); describe("hasTemplateVariables", () => { - it("returns false for undefined", () => { - expect(hasTemplateVariables(undefined)).toBe(false); - }); - it("returns false for empty string", () => { expect(hasTemplateVariables("")).toBe(false); }); - it("returns false for static prefix", () => { - expect(hasTemplateVariables("[Claude]")).toBe(false); - }); - - it("returns true when template variables present", () => { - expect(hasTemplateVariables("[{model}]")).toBe(true); - expect(hasTemplateVariables("{provider}")).toBe(true); - expect(hasTemplateVariables("prefix {thinkingLevel} suffix")).toBe(true); - }); - - it("returns true for multiple variables", () => { - expect(hasTemplateVariables("[{model} | {provider}]")).toBe(true); - }); - it("handles consecutive calls correctly (regex lastIndex reset)", () => { // First call expect(hasTemplateVariables("[{model}]")).toBe(true); diff --git a/src/config/sessions/store.pruning.e2e.test.ts b/src/config/sessions/store.pruning.e2e.test.ts index 302d9fefd99..92cd0da77fd 100644 --- a/src/config/sessions/store.pruning.e2e.test.ts +++ b/src/config/sessions/store.pruning.e2e.test.ts @@ -86,42 +86,6 @@ describe("Integration: saveSessionStore with pruning", () => { expect(loaded.fresh).toBeDefined(); }); - it("saveSessionStore rotates file when over size limit and creates .bak", async () => { - mockLoadConfig.mockReturnValue({ - session: { - maintenance: { - mode: "enforce", - pruneAfter: "30d", - maxEntries: 500, - rotateBytes: "100b", - }, - }, - }); - - const now = Date.now(); - const largeStore: Record = {}; - for (let i = 0; i < 50; i++) { - largeStore[`agent:main:session-${crypto.randomUUID()}`] = makeEntry(now - i * 1000); - } - await fs.mkdir(path.dirname(storePath), { recursive: true }); - await fs.writeFile(storePath, JSON.stringify(largeStore, null, 2), "utf-8"); - - const statBefore = await fs.stat(storePath); - expect(statBefore.size).toBeGreaterThan(100); - - const smallStore: Record = { - only: makeEntry(now), - }; - await saveSessionStore(storePath, smallStore); - - const files = await fs.readdir(testDir); - const bakFiles = files.filter((f) => f.startsWith("sessions.json.bak.")); - expect(bakFiles.length).toBeGreaterThanOrEqual(1); - - const loaded = loadSessionStore(storePath); - expect(loaded.only).toBeDefined(); - }); - it("saveSessionStore skips enforcement when maintenance mode is warn", async () => { mockLoadConfig.mockReturnValue({ session: { diff --git a/src/infra/heartbeat-runner.returns-default-unset.test.ts b/src/infra/heartbeat-runner.returns-default-unset.test.ts index 3b492f281b3..f8a76d952c0 100644 --- a/src/infra/heartbeat-runner.returns-default-unset.test.ts +++ b/src/infra/heartbeat-runner.returns-default-unset.test.ts @@ -287,24 +287,6 @@ describe("resolveHeartbeatDeliveryTarget", () => { }); }); - it("keeps WhatsApp group targets even with allowFrom set", () => { - const cfg: OpenClawConfig = { - channels: { whatsapp: { allowFrom: ["+1555"] } }, - }; - const entry = { - ...baseEntry, - lastChannel: "whatsapp" as const, - lastTo: "120363401234567890@g.us", - }; - expect(resolveHeartbeatDeliveryTarget({ cfg, entry })).toEqual({ - channel: "whatsapp", - to: "120363401234567890@g.us", - accountId: undefined, - lastChannel: "whatsapp", - lastAccountId: undefined, - }); - }); - it("normalizes prefixed WhatsApp group targets for heartbeat delivery", () => { const cfg: OpenClawConfig = { channels: { whatsapp: { allowFrom: ["+1555"] } }, @@ -323,19 +305,6 @@ describe("resolveHeartbeatDeliveryTarget", () => { }); }); - it("keeps explicit telegram targets", () => { - const cfg: OpenClawConfig = { - agents: { defaults: { heartbeat: { target: "telegram", to: "123" } } }, - }; - expect(resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry })).toEqual({ - channel: "telegram", - to: "123", - accountId: undefined, - lastChannel: undefined, - lastAccountId: undefined, - }); - }); - it("uses explicit heartbeat accountId when provided", () => { const cfg: OpenClawConfig = { agents: { @@ -1124,73 +1093,6 @@ describe("runHeartbeatOnce", () => { } }); - it("does not skip hook-triggered heartbeat when HEARTBEAT.md is effectively empty", async () => { - const tmpDir = await createCaseDir("openclaw-hb"); - const storePath = path.join(tmpDir, "sessions.json"); - const workspaceDir = path.join(tmpDir, "workspace"); - const replySpy = vi.spyOn(replyModule, "getReplyFromConfig"); - try { - await fs.mkdir(workspaceDir, { recursive: true }); - await fs.writeFile( - path.join(workspaceDir, "HEARTBEAT.md"), - "# HEARTBEAT.md\n\n## Tasks\n\n", - "utf-8", - ); - - const cfg: OpenClawConfig = { - agents: { - defaults: { - workspace: workspaceDir, - heartbeat: { every: "5m", target: "whatsapp" }, - }, - }, - channels: { whatsapp: { allowFrom: ["*"] } }, - session: { store: storePath }, - }; - const sessionKey = resolveMainSessionKey(cfg); - - await fs.writeFile( - storePath, - JSON.stringify( - { - [sessionKey]: { - sessionId: "sid", - updatedAt: Date.now(), - lastChannel: "whatsapp", - lastTo: "+1555", - }, - }, - null, - 2, - ), - ); - - replySpy.mockResolvedValue({ text: "hook event processed" }); - const sendWhatsApp = vi.fn().mockResolvedValue({ - messageId: "m1", - toJid: "jid", - }); - - const res = await runHeartbeatOnce({ - cfg, - reason: "hook:wake", - deps: { - sendWhatsApp, - getQueueSize: () => 0, - nowMs: () => 0, - webAuthExists: async () => true, - hasActiveWebListener: () => true, - }, - }); - - expect(res.status).toBe("ran"); - expect(replySpy).toHaveBeenCalled(); - expect(sendWhatsApp).toHaveBeenCalledTimes(1); - } finally { - replySpy.mockRestore(); - } - }); - it("runs heartbeat when HEARTBEAT.md has actionable content", async () => { const tmpDir = await createCaseDir("openclaw-hb"); const storePath = path.join(tmpDir, "sessions.json");