From 7bc56d7cfe7fa225077a4a10be8d857239da13f1 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 3 Dec 2025 14:45:08 +0000 Subject: [PATCH] test: cover verbose directive in group batches --- src/index.core.test.ts | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/index.core.test.ts b/src/index.core.test.ts index 5828b1a4b..1f9db893e 100644 --- a/src/index.core.test.ts +++ b/src/index.core.test.ts @@ -853,6 +853,59 @@ describe("config and templating", () => { expect(bodyArg).toBe("hello ultrathink"); }); + it("treats verbose directive-only inside group batch context", async () => { + const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockResolvedValue({ + stdout: "ok", + stderr: "", + code: 0, + signal: null, + killed: false, + }); + const storeDir = await fs.promises.mkdtemp( + path.join(os.tmpdir(), "warelay-session-"), + ); + const storePath = path.join(storeDir, "sessions.json"); + const cfg = { + inbound: { + reply: { + mode: "command" as const, + command: ["echo", "{{Body}}"], + agent: { kind: "claude" }, + session: { store: storePath }, + }, + }, + }; + + const batchBody = + "[Chat messages since your last reply - for context]\nAlice: hi\n\n[Current message - respond to this]\nBob: /v on\n[from: Bob (+222)]"; + + const ack = await index.getReplyFromConfig( + { + Body: batchBody, + From: "group:123@g.us", + To: "+2", + }, + undefined, + cfg, + runSpy, + ); + + expect(runSpy).not.toHaveBeenCalled(); + expect(ack?.text).toBe("Verbose logging enabled."); + + await index.getReplyFromConfig( + { Body: "hello", From: "+1", To: "+2" }, + undefined, + cfg, + runSpy, + ); + + expect(runSpy).toHaveBeenCalledTimes(1); + const args = runSpy.mock.calls[0][0] as string[]; + const bodyArg = args[args.length - 1]; + expect(bodyArg).toBe("hello"); + }); + it("rejects invalid directive-only think level without changing state", async () => { const runSpy = vi.spyOn(index, "runCommandWithTimeout").mockResolvedValue({ stdout: "ok",