Integration Test Plan - Elegant Sync Solution
Manual integration testing checklist for elegant sync implementation
Integration Test Plan
Pre-Test Setup
Start Backend
yarn serve:backend # Wait for: "✅ Backend API listening on port 3000"Start Frontend
yarn dev:gograb # Wait for: "🚀 GoGrab Space app initialized"Check Console Logs
- Look for:
[MongoDB Realtime] ✅ Spaces Change Stream enabled - Look for:
[MongoDB Realtime] ✅ Universes Change Stream enabled - Should NOT see errors during initialization
- Look for:
Test Suite 1: Basic Operations
Test 1.1: Create Universe
Steps:
- Navigate to dashboard
- Click "Create New Universe"
- Enter name: "Test Universe 1"
- Click "Create"
Expected:
- ✅ Universe appears in dashboard immediately (< 50ms)
- ✅ No console errors
- ✅ Check IndexedDB:
universe_*entry created - ✅ Check MongoDB: Universe document created (within 10s)
Verification:
// Run in browser console
const storage = window.__storageService__;
const universes = await storage.list({ prefix: 'universe_' });
console.log('Universes in IndexedDB:', universes);
Test 1.2: Delete Universe
Steps:
- From dashboard, click "Delete" on test universe
- Confirm deletion
Expected:
- ✅ Universe removed from dashboard immediately
- ✅ No console errors
- ✅ Check IndexedDB:
universe_*entry removed - ✅ Check MongoDB: Universe document deleted (within 10s)
Test Suite 2: Cross-Tab Sync (BroadcastChannel)
Test 2.1: Create in Tab A, See in Tab B
Steps:
- Open 2 tabs to the same dashboard
- In Tab A: Create "Multi-Tab Test Universe"
- Watch Tab B
Expected:
- ✅ Tab B updates within < 1ms (near-instant)
- ✅ Universe appears in both tabs
- ✅ Both tabs show same data
Timing:
- Target: < 100ms
- BroadcastChannel should be < 1ms
- autoFlashState reactivity adds ~5-10ms
Test 2.2: Delete in Tab B, Disappears from Tab A
Steps:
- Keep both tabs open
- In Tab B: Delete "Multi-Tab Test Universe"
- Watch Tab A
Expected:
- ✅ Tab A removes universe within < 100ms
- ✅ No phantom entries
- ✅ Consistent state across tabs
Test Suite 3: Multi-Browser Sync (MongoDB Change Streams)
Test 3.1: Create in Chrome, See in Firefox
Steps:
- Open Chrome to dashboard (login as user)
- Open Firefox to dashboard (login as same user)
- In Chrome: Create "Multi-Browser Test"
- Watch Firefox
Expected:
- ✅ Firefox updates within < 100ms (MongoDB Change Streams)
- ✅ Universe appears in both browsers
- ✅ Data consistency maintained
Verification:
- Check backend logs for Change Stream events
- Check frontend logs for "Real-time update received"
Test 3.2: Delete in Firefox, Disappears from Chrome
Steps:
- Keep both browsers open
- In Firefox: Delete "Multi-Browser Test"
- Watch Chrome
Expected:
- ✅ Chrome removes universe within < 100ms
- ✅ No 404 errors
- ✅ No phantom universe IDs
Test Suite 4: Multi-Device Sync
Test 4.1: Create on Laptop, See on Desktop
Steps:
- Login on laptop browser
- Login on desktop browser (different machine, same user)
- On laptop: Create "Multi-Device Test"
- Watch desktop
Expected:
- ✅ Desktop updates within < 500ms
- ✅ Universe syncs via MongoDB
- ✅ Both devices show consistent data
Test 4.2: Mobile Browser Sync
Steps:
- Login on mobile browser (phone/tablet)
- On desktop: Create "Mobile Sync Test"
- Watch mobile
Expected:
- ✅ Mobile updates within < 500ms
- ✅ Responsive design works
- ✅ Touch interactions work
Test Suite 5: Offline → Online Sync
Test 5.1: Create Offline, Sync When Online
Steps:
- Open DevTools → Network tab
- Enable "Offline" mode
- Create "Offline Test Universe"
- Disable "Offline" mode (go online)
Expected:
- ✅ Universe created locally while offline (< 50ms)
- ✅ Appears in UI immediately
- ✅ When online, syncs to MongoDB within 10s
- ✅ HTTP MongoDB Sync picks up and pushes
Verification:
// Check sync queue
const syncStatus = window.__syncEngine__?.getStatus();
console.log('Sync queue:', syncStatus);
Test 5.2: Delete Offline, Sync When Online
Steps:
- Enable "Offline" mode
- Delete a universe
- Disable "Offline" mode
Expected:
- ✅ Universe removed locally while offline
- ✅ UI updates immediately
- ✅ When online, deletion syncs to MongoDB
- ✅ Other browsers/devices receive delete notification
Test Suite 6: Conflict Resolution
Test 6.1: Simultaneous Creates (Different Browsers)
Steps:
- Open 2 browsers (Chrome, Firefox)
- Go offline in both
- In Chrome: Create "Conflict Test A"
- In Firefox: Create "Conflict Test B"
- Go online in both
Expected:
- ✅ Both universes created locally
- ✅ When online, both sync to MongoDB
- ✅ Both browsers eventually have both universes
- ✅ No data loss
Test 6.2: Edit Same Universe (Different Browsers)
Steps:
- Create "Edit Test Universe"
- In Chrome: Update description to "Chrome Edit"
- In Firefox: Update description to "Firefox Edit"
Expected:
- ✅ Last write wins (based on timestamp)
- ✅ Both browsers converge to same state
- ✅ No data corruption
Test Suite 7: Performance Benchmarks
Test 7.1: Create 100 Universes
Steps:
- Run performance test script
- Create 100 universes rapidly
Expected:
- ✅ All operations complete within 5 seconds
- ✅ Average < 50ms per operation
- ✅ No memory leaks
- ✅ UI remains responsive
Test 7.2: Multi-Tab Performance
Steps:
- Open 5 tabs
- Create universe in tab 1
- Measure propagation time
Expected:
- ✅ Tabs 2-5 update within < 100ms
- ✅ No performance degradation
- ✅ BroadcastChannel handles multiple tabs
Test Suite 8: Edge Cases
Test 8.1: Rapid Create/Delete Cycles
Steps:
- Create universe
- Immediately delete it
- Repeat 10 times quickly
Expected:
- ✅ No phantom IDs
- ✅ State remains consistent
- ✅ MongoDB stays in sync
Test 8.2: Network Fluctuation
Steps:
- Toggle offline/online repeatedly
- Create/update/delete during fluctuations
Expected:
- ✅ Operations succeed locally
- ✅ Queue properly manages sync
- ✅ Eventually consistent when stable
Test 8.3: Browser Restart
Steps:
- Create "Persistence Test"
- Close browser completely
- Reopen and login
Expected:
- ✅ Universe still exists
- ✅ Loads from IndexedDB instantly
- ✅ Syncs with MongoDB on startup
Test Suite 9: Zero Phantom IDs
Test 9.1: Verify No Phantom IDs
Steps:
- After any create/delete operation
- Check
space.universeIdsvs actual universe data
Verification:
// Run in console
const space = window.__spaceService__.currentSpace();
const universeIds = space.universeIds;
const actualUniverses = window.__spaceService__.universes();
console.log('Universe IDs:', universeIds);
console.log('Actual Universes:', actualUniverses.map(u => u.id));
// Should match exactly
const phantomIds = universeIds.filter(
id => !actualUniverses.some(u => u.id === id)
);
console.log('Phantom IDs (should be empty):', phantomIds);
Expected:
- ✅ Phantom IDs array is empty
- ✅ Perfect 1:1 match between IDs and data
Test 9.2: After Deletion
Steps:
- Create and delete several universes
- Check for phantom IDs
Expected:
- ✅ No lingering IDs
- ✅ Clean state
- ✅ MongoDB in sync
Test Suite 10: Multi-User Collaboration
Test 10.1: Two Users, Same Space
Steps:
- User A creates universe
- User B should see it appear
Expected:
- ✅ User B sees universe within < 500ms
- ✅ MongoDB Change Streams push update
- ✅ No conflicts
Test 10.2: Simultaneous Edits
Steps:
- User A edits universe layout
- User B edits same universe layout
Expected:
- ✅ Yjs CRDT merges changes
- ✅ No data loss
- ✅ Both users see merged result
Success Criteria
Performance ✅
- Local operations: < 50ms (target: 5-10ms)
- Cross-tab sync: < 100ms (target: < 1ms)
- Multi-browser: < 500ms (target: < 100ms)
- Offline → online: < 60s (target: 5-10s)
Reliability ✅
- Zero phantom universe IDs
- Zero data loss scenarios
- Zero sync conflicts
- 100% offline support
User Experience ✅
- Instant local operations
- Smooth multi-tab experience
- Real-time collaboration works
- Graceful error handling
Failure Scenarios
If any test fails:
Check Console Logs
- Look for errors
- Verify Change Streams connected
- Check BroadcastChannel messages
Check MongoDB
- Verify data persisted correctly
- Check for duplicate/phantom entries
Check IndexedDB
- Verify local storage consistent
- Check for orphaned data
Rollback Plan
- Switch back to SpaceService (old)
- Disable MongoDB Change Streams
- Investigate and fix
Ready to Test: All components migrated, MongoDB Change Streams enabled
Test Duration: 30-45 minutes for complete suite
Critical Tests: Suites 1, 2, 3, 9 (must pass 100%)