fc644ecd6e
Reemplaza el scaffold del echobot por la plataforma completa de bots traida desde ~/DataProyects/Github/agents_and_robots tras la operacion Matrix-out: los bots ya no hablan por Matrix sino por el bus unibus (modelo todo-rooms + E2E via shell/transportunibus sobre github.com/enmanuel/unibus/pkg/client). - go.mod: replace de unibus -> ../unibus y de fn-registry -> ../../../.. (paths relativos reajustados a la nueva ubicacion dentro de fn_registry). - app.md: bump a 0.2.0, descripcion + arquitectura + comandos + gotchas reales. - modulo Go conservado como github.com/enmanuel/agents (sin reescribir imports). agents_and_robots queda archivado como museo de la era Matrix.
135 lines
3.4 KiB
Bash
Executable File
135 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# run.sh — ejecutar E2E tests con Playwright
|
|
#
|
|
# Uso:
|
|
# ./dev-scripts/e2e/run.sh # headless (default)
|
|
# ./dev-scripts/e2e/run.sh --headed # con browser visible (requiere DISPLAY)
|
|
#
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
E2E_DIR="$REPO_ROOT/e2e"
|
|
ELEMENT_SCRIPT="$E2E_DIR/scripts/setup-element.sh"
|
|
PS_SCRIPT="$REPO_ROOT/dev-scripts/server/ps.sh"
|
|
|
|
HEADED=false
|
|
EXTRA_ARGS=()
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--headed)
|
|
HEADED=true
|
|
;;
|
|
*)
|
|
EXTRA_ARGS+=("$arg")
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# --- Verificaciones previas ---
|
|
|
|
# 1. Verificar dependencias instaladas
|
|
if [ ! -d "$E2E_DIR/node_modules" ]; then
|
|
echo "ERROR: node_modules no encontrado. Ejecutar primero:"
|
|
echo " ./dev-scripts/e2e/install.sh"
|
|
exit 1
|
|
fi
|
|
|
|
# 2. Verificar .env
|
|
if [ ! -f "$E2E_DIR/.env" ]; then
|
|
echo "ERROR: e2e/.env no encontrado. Crear desde el template:"
|
|
echo " cp e2e/.env.example e2e/.env"
|
|
echo " # editar e2e/.env con credenciales"
|
|
exit 1
|
|
fi
|
|
|
|
# 3. Verificar que los agentes estan corriendo
|
|
echo "=== Verificando agentes ==="
|
|
if [ -x "$PS_SCRIPT" ]; then
|
|
if ! "$PS_SCRIPT" 2>/dev/null | grep -q "running"; then
|
|
echo "WARN: el launcher no parece estar corriendo."
|
|
echo " Iniciar con: ./dev-scripts/server/start.sh"
|
|
echo " Continuando de todas formas..."
|
|
else
|
|
echo "Launcher corriendo OK"
|
|
fi
|
|
else
|
|
echo "WARN: no se encontro ps.sh, no se puede verificar el estado de los agentes"
|
|
fi
|
|
|
|
# --- Element Web ---
|
|
|
|
echo ""
|
|
echo "=== Element Web ==="
|
|
ELEMENT_STARTED_BY_US=false
|
|
|
|
if [ -x "$ELEMENT_SCRIPT" ]; then
|
|
if "$ELEMENT_SCRIPT" status 2>/dev/null | grep -q "corriendo\|running\|listening"; then
|
|
echo "Element Web ya esta corriendo"
|
|
else
|
|
echo "Levantando Element Web..."
|
|
"$ELEMENT_SCRIPT" start
|
|
ELEMENT_STARTED_BY_US=true
|
|
# Esperar a que el servidor este listo
|
|
sleep 2
|
|
fi
|
|
else
|
|
echo "WARN: setup-element.sh no encontrado. Asegurarse de que Element Web esta corriendo."
|
|
fi
|
|
|
|
# --- Ejecutar tests ---
|
|
|
|
echo ""
|
|
echo "=== Ejecutando E2E tests ==="
|
|
|
|
PLAYWRIGHT_ARGS=()
|
|
if [ "$HEADED" = true ]; then
|
|
if [ -z "${DISPLAY:-}" ] && [ -z "${WAYLAND_DISPLAY:-}" ]; then
|
|
echo "WARN: --headed solicitado pero no se detecta DISPLAY. Ejecutando headless."
|
|
else
|
|
PLAYWRIGHT_ARGS+=("--headed")
|
|
fi
|
|
fi
|
|
|
|
# Agregar argumentos extra del usuario
|
|
if [ ${#EXTRA_ARGS[@]} -gt 0 ]; then
|
|
PLAYWRIGHT_ARGS+=("${EXTRA_ARGS[@]}")
|
|
fi
|
|
|
|
EXIT_CODE=0
|
|
cd "$E2E_DIR"
|
|
npx playwright test "${PLAYWRIGHT_ARGS[@]}" || EXIT_CODE=$?
|
|
|
|
# Generar reporte HTML si hay fallos
|
|
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
echo ""
|
|
echo "=== Generando reporte HTML ==="
|
|
npx playwright show-report --host 0.0.0.0 --port 0 2>/dev/null &
|
|
REPORT_PID=$!
|
|
sleep 1
|
|
kill "$REPORT_PID" 2>/dev/null || true
|
|
echo "Reporte disponible en: $E2E_DIR/playwright-report/"
|
|
echo " Para verlo: cd e2e && npx playwright show-report"
|
|
fi
|
|
|
|
# --- Teardown ---
|
|
|
|
if [ "$ELEMENT_STARTED_BY_US" = true ]; then
|
|
echo ""
|
|
echo "=== Deteniendo Element Web ==="
|
|
"$ELEMENT_SCRIPT" stop 2>/dev/null || true
|
|
fi
|
|
|
|
# --- Resultado ---
|
|
|
|
echo ""
|
|
if [ "$EXIT_CODE" -eq 0 ]; then
|
|
echo "=== Todos los tests pasaron ==="
|
|
else
|
|
echo "=== Algunos tests fallaron (exit code: $EXIT_CODE) ==="
|
|
echo "Ver screenshots en: $E2E_DIR/test-results/"
|
|
fi
|
|
|
|
exit "$EXIT_CODE"
|