Team mode stays in the repository but is not built or shipped (ADR-0003). - The team server (index.ts, config, db, daemons, plugins, proactive, routes, scheduler, services, ws, drizzle migrations) and its tests move from @waggle/server to packages/team-server (@waggle/team-server, private). It keeps its own copies of the logger and the agent-group executor, so it does not import @waggle/server. @clerk/fastify, bullmq, ioredis, postgres, drizzle-orm, drizzle-kit, cron-parser and @waggle/waggle-dance leave @waggle/server; the launcher drops the same team-only dependencies. - build:packages no longer builds waggle-dance or the worker: nothing in the community edition imports them, and the worker's project reference would otherwise build the team server. The worker now imports from team-server; the team Dockerfile builds both explicitly. - The sidecar no longer starts the team server when DATABASE_URL is set, and loses the team routes (/api/team/*, /api/teams), the WaggleDance routes and bridge (/api/waggle-dance/*), the Team server binding and egress guard, the WebSocket team client, the TeamSync cache and pushes, team audit forwarding, team workspace registration and the team capability-policy lookup in chat. The in-process room signal bus stays: agent groups, fleet runs and external tool runs use it. middleware/audit.ts was dead and is deleted. - @waggle/core loses TeamSync and the teamServer part of WaggleConfig. A teamServer key in config.json is ignored and kept on save, as P0.1 does for the tier keys. Workspaces lose teamServerUrl and teamUserId; teamId and teamRole stay because workspaces from a shared data directory still carry them and the viewer write guards read them. POST /api/workspaces ignores team fields. - The sidecar bundle no longer marks the team packages as external. The agent still references the TeamSync type in orchestrator.ts and pattern-write-back.ts; those files are being rewritten in P1.5 and drop it there. Logs UF-030 and UF-031 (team sync and team policy defects found while removing the code).
140 lines
5.4 KiB
TypeScript
140 lines
5.4 KiB
TypeScript
/**
|
|
* Team Server E2E — tests the multi-user team server running on Docker
|
|
* (Postgres + Redis + LiteLLM).
|
|
*
|
|
* Requires: docker-compose up (postgres:5434, redis:6381, litellm:4000)
|
|
* Team server running on port 3100.
|
|
*/
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
const TEAM = 'http://127.0.0.1:3100';
|
|
|
|
test.beforeEach(async ({ request }) => {
|
|
try {
|
|
const res = await request.get(`${TEAM}/health`, { timeout: 1_000 });
|
|
test.skip(!res.ok(), 'Optional team server is not running on 127.0.0.1:3100');
|
|
} catch {
|
|
test.skip(true, 'Optional team server is not running on 127.0.0.1:3100');
|
|
}
|
|
});
|
|
|
|
// ── 1. Server Health ──────────────────────────────────────────────────
|
|
|
|
test.describe('1. Team Server Health', () => {
|
|
test('health endpoint responds', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/health`);
|
|
expect(res.ok()).toBeTruthy();
|
|
const data = await res.json();
|
|
expect(data.status).toBe('ok');
|
|
});
|
|
});
|
|
|
|
// ── 2. Team CRUD ──────────────────────────────────────────────────────
|
|
|
|
test.describe('2. Team Management', () => {
|
|
let teamSlug: string;
|
|
|
|
test('can create a team', async ({ request }) => {
|
|
const name = `TestTeam-${Date.now()}`;
|
|
teamSlug = name.toLowerCase().replace(/[^a-z0-9]/g, '-');
|
|
const res = await request.post(`${TEAM}/api/teams`, {
|
|
data: { name, slug: teamSlug },
|
|
headers: { 'Content-Type': 'application/json' },
|
|
});
|
|
// May need auth — accept 200, 201, or 401
|
|
expect([200, 201, 401, 403]).toContain(res.status());
|
|
});
|
|
|
|
test('can list teams', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/api/teams`);
|
|
expect([200, 401, 403]).toContain(res.status());
|
|
if (res.ok()) {
|
|
const data = await res.json();
|
|
expect(Array.isArray(data) || Array.isArray(data.teams)).toBeTruthy();
|
|
}
|
|
});
|
|
});
|
|
|
|
// ── 3. Agent Routes ───────────────────────────────────────────────────
|
|
|
|
test.describe('3. Agent & Model Routes', () => {
|
|
test('agents list', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/api/agents`);
|
|
expect([200, 401]).toContain(res.status());
|
|
});
|
|
|
|
test('workflows list', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/api/workflows`);
|
|
expect([200, 401, 404]).toContain(res.status());
|
|
});
|
|
});
|
|
|
|
// ── 4. Database Connection ────────────────────────────────────────────
|
|
|
|
test.describe('4. Database', () => {
|
|
test('postgres is reachable from server', async ({ request }) => {
|
|
// The server started successfully which means DB connected.
|
|
// Verify by hitting an endpoint that requires DB.
|
|
const res = await request.get(`${TEAM}/api/teams`);
|
|
// If 500, DB connection failed. 200 or 401 means DB is fine.
|
|
expect(res.status()).not.toBe(500);
|
|
});
|
|
});
|
|
|
|
// ── 5. WebSocket Gateway ──────────────────────────────────────────────
|
|
|
|
test.describe('5. WebSocket', () => {
|
|
test('ws endpoint exists', async ({ request }) => {
|
|
// HTTP GET to /ws should return upgrade required or similar
|
|
const res = await request.get(`${TEAM}/ws`);
|
|
// WebSocket endpoints typically return 400 or 426 on plain HTTP
|
|
expect([400, 404, 426]).toContain(res.status());
|
|
});
|
|
});
|
|
|
|
// ── 6. Cron & Jobs ────────────────────────────────────────────────────
|
|
|
|
test.describe('6. Background Services', () => {
|
|
test('cron status endpoint', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/api/cron`);
|
|
expect([200, 401, 404]).toContain(res.status());
|
|
});
|
|
});
|
|
|
|
// ── 7. Knowledge & Resources ──────────────────────────────────────────
|
|
|
|
test.describe('7. Knowledge Routes', () => {
|
|
test('skills endpoint', async ({ request }) => {
|
|
const res = await request.get(`${TEAM}/api/skills`);
|
|
expect([200, 401, 404]).toContain(res.status());
|
|
});
|
|
});
|
|
|
|
// ── 8. Concurrent Requests ────────────────────────────────────────────
|
|
|
|
test.describe('8. Concurrency', () => {
|
|
test('10 concurrent health checks all succeed', async ({ request }) => {
|
|
const results = await Promise.all(
|
|
Array.from({ length: 10 }, () => request.get(`${TEAM}/health`))
|
|
);
|
|
for (const res of results) {
|
|
expect(res.ok()).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
test('server handles rapid API calls without crashing', async ({ request }) => {
|
|
const endpoints = ['/health', '/api/teams', '/api/agents', '/api/workflows', '/api/cron'];
|
|
const results = await Promise.all(
|
|
endpoints.map(ep => request.get(`${TEAM}${ep}`))
|
|
);
|
|
// No 500s — server survived the burst
|
|
for (const res of results) {
|
|
expect(res.status()).toBeLessThan(500);
|
|
}
|
|
|
|
// Health still ok after burst
|
|
const health = await request.get(`${TEAM}/health`);
|
|
expect(health.ok()).toBeTruthy();
|
|
});
|
|
});
|