import { describe, it, expect } from 'vitest' import { GET } from '@/app/api/agents/route' import { NextRequest } from 'next/server' describe('/api/agents', () => { it('returns list of standard agents', async () => { const request = new NextRequest('http://localhost:3000/api/agents') const response = await GET(request) const data = await response.json() expect(response.status).toBe(200) expect(data.agents).toBeDefined() expect(Array.isArray(data.agents)).toBe(true) expect(data.agents.length).toBeGreaterThan(0) }) it('includes agent-1 (Repoguide)', async () => { const request = new NextRequest('http://localhost:3000/api/agents') const response = await GET(request) const data = await response.json() const agent1 = data.agents.find((a: any) => a.id === 'agent-1') expect(agent1).toBeDefined() expect(agent1?.name).toBe('Repoguide') expect(agent1?.description).toBe('Documenting the development process.') }) it('includes agent-2 (Morgan)', async () => { const request = new NextRequest('http://localhost:3000/api/agents') const response = await GET(request) const data = await response.json() const agent2 = data.agents.find((a: any) => a.id === 'agent-2') expect(agent2).toBeDefined() expect(agent2?.name).toBe('Morgan') expect(agent2?.description).toBe('System Prompt Designer') }) it('agent response does not include webhookUrl', async () => { const request = new NextRequest('http://localhost:3000/api/agents') const response = await GET(request) const data = await response.json() data.agents.forEach((agent: any) => { expect(agent).toHaveProperty('id') expect(agent).toHaveProperty('name') expect(agent).toHaveProperty('description') expect(agent).not.toHaveProperty('webhookUrl') }) }) it('agent response includes id, name, and description', async () => { const request = new NextRequest('http://localhost:3000/api/agents') const response = await GET(request) const data = await response.json() expect(data.agents.length).toBeGreaterThan(0) const firstAgent = data.agents[0] expect(firstAgent.id).toBeDefined() expect(typeof firstAgent.id).toBe('string') expect(firstAgent.name).toBeDefined() expect(typeof firstAgent.name).toBe('string') expect(firstAgent.description).toBeDefined() expect(typeof firstAgent.description).toBe('string') }) })