- 新增 CLIPluginAdapter 统一接口 (backend/app/core/agent_adapter.py) - 新增 LLM 服务层,支持 Anthropic/OpenAI/DeepSeek/Ollama (backend/app/services/llm_service.py) - 新增 Agent 执行引擎,支持文件锁自动管理 (backend/app/services/agent_executor.py) - 新增 NativeLLMAgent 原生 LLM 适配器 (backend/app/adapters/native_llm_agent.py) - 新增进程管理器 (backend/app/services/process_manager.py) - 新增 Agent 控制 API (backend/app/routers/agents_control.py) - 新增 WebSocket 实时通信 (backend/app/routers/websocket.py) - 更新前端 AgentsPage,支持启动/停止 Agent - 测试通过:Agent 启动、批量操作、栅栏同步 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
// API 接口测试
|
|
test.describe('Swarm API 接口测试', () => {
|
|
const apiBase = 'http://localhost:8000/api';
|
|
|
|
test('健康检查接口', async ({ request }) => {
|
|
const response = await request.get(`${apiBase}/health`);
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('status');
|
|
expect(body).toHaveProperty('version');
|
|
expect(body.status).toBe('healthy');
|
|
});
|
|
|
|
test('获取 Agent 列表', async ({ request }) => {
|
|
const response = await request.get(`${apiBase}/agents`);
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('agents');
|
|
expect(Array.isArray(body.agents)).toBeTruthy();
|
|
});
|
|
|
|
test('获取文件锁列表', async ({ request }) => {
|
|
const response = await request.get(`${apiBase}/locks`);
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('locks');
|
|
expect(Array.isArray(body.locks)).toBeTruthy();
|
|
});
|
|
|
|
test('获取心跳列表', async ({ request }) => {
|
|
const response = await request.get(`${apiBase}/heartbeats`);
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('heartbeats');
|
|
});
|
|
|
|
test('注册 Agent', async ({ request }) => {
|
|
const testAgent = {
|
|
agent_id: `test-agent-${Date.now()}`,
|
|
name: 'Test Agent',
|
|
role: 'developer',
|
|
model: 'test-model',
|
|
description: 'Playwright 测试用 Agent',
|
|
};
|
|
|
|
const response = await request.post(`${apiBase}/agents/register`, {
|
|
data: testAgent,
|
|
});
|
|
|
|
expect(response.ok()).toBeTruthy();
|
|
const body = await response.json();
|
|
expect(body.agent_id).toBe(testAgent.agent_id);
|
|
expect(body.name).toBe(testAgent.name);
|
|
});
|
|
|
|
test('解析任务文件', async ({ request }) => {
|
|
const response = await request.post(`${apiBase}/parse-task`, {
|
|
data: { task: '修复 src/auth/login.py 中的 bug' },
|
|
});
|
|
|
|
expect(response.ok()).toBeTruthy();
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('files');
|
|
expect(Array.isArray(body.files)).toBeTruthy();
|
|
});
|
|
|
|
test('获取任务主要角色', async ({ request }) => {
|
|
const response = await request.post(`${apiBase}/roles/primary`, {
|
|
data: { task: '实现登录功能并编写测试用例' },
|
|
});
|
|
|
|
expect(response.ok()).toBeTruthy();
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('primary_role');
|
|
expect(body).toHaveProperty('role_scores');
|
|
});
|
|
|
|
test('列出工作流文件', async ({ request }) => {
|
|
const response = await request.get(`${apiBase}/workflows/files`);
|
|
expect(response.ok()).toBeTruthy();
|
|
|
|
const body = await response.json();
|
|
expect(body).toHaveProperty('files');
|
|
expect(Array.isArray(body.files)).toBeTruthy();
|
|
});
|
|
});
|