-
Notifications
You must be signed in to change notification settings - Fork 1
WEBSOCKET_TESTING_GUIDE
GitHub Actions Bot edited this page May 3, 2026
·
3 revisions
Version: v0.5.0 Date: January 31, 2026
- Start nself-admin:
pnpm dev - Have a test project with services running
- Open browser console to see WebSocket events (optional)
- Navigate to
/(Dashboard) - Ensure you have at least one service running
- Look for connection badge next to environment badge
- Badge should show green with "Live" text and Wifi icon
- Hover over badge - tooltip should say "Real-time updates active"
- Click "Stop" on a running service
- Expected:
- Service card immediately shows "Stopping" status (yellow)
- After 1-2 seconds, shows "Stopped" status (red)
- No page refresh required
- Connection badge stays green
- Click "Start" on the stopped service
- Expected:
- Service card immediately shows "Starting" status (yellow)
- After 2-3 seconds, shows "Running" status (green)
- Health indicator updates to "healthy"
- Click "Restart" on a running service
- Expected:
- Service card shows "Restarting" status (yellow)
- After 3-4 seconds, shows "Running" status (green)
- Stop your WiFi or disconnect network
- Expected:
- Connection badge turns yellow, shows "Reconnecting"
- After ~5 seconds, turns red, shows "Offline"
- Restore network connection
- Expected:
- Badge automatically turns yellow "Reconnecting"
- Within 1-2 seconds, turns green "Live"
- Service status updates resume
- ✅ All status changes appear within <2 seconds
- ✅ No console errors
- ✅ Connection indicator accurately reflects WebSocket state
- ✅ Auto-reconnect works without page refresh
- Navigate to
/build - Ensure project has
.envfile
- Connection indicator should not be visible (build not started)
- Click "Start Build"
- Expected:
- Connection indicator appears immediately (green)
- Progress bar starts at 0%
- Build step 1 shows "in-progress" (blue spinner)
- Watch progress bar
- Expected:
- Progress increases: 0% → 10% → 40% → 70% → 100%
- Each step completes and shows green checkmark
- Current step shows blue spinner
- Elapsed time counter updates every second
- Wait for completion
- Expected:
- Progress reaches 100%
- All steps show green checkmarks
- "Build Successful!" message appears
- Auto-redirect to
/startafter 2 seconds
- Rename
.envto.env.backup - Click "Retry Build"
- Expected:
- Build starts
- Progress stops at ~40%
- Build step 2 shows red X
- Error message appears: "Build failed: docker-compose.yml was not created"
- "Build Failed" header shows
- Connection indicator stays green (still connected)
- Restore
.envfile - Start a build
- Immediately stop WiFi
- Expected:
- Connection indicator turns yellow "Reconnecting..."
- Build continues (API call already in progress)
- Progress updates may lag
- When network restores, updates resume
- ✅ Progress updates appear within <500ms
- ✅ Build steps update in correct order
- ✅ Error messages are clear and immediate
- ✅ Connection indicator shows accurate state
- Navigate to a service page (e.g.,
/services/postgres) - Open logs viewer component
- Connection indicator shows green (top-right of logs card)
- "Stream" button is available
- No logs are marked as "live" yet
- Click "Stream" button
- Expected:
- Button changes to "Pause"
- Connection indicator stays green
- Footer shows "Live streaming" with pulsing dot (green)
- Generate some logs (restart the service)
- Expected:
- New logs appear immediately in viewer
- Auto-scroll to bottom
- Footer shows count like "(5 live)" in green
- Click "Pause" button
- Expected:
- Button changes back to "Stream"
- "Live streaming" indicator disappears
- No new logs appear (even if service generates them)
- Click "Stream" to resume
- Select "Error" from log level filter
- Expected:
- Only error-level logs are shown
- Live logs still appear (if they're errors)
- Count shows filtered total
- Type "postgres" in search box
- Expected:
- Only logs containing "postgres" are shown
- Live logs still appear (if they match search)
- Streaming continues in background
- ✅ Logs appear within <500ms of generation
- ✅ Auto-scroll works smoothly
- ✅ Filters work with live logs
- ✅ Pause/resume works correctly
- Open Dashboard in Tab 1
- Open same Dashboard in Tab 2
- Both tabs show green connection indicator
- Browser console shows 2 separate WebSocket connections
- In Tab 1, stop a service
- Expected:
- Tab 1: Service status updates immediately
- Tab 2: Service status also updates immediately
- Both tabs stay in sync
- Close Tab 1
- Expected:
- Tab 2 continues working normally
- Tab 2 connection stays green
- No errors in Tab 2 console
- ✅ Each tab maintains its own WebSocket connection
- ✅ Updates appear in all tabs simultaneously
- ✅ Closing one tab doesn't affect others
- Open browser DevTools → Network tab
- Filter by "ws" (WebSocket)
- Load Dashboard
- Expected in Network tab:
- WebSocket connection established to
/api/ws - Connection stays open (not constantly reconnecting)
- No errors
- Click "Stop" on a service
- Measure:
- Time from click to status change
- Target: <100ms
- Use browser DevTools Performance tab for precise measurement
- Open Logs Viewer
- Click "Stream"
- Restart a service (generates many logs quickly)
- Expected:
- Logs appear in batches (not individual events)
- Network tab shows fewer WebSocket messages than actual log lines
- Target: ~80% reduction in events
- Open DevTools → Memory tab
- Let app run for 5 minutes with logs streaming
- Take heap snapshot
- Expected:
- No significant memory increase
- Old log entries are garbage collected
- No memory leaks
- ✅ Event latency <100ms
- ✅ Event batching reduces network calls by ~80%
- ✅ No memory leaks over 5+ minutes
- ✅ Connection stays stable
- Start with Dashboard open
- Stop the nself-admin server (
Ctrl+C) - Expected:
- Connection indicator turns red "Offline"
- Dashboard continues to function (shows cached data)
- Restart server (
pnpm dev) - Expected:
- Connection indicator turns yellow "Reconnecting"
- Within 1-2 seconds, turns green "Live"
- Real-time updates resume
- Open browser console
- Send invalid event via console:
// This should be handled gracefully window.dispatchEvent(new CustomEvent('invalid-ws-event'))
- Expected:
- No crashes
- Connection stays green
- Normal operation continues
- ✅ App handles disconnections gracefully
- ✅ Auto-reconnect works reliably
- ✅ Invalid events don't cause crashes
Open browser console and run:
// See all WebSocket events
localStorage.setItem('debug', 'ws:*')
// See specific event types
localStorage.setItem('debug', 'ws:service-status')
localStorage.setItem('debug', 'ws:build-progress')
localStorage.setItem('debug', 'ws:logs')Refresh page to enable debugging.
-
Connection events:
ws:connected,ws:disconnected -
Service events:
ws:service-statuswith service name and status -
Build events:
ws:build-progresswith progress percentage -
Log events:
ws:logswith log lines (batched)
Symptoms: Badge shows "Offline", never turns green Possible Causes:
- WebSocket server not initialized
- Port 3021 blocked by firewall
- Browser doesn't support WebSocket
Solution:
- Check browser console for errors
- Navigate to
/api/ws- should return WebSocket status - Try different browser
- Check firewall settings
Symptoms: Services change status but UI doesn't update Possible Causes:
- WebSocket connected but events not emitted
- Event subscription not working
Solution:
- Check browser console - should see
ws:service-statusevents - Check server logs - should see "Emitting service status" messages
- Verify API routes are importing
emitServiceStatuscorrectly
Symptoms: Progress bar stops, never completes Possible Causes:
- Build actually failed but error not shown
- WebSocket disconnected mid-build
Solution:
- Check browser console for errors
- Check server logs for build errors
- Verify
emitBuildProgressis called for all stages
Symptoms: "Stream" button active but no logs appear Possible Causes:
- Service not generating logs
- Event subscription not working
Solution:
- Verify service is running
- Restart service to generate logs
- Check browser console for
ws:logsevents - Verify API is calling
emitLogStream
Before each release, verify:
- Dashboard connection indicator works
- Service start/stop updates appear instantly
- Build progress shows all stages
- Build errors are displayed clearly
- Logs stream in real-time
- Pause/resume streaming works
- Multiple tabs work independently
- Auto-reconnect works after network interruption
- No memory leaks after 10 minutes
- Event latency <100ms
- No console errors
# Test hooks
npm test src/hooks/useWebSocket.test.ts
npm test src/hooks/useServiceStatus.test.ts
npm test src/hooks/useBuildProgress.test.ts# Test WebSocket server
npm test src/lib/websocket/server.test.ts
# Test event emission
npm test src/lib/websocket/emitters.test.ts# Playwright tests
npx playwright test tests/websocket-integration.spec.tsIf issues persist:
- Check
docs/WEBSOCKET_IMPLEMENTATION.mdfor architecture details - Check
src/lib/websocket/README.mdfor usage examples - Review browser console and server logs
- File an issue with reproduction steps
Last Updated: January 31, 2026 Version: v0.5.0
Version: 1.0.0 | Updated: 2026-09-16 11:21 UTC | GitHub