Files
agents_and_robots/e2e/tests/create-bot-pipeline.spec.ts
T
egutierrez f3581721b1 test: E2E tests para robot test-bot y pipeline de creacion
Tests funcionales (test-bot.spec.ts):
- help lista built-in + custom commands sin prefijo !
- ping funciona sin prefijo y con ! (retrocompatible)
- echo repite texto exacto (assertion estricta)
- dice devuelve numero 1-6
- comando desconocido muestra error descriptivo
- sin errores E2EE en el timeline

Tests de pipeline (create-bot-pipeline.spec.ts):
- Valida estructura: agent.go, config.yaml, commands.go
- Verifica type: robot, command_prefix vacio, encryption habilitada
- Confirma ausencia de prompts/system.md
- Verifica import en launcher

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 20:43:24 +00:00

63 lines
2.3 KiB
TypeScript

import { test, expect } from "@playwright/test";
import * as fs from "fs";
import * as path from "path";
const REPO_ROOT = path.resolve(__dirname, "../..");
const AGENT_DIR = path.join(REPO_ROOT, "agents/test-bot");
const LAUNCHER = path.join(REPO_ROOT, "cmd/launcher/main.go");
test.describe("create-bot pipeline (validacion estructural)", () => {
test("agents/test-bot/agent.go existe y exporta Rules()", () => {
const agentGo = path.join(AGENT_DIR, "agent.go");
expect(fs.existsSync(agentGo)).toBe(true);
const content = fs.readFileSync(agentGo, "utf-8");
expect(content).toContain("func Rules()");
expect(content).toContain('agents.Register("test-bot"');
expect(content).toContain("return nil");
});
test("agents/test-bot/config.yaml tiene type: robot", () => {
const configYaml = path.join(AGENT_DIR, "config.yaml");
expect(fs.existsSync(configYaml)).toBe(true);
const content = fs.readFileSync(configYaml, "utf-8");
expect(content).toMatch(/type:\s*robot/);
expect(content).toMatch(/id:\s*test-bot/);
expect(content).toMatch(/enabled:\s*true/);
});
test("agents/test-bot NO tiene prompts/system.md", () => {
const systemPrompt = path.join(AGENT_DIR, "prompts/system.md");
expect(fs.existsSync(systemPrompt)).toBe(false);
});
test("agents/test-bot/commands.go existe con Commands()", () => {
const commandsGo = path.join(AGENT_DIR, "commands.go");
expect(fs.existsSync(commandsGo)).toBe(true);
const content = fs.readFileSync(commandsGo, "utf-8");
expect(content).toContain("func Commands()");
expect(content).toContain('"echo"');
expect(content).toContain('"dice"');
});
test("cmd/launcher/main.go tiene import de test-bot", () => {
const content = fs.readFileSync(LAUNCHER, "utf-8");
expect(content).toContain("agents/test-bot");
});
test("config.yaml tiene command_prefix vacio (sin prefijo !)", () => {
const configYaml = path.join(AGENT_DIR, "config.yaml");
const content = fs.readFileSync(configYaml, "utf-8");
expect(content).toMatch(/command_prefix:\s*""/);
});
test("config.yaml tiene encryption habilitada", () => {
const configYaml = path.join(AGENT_DIR, "config.yaml");
const content = fs.readFileSync(configYaml, "utf-8");
// encryption.enabled should be true
expect(content).toMatch(/encryption:[\s\S]*?enabled:\s*true/);
});
});