Background
EventsGateway.handleConnection joins authenticated clients to user:<sub>
rooms. Unauthenticated connections (no token or invalid token) should not be
added to any user room. There are no tests confirming this behavior.
Goal
Add tests in src/websocket/events.gateway.spec.ts.
Requirements
-
No token: connect a socket without auth.token; assert socket.join
is NOT called with any user:* room.
-
Invalid token: connect with auth.token = "invalid.jwt.token"; assert
socket.join not called with user room (JWT verify throws and is caught).
-
Valid token: connect with a valid JWT; assert socket.join is called
Acceptance criteria
- User rooms only joined by authenticated sockets.
- Invalid/missing tokens handled gracefully without crashing.
Background
EventsGateway.handleConnectionjoins authenticated clients touser:<sub>rooms. Unauthenticated connections (no token or invalid token) should not be
added to any user room. There are no tests confirming this behavior.
Goal
Add tests in
src/websocket/events.gateway.spec.ts.Requirements
No token: connect a socket without
auth.token; assertsocket.joinis NOT called with any
user:*room.Invalid token: connect with
auth.token = "invalid.jwt.token"; assertsocket.joinnot called with user room (JWT verify throws and is caught).Valid token: connect with a valid JWT; assert
socket.joinis calledAcceptance criteria