test: E2E tests para agente test-personality y pipeline de creacion
Tests funcionales (test-personality.spec.ts): - Saludo con personalidad pirata espacial (keywords flexibles) - Personalidad consistente en respuestas serias (fotosintesis + pirata) - !help y !ping funcionan (assertions estrictas) - Sin errores E2EE Tests de pipeline (create-agent-pipeline.spec.ts): - Valida agent.go con Rules() y ActionKindLLM - Config sin type: robot (es agent por defecto) - System prompt con personalidad + seccion de seguridad - LLM configurado (openai/gpt-4o) - Encryption habilitada, import en launcher Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
import { test, expect, handleElementDialogs } from "../fixtures/persistent-context";
|
||||
import {
|
||||
goToRoom,
|
||||
sendMessage,
|
||||
waitForBotReply,
|
||||
assertNoDecryptionErrors,
|
||||
} from "../fixtures/matrix-room";
|
||||
|
||||
// Keywords that indicate pirate-space personality.
|
||||
// The LLM is non-deterministic, so we check for presence of ANY keyword from the set.
|
||||
const PIRATE_SPACE_KEYWORDS = [
|
||||
"arrr",
|
||||
"cosmonauta",
|
||||
"estelar",
|
||||
"marea",
|
||||
"nave",
|
||||
"galaxia",
|
||||
"estrella",
|
||||
"pirata",
|
||||
"capitan",
|
||||
"nebulosa",
|
||||
"intergal",
|
||||
"asteroide",
|
||||
"meteorito",
|
||||
"agujero negro",
|
||||
"tripulacion",
|
||||
"🏴☠️",
|
||||
"🚀",
|
||||
"⭐",
|
||||
"🌌",
|
||||
"☄️",
|
||||
"💀",
|
||||
];
|
||||
|
||||
function containsPirateKeyword(text: string): boolean {
|
||||
const lower = text.toLowerCase();
|
||||
return PIRATE_SPACE_KEYWORDS.some((kw) => lower.includes(kw.toLowerCase()));
|
||||
}
|
||||
|
||||
test.describe("test-personality (pirata espacial)", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await handleElementDialogs(page);
|
||||
await goToRoom(page, "Test Personality");
|
||||
});
|
||||
|
||||
test("responde a saludo con personalidad pirata espacial", async ({ page }) => {
|
||||
await sendMessage(page, "Hola, como estas?");
|
||||
|
||||
const reply = await waitForBotReply(page, {
|
||||
timeout: 60_000,
|
||||
sender: "Test Personality",
|
||||
});
|
||||
expect(reply).toBeTruthy();
|
||||
expect(reply.length).toBeGreaterThan(20);
|
||||
expect(containsPirateKeyword(reply)).toBe(true);
|
||||
});
|
||||
|
||||
test("personalidad consistente en respuestas serias", async ({ page }) => {
|
||||
await sendMessage(page, "Que es la fotosintesis? Responde en una frase.");
|
||||
|
||||
const reply = await waitForBotReply(page, {
|
||||
timeout: 60_000,
|
||||
sender: "Test Personality",
|
||||
});
|
||||
expect(reply).toBeTruthy();
|
||||
expect(reply.length).toBeGreaterThan(20);
|
||||
// Should contain real content about photosynthesis
|
||||
expect(reply.toLowerCase()).toMatch(/luz|sol|planta|energia|clorofila|carbon/i);
|
||||
// And still maintain pirate personality
|
||||
expect(containsPirateKeyword(reply)).toBe(true);
|
||||
});
|
||||
|
||||
test("!help muestra lista de comandos", async ({ page }) => {
|
||||
await sendMessage(page, "!help");
|
||||
|
||||
const reply = await waitForBotReply(page, {
|
||||
timeout: 10_000,
|
||||
sender: "Test Personality",
|
||||
});
|
||||
expect(reply).toBeTruthy();
|
||||
expect(reply.toLowerCase()).toContain("help");
|
||||
expect(reply.toLowerCase()).toContain("ping");
|
||||
});
|
||||
|
||||
test("!ping responde", async ({ page }) => {
|
||||
await sendMessage(page, "!ping");
|
||||
|
||||
const reply = await waitForBotReply(page, {
|
||||
timeout: 10_000,
|
||||
sender: "Test Personality",
|
||||
});
|
||||
expect(reply).toBeTruthy();
|
||||
});
|
||||
|
||||
test("no hay errores de E2EE en el timeline", async ({ page }) => {
|
||||
await assertNoDecryptionErrors(page);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user