# QA Plan: WebSocket Chat
## Test Scope
### Unit Tests
| Test | File | Description |
|------|------|-------------|
| Config loading | `internal/config/config_test.go` | Verify RedisURL loads from env |
### Integration Tests
| Test | File | Description |
|------|------|-------------|
| WebSocket upgrade | `internal/api/handlers/websocket_test.go` | Verify HTTP→WS upgrade |
| Message broadcast | `internal/api/handlers/websocket_test.go` | Verify messages reach all clients |
| Room isolation | `internal/api/handlers/websocket_test.go` | Verify room messages stay in room |
| Ping/pong | `internal/api/handlers/websocket_test.go` | Verify heartbeat mechanism |
### Manual Tests
| Test | Steps | Expected |
|------|-------|----------|
| Basic chat | 1. Start server
2. Connect two wscat clients
3. Send message from one | Other client receives message |
| Room chat | 1. Connect clients to `/ws/room1`
2. Connect client to `/ws/room2`
3. Send to room1 | Only room1 clients receive |
| Disconnect | 1. Connect client
2. Kill client
3. Check server logs | Clean disconnect logged |
## Acceptance Criteria
- [ ] WebSocket endpoint accessible at `/api/chat-api/ws`
- [ ] Messages broadcast to all connected clients
- [ ] Room-based messaging isolates conversations
- [ ] Connection lifecycle properly managed
## Test Commands
```bash
# Run all Go tests
go test ./services/chat-api/... -v
# Manual WebSocket test
wscat -c ws://localhost:8001/api/chat-api/ws
```