7.1 KiB
7.1 KiB
🧪 Test Client Quick Reference
🚀 Getting Started
1. Start Server
npm run dev
2. Open Test Client
Open test-client.html in your browser
3. Connect
- Anonymous: Leave token field empty → Click "Connect"
- Authenticated: Paste JWT token → Click "Connect"
📡 WebSocket Tests
Basic Tests
| Action | Button/Field | Expected Result |
|---|---|---|
| Connect | "Connect" button | Status: ✅ Connected |
| Ping | "Send Ping" button | Receive pong response |
| Custom | Edit JSON field + "Send Message" | Custom response |
| Disconnect | "Disconnect" button | Status: ❌ Disconnected |
Custom Message Examples
{"type": "ping"}
{"type": "custom", "data": {"test": true}}
{"type": "subscribe", "channel": "marketplace"}
🔥 Stress Tests
Gradual Test
- Set Number of Messages: 10-1000
- Set Interval (ms): 10-5000
- Click "🚀 Run Stress Test"
- Monitor progress in real-time
- Click "⏹️ Stop Test" to abort
Recommended Tests
- Light: 10 msgs @ 500ms
- Medium: 100 msgs @ 100ms
- Heavy: 500 msgs @ 50ms
- Extreme: 1000 msgs @ 10ms
Burst Test
- Click "💥 Send Burst (100 msgs)"
- Sends 100 messages instantly
- Tests rapid-fire handling
🛒 Marketplace API Tests
Prerequisites
1. Login: http://localhost:3000/auth/steam
2. Set trade URL (required for creating listings)
3. Keep WebSocket connected to receive broadcasts
Get Listings
Fields:
- Game: All / CS2 / Rust
- Min Price: (optional)
- Max Price: (optional)
Button: "Get Listings"
Response: List of marketplace items
Create Listing
Fields:
- Item Name: "AK-47 | Redline"
- Game: CS2 / Rust
- Price: 45.99
- Description: (optional)
Button: "Create Listing (Requires Auth)"
Expected:
- ✅ Success response
- 📡 WebSocket broadcast:
new_listing
Update Price
Fields:
- Listing ID: "listing_123"
- New Price: 39.99
Button: "Update Price (Requires Auth)"
Expected:
- ✅ Success response
- 📡 WebSocket broadcast:
price_update
Set Trade URL
Field:
- Steam Trade URL:
https://steamcommunity.com/tradeoffer/new/?partner=...
Button: "Set Trade URL (Requires Auth)"
Format: Must be valid Steam trade offer URL:
https://steamcommunity.com/tradeoffer/new/?partner=XXXXXXXXX&token=XXXXXXXX
Expected: ✅ Trade URL saved
Note: Both PUT and PATCH methods supported
📊 Statistics
Real-Time Counters
- Messages Received: Total WebSocket messages received
- Messages Sent: Total WebSocket messages sent
- Connection Time: How long connected (updates every second)
💬 Messages Panel
Message Types
- 🟢 Received: Messages from server (green border)
- 🔵 Sent: Messages sent to server (blue border)
- 🔴 Error: Errors and disconnections (red border)
Message Format
[Time] 10:30:45 AM
[Type] PING / API / CONNECTION / ERROR
[Content] JSON or text content
Clear Messages
Click "Clear Messages" button to reset the message log
🎯 Quick Test Scenarios
Scenario 1: Basic WebSocket Test (30 seconds)
1. Connect (anonymous)
2. Send Ping
3. Verify pong received
4. Send custom message
5. Disconnect
✅ WebSocket working
Scenario 2: Stress Test (1 minute)
1. Connect
2. Set: 100 msgs @ 100ms
3. Run Stress Test
4. Verify all received
5. Run Burst Test
✅ Socket stable under load
Scenario 3: Marketplace Test (2 minutes)
1. Login via Steam
2. Set trade URL
3. Create listing
4. Verify broadcast received
5. Update price
6. Verify broadcast received
✅ Marketplace working
Scenario 4: Multi-Client Test (3 minutes)
1. Open 2 browser tabs
2. Connect both to WebSocket
3. Tab 1: Create listing
4. Tab 2: Should receive broadcast
5. Tab 1: Update price
6. Tab 2: Should receive update
✅ Broadcasting working
🔍 Troubleshooting
Can't Connect to WebSocket
✓ Check server is running: curl http://localhost:3000/health
✓ Verify URL: ws://localhost:3000/ws
✓ Try anonymous connection first
✓ Check firewall settings
CORS Errors
✓ Server configured to allow file:// protocol
✓ Restart server if you just updated config
✓ All localhost ports allowed in development
401 Unauthorized
✓ Login: http://localhost:3000/auth/steam
✓ Check cookies are enabled
✓ Clear cookies and login again
No Broadcasts Received
✓ Verify WebSocket is connected
✓ Check you're on the right channel
✓ Try reconnecting WebSocket
✓ Check server logs
Stress Test Connection Drops
✓ Reduce message count
✓ Increase interval
✓ Expected at >500 msgs
✓ Check server rate limiting
🔗 Quick Links
Server Endpoints
- Health: http://localhost:3000/health
- API Info: http://localhost:3000/
- Steam Login: http://localhost:3000/auth/steam
- Current User: http://localhost:3000/auth/me
- Listings: http://localhost:3000/marketplace/listings
WebSocket
- Connection: ws://localhost:3000/ws
- With Token: ws://localhost:3000/ws?token=YOUR_TOKEN
📋 Test Checklist
Basic Tests
- Anonymous WebSocket connection
- Authenticated WebSocket connection
- Send ping/pong
- Send custom message
- View statistics
- Clear messages
Stress Tests
- Gradual test (10 msgs)
- Gradual test (100 msgs)
- Burst test (100 msgs)
- Connection stays stable
- All messages received
Marketplace Tests
- Get all listings
- Filter by game
- Filter by price
- Create listing
- Update price
- Set trade URL
- Receive broadcasts
Multi-Client Tests
- Open 2 browsers
- Both receive broadcasts
- Create listing in one
- Verify other receives it
💡 Tips
Performance
- Clear messages before large tests
- Monitor browser console for errors
- Check server logs for issues
- Document test results
Authentication
- Login via Steam first
- Token stored in cookies automatically
- Token expires after 15 minutes
- Refresh by logging in again
Broadcasting
- Keep WebSocket connected
- Multiple clients can connect
- Broadcasts are real-time
- Check Messages panel for updates
Stress Testing
- Start small (10 messages)
- Gradually increase load
- Document breaking points
- Test reconnection after stress
📚 Related Documentation
- TESTING_GUIDE.md - Comprehensive testing guide
- WEBSOCKET_AUTH.md - Authentication details
- WEBSOCKET_GUIDE.md - WebSocket features
- NEW_FEATURES.md - Latest features
- FIXED.md - Known issues and fixes
🎓 Keyboard Shortcuts
(Future enhancement)
Ctrl+Enter- Send messageCtrl+K- Clear messagesCtrl+R- Reconnect WebSocketEsc- Stop stress test
📞 Need Help?
- Check browser console (F12)
- Check server logs
- See TESTING_GUIDE.md
- Check FIXED.md for known issues
- Verify server is running
Last Updated: After Issue #8 (CORS fix for file:// protocol)
Status: ✅ All features working
Quick Test: Open test-client.html → Click Connect → Click Send Ping → Verify pong received