diff --git a/backend/src/__tests__/app.test.js b/backend/src/__tests__/app.test.js index 7e5df1e..42a5847 100644 --- a/backend/src/__tests__/app.test.js +++ b/backend/src/__tests__/app.test.js @@ -61,7 +61,7 @@ describe('Backend API Tests', () => { it('should have CORS headers', async () => { const response = await request(app) .get('/api/health') - .set('Origin', 'http://localhost:3000') + .set('Origin', 'http://localhost:8080') .expect(200); expect(response.headers).toHaveProperty('access-control-allow-origin'); diff --git a/backend/src/__tests__/auth-phase1.5.test.js b/backend/src/__tests__/auth-phase1.5.test.js index d895adb..146e5d5 100644 --- a/backend/src/__tests__/auth-phase1.5.test.js +++ b/backend/src/__tests__/auth-phase1.5.test.js @@ -127,7 +127,8 @@ describe('Authentication API Tests - Phase 1.5', () => { }) .expect(400); - expect(response.body.error).toContain('WSDC ID'); + // Generic error message to prevent user enumeration + expect(response.body.error).toContain('already exists'); }); it('should continue registration even if email send fails', async () => { @@ -484,7 +485,9 @@ describe('Authentication API Tests - Phase 1.5', () => { }) .expect(400); - expect(response.body.error).toContain('8 characters'); + expect(response.body.error).toBe('Validation Error'); + expect(response.body.details).toBeDefined(); + expect(response.body.details[0].msg).toContain('8 characters'); }); it('should reject invalid token', async () => { diff --git a/backend/src/__tests__/socket.test.js b/backend/src/__tests__/socket.test.js index b4f55a5..fe5aa90 100644 --- a/backend/src/__tests__/socket.test.js +++ b/backend/src/__tests__/socket.test.js @@ -129,10 +129,24 @@ describe('Socket.IO Server', () => { type: 'event', }, }); + + // Create event participant (check-in) for test user + await prisma.eventParticipant.create({ + data: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); }); afterAll(async () => { // Cleanup test data + await prisma.eventParticipant.deleteMany({ + where: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); await prisma.chatRoom.delete({ where: { id: testChatRoom.id }, }); @@ -147,7 +161,7 @@ describe('Socket.IO Server', () => { }); clientSocket.on('connect', () => { - clientSocket.emit('join_event_room', { eventId: testEvent.id }); + clientSocket.emit('join_event_room', { slug: testEvent.slug }); }); clientSocket.on('active_users', (users) => { @@ -170,7 +184,7 @@ describe('Socket.IO Server', () => { }); client1.on('connect', () => { - client1.emit('join_event_room', { eventId: testEvent.id }); + client1.emit('join_event_room', { slug: testEvent.slug }); // Create second user and join the same room const client2Token = generateToken({ userId: testUser.id }); @@ -187,7 +201,7 @@ describe('Socket.IO Server', () => { }); client2.on('connect', () => { - client2.emit('join_event_room', { eventId: testEvent.id }); + client2.emit('join_event_room', { slug: testEvent.slug }); }); }); }); @@ -200,12 +214,11 @@ describe('Socket.IO Server', () => { const messageContent = 'Test message content'; clientSocket.on('connect', () => { - clientSocket.emit('join_event_room', { eventId: testEvent.id }); + clientSocket.emit('join_event_room', { slug: testEvent.slug }); clientSocket.on('active_users', () => { // Wait for active_users, then send message clientSocket.emit('send_event_message', { - eventId: testEvent.id, content: messageContent, }); }); @@ -242,12 +255,12 @@ describe('Socket.IO Server', () => { }); clientSocket.on('connect', () => { - clientSocket.emit('join_event_room', { eventId: testEvent.id }); + clientSocket.emit('join_event_room', { slug: testEvent.slug }); clientSocket.on('active_users', (users) => { if (users.length > 0) { // User joined, now leave - clientSocket.emit('leave_event_room', { eventId: testEvent.id }); + clientSocket.emit('leave_event_room'); setTimeout(() => { done(); }, 100); @@ -429,9 +442,23 @@ describe('Socket.IO Server', () => { type: 'event', }, }); + + // Create event participant (check-in) for test user + await prisma.eventParticipant.create({ + data: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); }); afterAll(async () => { + await prisma.eventParticipant.deleteMany({ + where: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); await prisma.chatRoom.delete({ where: { id: testChatRoom.id }, }); @@ -455,12 +482,12 @@ describe('Socket.IO Server', () => { client1.on('connect', () => { client1Connected = true; - client1.emit('join_event_room', { eventId: testEvent.id }); + client1.emit('join_event_room', { slug: testEvent.slug }); }); client2.on('connect', () => { client2Connected = true; - client2.emit('join_event_room', { eventId: testEvent.id }); + client2.emit('join_event_room', { slug: testEvent.slug }); }); client2.on('user_left', (userData) => { @@ -491,9 +518,23 @@ describe('Socket.IO Server', () => { endDate: new Date('2025-12-03'), }, }); + + // Create event participant (check-in) for test user + await prisma.eventParticipant.create({ + data: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); }); afterAll(async () => { + await prisma.eventParticipant.deleteMany({ + where: { + userId: testUser.id, + eventId: testEvent.id, + }, + }); await prisma.event.delete({ where: { id: testEvent.id }, }); @@ -505,11 +546,10 @@ describe('Socket.IO Server', () => { }); clientSocket.on('connect', () => { - clientSocket.emit('join_event_room', { eventId: testEvent.id }); + clientSocket.emit('join_event_room', { slug: testEvent.slug }); setTimeout(() => { clientSocket.emit('send_event_message', { - eventId: testEvent.id, content: 'Test message', }); }, 100);