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/); }); });