Files
agents_and_robots/e2e/tests/assistant-bot.spec.ts
T
egutierrez 1e896adeaa refactor: migrar tests E2E a persistent context
global-setup.ts:
- Usa launchPersistentContext en vez de browser.newContext()
- Reemplaza storageState por marker file para cache de sesion
- Captura logs de consola del browser para debug
- Screenshots y HTML dump en caso de error

playwright.config.ts:
- Elimina storageState (ahora via persistent context fixture)
- Screenshots siempre activas, video y trace en failures

Tests (login, assistant-bot, asistente-2):
- Importan test/expect desde persistent-context fixture
- Usan handleElementDialogs() en vez de espera manual de rooms
- Nuevo test de threads en asistente-2: verifica que el bot
  responde dentro del thread cuando se le habla por thread

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 15:47:51 +00:00

64 lines
1.7 KiB
TypeScript

import { test, expect, handleElementDialogs } from "../fixtures/persistent-context";
import {
goToRoom,
sendMessage,
waitForBotReply,
assertNoDecryptionErrors,
} from "../fixtures/matrix-room";
test.describe("assistant-bot", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
await handleElementDialogs(page);
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);
});
});