🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
🔖 Checkpoint: Edit /workspaces/claude-code-flow/user-service/tests/integration/user.routes.test.ts
rUvc08fc99694e6
diff --git a/.claude/checkpoints/1754489077.json b/.claude/checkpoints/1754489077.jsonnew file mode 100644index 0000000000..23134544fc--- /dev/null+++ b/.claude/checkpoints/1754489077.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250806-140437", "file": "/workspaces/claude-code-flow/user-service/tests/unit/user.service.test.ts", "timestamp": "2025-08-06T14:04:37Z", "type": "pre-edit", "original_branch": "alpha-88"}diff --git a/.claude/checkpoints/1754489079.json b/.claude/checkpoints/1754489079.jsonnew file mode 100644index 0000000000..40d60fabd0--- /dev/null+++ b/.claude/checkpoints/1754489079.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250806-140439", "file": "/workspaces/claude-code-flow/user-service/tests/unit/user.service.test.ts", "timestamp": "2025-08-06T14:04:39Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 24 +++ .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754489037.json | 1 + .claude/checkpoints/1754489039.json | 1 + benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- claude-flow-wiki | 0 user-service/tests/unit/user.service.test.ts | 187 +++++++++++++++++++++++ 9 files changed, 221 insertions(+), 8 deletions(-) "}diff --git a/benchmark/.claude/checkpoints/1754489088.json b/benchmark/.claude/checkpoints/1754489088.jsonnew file mode 100644index 0000000000..12645c9388--- /dev/null+++ b/benchmark/.claude/checkpoints/1754489088.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250806-140448", "file": "/workspaces/claude-code-flow/claude-flow-wiki/Benchmark-System.md", "timestamp": "2025-08-06T14:04:48Z", "type": "pre-edit", "original_branch": "alpha-88"}diff --git a/benchmark/.claude/checkpoints/1754489098.json b/benchmark/.claude/checkpoints/1754489098.jsonnew file mode 100644index 0000000000..2142a66637--- /dev/null+++ b/benchmark/.claude/checkpoints/1754489098.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250806-140458", "file": "/workspaces/claude-code-flow/claude-flow-wiki/Benchmark-System.md", "timestamp": "2025-08-06T14:04:58Z", "type": "pre-edit", "original_branch": "alpha-88"}diff --git a/benchmark/.claude/checkpoints/1754489119.json b/benchmark/.claude/checkpoints/1754489119.jsonnew file mode 100644index 0000000000..4643058932--- /dev/null+++ b/benchmark/.claude/checkpoints/1754489119.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250806-140519", "file": "/workspaces/claude-code-flow/claude-flow-wiki/Benchmark-System.md", "timestamp": "2025-08-06T14:05:19Z", "type": "pre-edit", "original_branch": "alpha-88"}diff --git a/user-service/tests/integration/user.routes.test.ts b/user-service/tests/integration/user.routes.test.tsnew file mode 100644index 0000000000..8d71bd59d9--- /dev/null+++ b/user-service/tests/integration/user.routes.test.ts@@ -0,0 +1,251 @@+import request from 'supertest';+import { createApp } from '../../src/app';+import { Application } from 'express';+import { userRepository } from '../../src/repositories/user.repository';++describe('User Routes Integration', () => {+ let app: Application;+ let authToken: string;+ let userId: string;++ beforeAll(() => {+ app = createApp();+ });++ beforeEach(async () => {+ await userRepository.clear();+ });++ describe('POST /api/register', () => {+ it('should register a new user', async () => {+ const response = await request(app)+ .post('/api/register')+ .send({+ email: '[email protected]',+ username: 'testuser',+ password: 'Test123!@#',+ firstName: 'Test',+ lastName: 'User',+ });++ expect(response.status).toBe(201);+ expect(response.body.success).toBe(true);+ expect(response.body.data.email).toBe('[email protected]');+ expect(response.body.data).not.toHaveProperty('password');++ userId = response.body.data.id;+ });++ it('should validate required fields', async () => {+ const response = await request(app)+ .post('/api/register')+ .send({+ email: 'invalid-email',+ username: 'test',+ });++ expect(response.status).toBe(400);+ expect(response.body.success).toBe(false);+ });++ it('should prevent duplicate email registration', async () => {+ const userData = {+ email: '[email protected]',+ username: 'testuser1',+ password: 'Test123!@#',+ };++ await request(app).post('/api/register').send(userData);++ const response = await request(app)+ .post('/api/register')+ .send({ ...userData, username: 'testuser2' });++ expect(response.status).toBe(409);+ expect(response.body.error.message).toContain('Email already exists');+ });+ });++ describe('POST /api/login', () => {+ beforeEach(async () => {+ const registerResponse = await request(app)+ .post('/api/register')+ .send({+ email: '[email protected]',+ username: 'testuser',+ password: 'Test123!@#',+ });++ userId = registerResponse.body.data.id;+ });++ it('should login with valid credentials', async () => {+ const response = await request(app)+ .post('/api/login')+ .send({+ email: '[email protected]',+ password: 'Test123!@#',+ });++ expect(response.status).toBe(200);+ expect(response.body.success).toBe(true);+ expect(response.body.data.token).toBeDefined();+ expect(response.body.data.user.email).toBe('[email protected]');++ authToken = response.body.data.token;+ });++ it('should reject invalid credentials', async () => {+ const response = await request(app)+ .post('/api/login')+ .send({+ email: '[email protected]',+ password: 'WrongPassword',+ });++ expect(response.status).toBe(401);+ expect(response.body.error.message).toContain('Invalid credentials');+ });+ });++ describe('Protected Routes', () => {+ beforeEach(async () => {+ // Register and login to get auth token+ await request(app)+ .post('/api/register')+ .send({+ email: '[email protected]',+ username: 'testuser',+ password: 'Test123!@#',+ role: 'admin',+ });++ const loginResponse = await request(app)+ .post('/api/login')+ .send({+ email: '[email protected]',+ password: 'Test123!@#',+ });++ authToken = loginResponse.body.data.token;+ userId = loginResponse.body.data.user.id;+ });++ describe('GET /api/profile', () => {+ it('should get user profile with valid token', async () => {+ const response = await request(app)+ .get('/api/profile')+ .set('Authorization', `Bearer ${authToken}`);++ expect(response.status).toBe(200);+ expect(response.body.data.email).toBe('[email protected]');+ });++ it('should reject request without token', async () => {+ const response = await request(app)+ .get('/api/profile');++ expect(response.status).toBe(401);+ });+ });++ describe('PUT /api/users/:id', () => {+ it('should update user profile', async () => {+ const response = await request(app)+ .put(`/api/users/${userId}`)+ .set('Authorization', `Bearer ${authToken}`)+ .send({+ firstName: 'Updated',+ lastName: 'Name',+ });++ expect(response.status).toBe(200);+ expect(response.body.data.firstName).toBe('Updated');+ expect(response.body.data.lastName).toBe('Name');+ });+ });++ describe('POST /api/change-password', () => {+ it('should change password with correct old password', async () => {+ const response = await request(app)+ .post('/api/change-password')+ .set('Authorization', `Bearer ${authToken}`)+ .send({+ oldPassword: 'Test123!@#',+ newPassword: 'NewTest123!@#',+ });++ expect(response.status).toBe(200);+ expect(response.body.message).toContain('Password changed successfully');+ });++ it('should reject with incorrect old password', async () => {+ const response = await request(app)+ .post('/api/change-password')+ .set('Authorization', `Bearer ${authToken}`)+ .send({+ oldPassword: 'WrongPassword',+ newPassword: 'NewTest123!@#',+ });++ expect(response.status).toBe(401);+ });+ });++ describe('GET /api/users', () => {+ beforeEach(async () => {+ // Create multiple users+ for (let i = 0; i < 5; i++) {+ await request(app)+ .post('/api/register')+ .send({+ email: `user${i}@example.com`,+ username: `user${i}`,+ password: 'Test123!@#',+ });+ }+ });++ it('should list users with pagination', async () => {+ const response = await request(app)+ .get('/api/users')+ .set('Authorization', `Bearer ${authToken}`)+ .query({ page: 1, limit: 3 });++ expect(response.status).toBe(200);+ expect(response.body.data).toHaveLength(3);+ expect(response.body.meta.totalPages).toBeGreaterThan(1);+ });++ it('should filter users by search', async () => {+ const response = await request(app)+ .get('/api/users')+ .set('Authorization', `Bearer ${authToken}`)+ .query({ search: 'user1' });++ expect(response.status).toBe(200);+ expect(response.body.data.length).toBeGreaterThan(0);+ });+ });+ });++ describe('Health Check', () => {+ it('should return health status', async () => {+ const response = await request(app).get('/health');++ expect(response.status).toBe(200);+ expect(response.body.status).toBe('healthy');+ expect(response.body.timestamp).toBeDefined();+ });+ });++ describe('API Documentation', () => {+ it('should return API documentation', async () => {+ const response = await request(app).get('/api/docs');++ expect(response.status).toBe(200);+ expect(response.body.name).toBe('User Service API');+ expect(response.body.endpoints).toBeDefined();+ });+ });+});\ No newline at end of file