- Full PWA support with offline capabilities - Comprehensive search across songs, playlists, and channels - Offline playlist manager with download tracking - Pre-built frontend for zero-build deployment - Docker-based deployment with docker compose - Material-UI dark theme interface - YouTube audio download and management - Multi-user authentication support
9.8 KiB
9.8 KiB
🎵 SoundWave PWA - Setup & Testing Guide
🚀 Quick Start
Prerequisites
- Node.js 18+ and npm
- Python 3.10+
- Docker & Docker Compose (optional)
Installation
-
Clone and Install
cd soundwave/frontend npm install -
Generate PWA Icons (Optional for testing)
# If you have ImageMagick installed: ../scripts/generate-pwa-icons.sh # Otherwise, use online tools: # - https://www.pwabuilder.com/imageGenerator # - https://realfavicongenerator.net/ -
Start Development Server
npm run devVisit: http://localhost:3000
-
Build for Production
npm run build npm run previewVisit: http://localhost:4173
📱 Testing PWA Features
1. Test Service Worker
- Open Chrome DevTools (F12)
- Go to Application tab
- Click Service Workers in sidebar
- Verify:
- ✅ Service worker is registered
- ✅ Status shows "activated and is running"
- ✅ Source:
/service-worker.js
2. Test Manifest
- In DevTools > Application tab
- Click Manifest in sidebar
- Verify:
- ✅ Name: "SoundWave"
- ✅ Short name: "SoundWave"
- ✅ Start URL: "/"
- ✅ Display: "standalone"
- ✅ Icons: 8 icons (72px to 512px)
- ✅ Theme color: "#1976d2"
3. Test Offline Mode
- In DevTools > Application > Service Workers
- Check Offline checkbox
- Reload the page (Ctrl+R)
- Verify:
- ✅ Page loads successfully
- ✅ Cached content is displayed
- ✅ Offline indicator shows in UI
- ✅ "You're offline" alert appears
4. Test Cache Storage
- In DevTools > Application > Cache Storage
- Verify caches:
- ✅
soundwave-v1(static assets) - ✅
soundwave-api-v1(API responses) - ✅
soundwave-audio-v1(audio files) - ✅
soundwave-images-v1(images)
- ✅
- Click on each cache to view cached items
5. Test Install Prompt
Desktop (Chrome/Edge):
- Visit http://localhost:4173 (must be preview mode)
- Look for install icon in address bar
- Click to install
- Or wait 3 seconds for install prompt
Mobile (Chrome):
- Visit site in Chrome mobile
- Wait for "Add to Home Screen" prompt
- Tap "Add" to install
Mobile (Safari iOS):
- Visit site in Safari
- Tap Share button
- Scroll and tap "Add to Home Screen"
- Confirm
6. Run Lighthouse Audit
- Open Chrome DevTools
- Go to Lighthouse tab
- Select:
- ✅ Progressive Web App
- ✅ Performance
- ✅ Accessibility
- ✅ Best Practices
- ✅ SEO
- Click Generate report
- Target scores:
- PWA: 100/100
- Performance: 90+/100
- Accessibility: 95+/100
- Best Practices: 100/100
- SEO: 100/100
7. Test Media Session API
- Play an audio file
- Check notification tray (desktop/mobile)
- Verify:
- ✅ Song title displayed
- ✅ Artist name displayed
- ✅ Album art shown (if available)
- ✅ Play/pause button works
- ✅ Seek buttons work (10s forward/back)
Lock Screen (Mobile):
- Play audio
- Lock device
- Check lock screen controls
8. Test Notifications
- Go to Settings page
- Find PWA section
- Toggle Enable push notifications
- Accept permission prompt
- Verify:
- ✅ Permission granted
- ✅ Toggle stays enabled
- ✅ Success message shown
9. Test Cache Management
- Go to Settings > PWA section
- Check cache size display
- Click Clear Cache button
- Verify:
- ✅ Cache cleared successfully
- ✅ Cache size resets
- ✅ Success message shown
- Reload page to rebuild cache
10. Test Update Flow
- Make a change to code
- Build new version:
npm run build - In running app, wait ~30 seconds
- Verify:
- ✅ Update notification appears
- ✅ "Update" button shown
- Click "Update"
- Verify:
- ✅ Page reloads
- ✅ New version active
🧪 Testing Checklist
Installation
- Desktop Chrome install prompt appears
- Desktop Edge install prompt appears
- Android Chrome "Add to Home Screen" works
- iOS Safari "Add to Home Screen" works
- Installed app opens in standalone mode
- App has correct icon and name
Offline Functionality
- Service worker registers successfully
- Page loads offline
- Previously viewed content accessible offline
- Offline indicator shows when offline
- Online indicator shows when back online
- Cached audio plays offline
- Images load from cache offline
Performance
- First page load < 3 seconds
- Subsequent loads < 1 second
- Smooth scrolling on mobile
- No layout shift
- Touch targets ≥ 44px
- No zoom on input focus
Media Controls
- Media session metadata shows correctly
- Play/pause from notification tray works
- Lock screen controls work (mobile)
- Seek forward/backward works
- Position state updates on system controls
- Controls disappear when audio ends
UI/UX
- Install prompt shows after 3 seconds
- Update prompt shows when available
- Offline alert persistent when offline
- Online notification shows briefly
- Cache size displays correctly
- Clear cache works
- All buttons have proper touch feedback
- Loading states show appropriately
Responsive Design
- Works on mobile (320px width)
- Works on tablet (768px width)
- Works on desktop (1920px width)
- Safe areas respected on notched devices
- Landscape mode works correctly
Accessibility
- Keyboard navigation works
- Focus indicators visible
- Screen reader compatible
- Color contrast sufficient
- Reduced motion respected
Cross-Browser
- Chrome Desktop
- Chrome Android
- Edge Desktop
- Safari Desktop
- Safari iOS
- Firefox Desktop
- Samsung Internet
🐛 Troubleshooting
Service Worker Not Registering
Issue: Console shows service worker registration failed
Solutions:
- Serve over HTTPS or localhost
- Check service worker file path is correct
- Clear browser cache (Ctrl+Shift+Delete)
- Check console for detailed error
- Verify
vite.config.tshas correctpublicDir
# Force rebuild
rm -rf frontend/dist
npm run build
Install Prompt Not Showing
Issue: No install button or prompt appears
Checklist:
- Using HTTPS or localhost
- Manifest.json loads without errors
- Service worker registered and active
- All manifest icons exist
- User hasn't dismissed recently (wait 90 days)
- User hasn't already installed
- Using Chrome/Edge (not Firefox/Safari)
Test:
// In console
window.addEventListener('beforeinstallprompt', (e) => {
console.log('Install prompt available!', e);
});
Offline Mode Not Working
Issue: Page doesn't load offline
Solutions:
- Visit pages while online first (to cache them)
- Check service worker is active:
navigator.serviceWorker.getRegistration().then(reg => { console.log('Active:', reg?.active); }); - Check cache storage has content:
- DevTools > Application > Cache Storage
- Verify fetch handler in service worker
Media Session Not Working
Issue: No controls in notification tray
Browser Support:
- ✅ Chrome Desktop/Android
- ✅ Edge Desktop
- ⚠️ Safari (limited)
- ❌ Firefox Desktop (partial)
Solutions:
- Check if API supported:
if ('mediaSession' in navigator) { console.log('Media Session API supported'); } - Verify metadata is set correctly
- Check action handlers are defined
- Test in Chrome first
Cache Not Clearing
Issue: Old content still showing after clear
Solutions:
- Hard refresh (Ctrl+Shift+R)
- Clear browser cache:
- DevTools > Application > Clear storage > Clear site data
- Unregister service worker:
navigator.serviceWorker.getRegistrations().then(registrations => { registrations.forEach(reg => reg.unregister()); }); - Reload page
Icons Not Loading
Issue: Icons show broken or default
Solutions:
- Generate icons:
../scripts/generate-pwa-icons.sh - Or use online tools and place in
frontend/public/img/ - Required sizes: 72, 96, 128, 144, 152, 192, 384, 512
- Update manifest.json paths if needed
- Clear cache and rebuild
📊 Performance Optimization
Check Bundle Size
npm run build -- --report
Analyze Cache Usage
// In console
async function checkCacheSize() {
const estimate = await navigator.storage.estimate();
const usage = estimate.usage / (1024 * 1024); // MB
const quota = estimate.quota / (1024 * 1024); // MB
console.log(`Cache: ${usage.toFixed(2)} MB / ${quota.toFixed(2)} MB`);
}
checkCacheSize();
Monitor Service Worker
// In console
navigator.serviceWorker.addEventListener('message', (event) => {
console.log('SW Message:', event.data);
});
📚 Additional Resources
- Full Documentation: PWA_IMPLEMENTATION.md
- Complete Summary: COMPLETE_PWA_SUMMARY.md
- Developer Guide: PWA_DEVELOPER_GUIDE.md
- Icon Generator: https://www.pwabuilder.com/imageGenerator
- PWA Checklist: https://web.dev/pwa-checklist/
- Lighthouse: https://developers.google.com/web/tools/lighthouse
🎉 Success Criteria
Your PWA is ready when:
- ✅ Lighthouse PWA score: 100/100
- ✅ Installs successfully on all platforms
- ✅ Works offline with cached content
- ✅ Service worker registers and caches content
- ✅ Media controls work in notification tray
- ✅ Update flow works correctly
- ✅ All touch targets ≥ 44px
- ✅ Responsive on all screen sizes
- ✅ Accessible via keyboard
- ✅ No console errors
Ready to Deploy? Check the production deployment guide in PWA_IMPLEMENTATION.md!