perf(test): stabilize e2e harness and reduce flaky gateway coverage

This commit is contained in:
Peter Steinberger
2026-02-13 17:31:58 +00:00
parent 2ab7715d16
commit fdfc34fa1f
25 changed files with 427 additions and 940 deletions

View File

@@ -206,7 +206,7 @@ describe("directive behavior", () => {
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Model set to minimax");
expect(text).toContain("Models (minimax)");
expect(text).toContain("minimax/MiniMax-M2.1");
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});

View File

@@ -125,7 +125,8 @@ describe("group intro prompts", () => {
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
const extraSystemPrompt =
vi.mocked(runEmbeddedPiAgent).mock.calls.at(-1)?.[0]?.extraSystemPrompt ?? "";
expect(extraSystemPrompt).toBe(
expect(extraSystemPrompt).toContain('"channel": "discord"');
expect(extraSystemPrompt).toContain(
`You are replying inside a Discord group chat. Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included). ${groupParticipationNote} Address the specific sender noted in the message context.`,
);
});
@@ -156,7 +157,8 @@ describe("group intro prompts", () => {
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
const extraSystemPrompt =
vi.mocked(runEmbeddedPiAgent).mock.calls.at(-1)?.[0]?.extraSystemPrompt ?? "";
expect(extraSystemPrompt).toBe(
expect(extraSystemPrompt).toContain('"channel": "whatsapp"');
expect(extraSystemPrompt).toContain(
`You are replying inside a WhatsApp group chat. Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included). WhatsApp IDs: SenderId is the participant JID (group participant id). ${groupParticipationNote} Address the specific sender noted in the message context.`,
);
});
@@ -187,7 +189,8 @@ describe("group intro prompts", () => {
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
const extraSystemPrompt =
vi.mocked(runEmbeddedPiAgent).mock.calls.at(-1)?.[0]?.extraSystemPrompt ?? "";
expect(extraSystemPrompt).toBe(
expect(extraSystemPrompt).toContain('"channel": "telegram"');
expect(extraSystemPrompt).toContain(
`You are replying inside a Telegram group chat. Activation: trigger-only (you are invoked only when explicitly mentioned; recent context may be included). ${groupParticipationNote} Address the specific sender noted in the message context.`,
);
});

View File

@@ -161,7 +161,7 @@ describe("trigger handling", () => {
expect(text).toBe("ok");
expect(runEmbeddedPiAgent).toHaveBeenCalledOnce();
const extra = vi.mocked(runEmbeddedPiAgent).mock.calls[0]?.[0]?.extraSystemPrompt ?? "";
expect(extra).toContain("Test Group");
expect(extra).toContain('"chat_type": "group"');
expect(extra).toContain("Activation: always-on");
});
});

View File

@@ -222,8 +222,8 @@ describe("trigger handling", () => {
cfg,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toBe("ok");
expect(text).not.toContain("Elevated mode set to ask");
expect(text).toBeUndefined();
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});
});

View File

@@ -191,7 +191,8 @@ describe("trigger handling", () => {
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Help");
expect(text).toContain("Shortcuts");
expect(text).toContain("Session");
expect(text).toContain("More: /commands for full list");
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});

View File

@@ -116,9 +116,9 @@ describe("trigger handling", () => {
const text = Array.isArray(res) ? res[0]?.text : res?.text;
const normalized = normalizeTestText(text ?? "");
expect(normalized).toContain("Current: anthropic/claude-opus-4-5");
expect(normalized).toContain("Switch: /model <provider/model>");
expect(normalized).toContain("Browse: /models (providers) or /models <provider> (models)");
expect(normalized).toContain("More: /model status");
expect(normalized).toContain("/model <provider/model> to switch");
expect(normalized).toContain("Tap below to browse models");
expect(normalized).toContain("/model status for details");
expect(normalized).not.toContain("reasoning");
expect(normalized).not.toContain("image");
});