perf(test): trim duplicate gateway and auto-reply test overhead

This commit is contained in:
Peter Steinberger
2026-02-13 23:40:25 +00:00
parent ad57e561c6
commit 5caf829d28
6 changed files with 34 additions and 234 deletions

View File

@@ -161,36 +161,10 @@ describe("RawBody directive parsing", () => {
},
expectedIncludes: ["Verbose logging enabled."],
});
await assertCommandReply({
message: {
Body: `[Chat messages since your last reply - for context]\\n[WhatsApp ...] Someone: hello\\n\\n[Current message - respond to this]\\n[WhatsApp ...] Jake: /status\\n[from: Jake McInteer (+6421807830)]`,
RawBody: "/status",
ChatType: "group",
From: "+1222",
To: "+1222",
SessionKey: "agent:main:whatsapp:group:g1",
Provider: "whatsapp",
Surface: "whatsapp",
SenderE164: "+1222",
CommandAuthorized: true,
},
config: {
agents: {
defaults: {
model: "anthropic/claude-opus-4-5",
workspace: path.join(home, "openclaw-3"),
},
},
channels: { whatsapp: { allowFrom: ["+1222"] } },
session: { store: path.join(home, "sessions-3.json") },
},
expectedIncludes: ["Session: agent:main:whatsapp:group:g1", "anthropic/claude-opus-4-5"],
});
});
});
it("preserves history when RawBody is provided for command parsing", async () => {
it("preserves history and reuses non-default agent session files", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
payloads: [{ text: "ok" }],
@@ -238,11 +212,6 @@ describe("RawBody directive parsing", () => {
expect(prompt).toContain('"body": "hello"');
expect(prompt).toContain("status please");
expect(prompt).not.toContain("/think:high");
});
});
it("reuses non-default agent session files without throwing path validation errors", async () => {
await withTempHome(async (home) => {
const agentId = "worker1";
const sessionId = "sess-worker-1";
const sessionKey = `agent:${agentId}:telegram:12345`;
@@ -259,6 +228,7 @@ describe("RawBody directive parsing", () => {
},
});
vi.mocked(runEmbeddedPiAgent).mockReset();
vi.mocked(runEmbeddedPiAgent).mockResolvedValue({
payloads: [{ text: "ok" }],
meta: {
@@ -267,7 +237,7 @@ describe("RawBody directive parsing", () => {
},
});
const res = await getReplyFromConfig(
const resWorker = await getReplyFromConfig(
{
Body: "hello",
From: "telegram:12345",
@@ -288,8 +258,8 @@ describe("RawBody directive parsing", () => {
},
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toBe("ok");
const textWorker = Array.isArray(resWorker) ? resWorker[0]?.text : resWorker?.text;
expect(textWorker).toBe("ok");
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
expect(vi.mocked(runEmbeddedPiAgent).mock.calls[0]?.[0]?.sessionFile).toBe(sessionFile);
});