feat: tests E2E para assistant-bot y asistente-2
Tests de cada agente via Element Web + Playwright: - assistant-bot: saludo DM, pregunta, !help, !ping, E2EE check - asistente-2: saludo, !tools, tool use (que hora es?), !help, E2EE check Assertions flexibles para respuestas LLM (no-deterministicas), estrictas para commands deterministicos (!help, !ping). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
import { test, expect } from "@playwright/test";
|
||||||
|
import {
|
||||||
|
goToRoom,
|
||||||
|
sendMessage,
|
||||||
|
waitForBotReply,
|
||||||
|
assertNoDecryptionErrors,
|
||||||
|
} from "../fixtures/matrix-room";
|
||||||
|
|
||||||
|
test.describe("asistente-2", () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto("/");
|
||||||
|
|
||||||
|
// Esperar a que la sesion este lista
|
||||||
|
await expect(
|
||||||
|
page.locator('[role="tree"][aria-label="Rooms"]')
|
||||||
|
).toBeVisible({ timeout: 30_000 });
|
||||||
|
|
||||||
|
await goToRoom(page, "Asistente 2");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("responde a un saludo", async ({ page }) => {
|
||||||
|
await sendMessage(page, "Hola, que tal?");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 60_000,
|
||||||
|
sender: "Asistente 2",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
expect(reply.length).toBeGreaterThan(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("!tools muestra herramientas disponibles", async ({ page }) => {
|
||||||
|
await sendMessage(page, "!tools");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 10_000,
|
||||||
|
sender: "Asistente 2",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
// asistente-2 tiene al menos current_time
|
||||||
|
expect(reply.toLowerCase()).toMatch(/current_time|hora|herramienta|tool/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("pregunta que activa tool use (que hora es?)", async ({ page }) => {
|
||||||
|
await sendMessage(page, "Que hora es ahora mismo?");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 60_000,
|
||||||
|
sender: "Asistente 2",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
// La respuesta debe contener algo relacionado con tiempo/hora
|
||||||
|
expect(reply.length).toBeGreaterThan(5);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("!help muestra comandos", async ({ page }) => {
|
||||||
|
await sendMessage(page, "!help");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 10_000,
|
||||||
|
sender: "Asistente 2",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
expect(reply.toLowerCase()).toContain("help");
|
||||||
|
expect(reply.toLowerCase()).toContain("ping");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("no hay errores de E2EE en el timeline", async ({ page }) => {
|
||||||
|
await assertNoDecryptionErrors(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { test, expect } from "@playwright/test";
|
||||||
|
import {
|
||||||
|
goToRoom,
|
||||||
|
sendMessage,
|
||||||
|
waitForBotReply,
|
||||||
|
assertNoDecryptionErrors,
|
||||||
|
} from "../fixtures/matrix-room";
|
||||||
|
|
||||||
|
test.describe("assistant-bot", () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.goto("/");
|
||||||
|
|
||||||
|
// Esperar a que la sesion este lista
|
||||||
|
await expect(
|
||||||
|
page.locator('[role="tree"][aria-label="Rooms"]')
|
||||||
|
).toBeVisible({ timeout: 30_000 });
|
||||||
|
|
||||||
|
await goToRoom(page, "Assistant");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("responde a un saludo en DM", async ({ page }) => {
|
||||||
|
await sendMessage(page, "Hola, como estas?");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 60_000,
|
||||||
|
sender: "Assistant",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
expect(reply.length).toBeGreaterThan(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("responde a una pregunta con contenido coherente", async ({ page }) => {
|
||||||
|
await sendMessage(page, "Que es la fotosintesis? Responde en una frase.");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 60_000,
|
||||||
|
sender: "Assistant",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
expect(reply.length).toBeGreaterThan(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("!help muestra lista de comandos", async ({ page }) => {
|
||||||
|
await sendMessage(page, "!help");
|
||||||
|
|
||||||
|
const reply = await waitForBotReply(page, {
|
||||||
|
timeout: 10_000,
|
||||||
|
sender: "Assistant",
|
||||||
|
});
|
||||||
|
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: "Assistant",
|
||||||
|
});
|
||||||
|
expect(reply).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("no hay errores de E2EE en el timeline", async ({ page }) => {
|
||||||
|
await assertNoDecryptionErrors(page);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user