Files
agents_and_robots/e2e/tests/asistente-2.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

101 lines
2.8 KiB
TypeScript

import { test, expect, handleElementDialogs } from "../fixtures/persistent-context";
import {
goToRoom,
sendMessage,
waitForBotReply,
assertNoDecryptionErrors,
startThreadOnLastMessage,
sendThreadMessage,
waitForThreadReply,
} from "../fixtures/matrix-room";
test.describe("asistente-2", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
await handleElementDialogs(page);
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("responde dentro del thread cuando se le habla por thread", async ({
page,
}) => {
// 1. Enviar un mensaje normal (sera el thread root)
await sendMessage(page, "Mensaje para iniciar thread");
// Esperar a que el bot responda al mensaje original
await waitForBotReply(page, {
timeout: 60_000,
sender: "Asistente 2",
});
// 2. Iniciar thread sobre el mensaje del usuario
await startThreadOnLastMessage(page);
// 3. Enviar mensaje dentro del thread
await sendThreadMessage(
page,
"Hola desde el thread, respondeme aqui por favor"
);
// 4. Esperar que el bot responda DENTRO del thread
const threadReply = await waitForThreadReply(page, {
timeout: 60_000,
sender: "Asistente 2",
});
expect(threadReply).toBeTruthy();
expect(threadReply.length).toBeGreaterThan(5);
});
test("no hay errores de E2EE en el timeline", async ({ page }) => {
await assertNoDecryptionErrors(page);
});
});