# 🧪 SPRINT 2 - TESTS MANUELS (15 min)

**Objectif:** Valider les 3 optimisations en conditions réelles

---

## Test 1: Compression Diff (5 min) ✅

### Setup:
1. `pnpm dev` (démarrer frontend)
2. Ouvrir DevTools → Console
3. Ouvrir un plan existant avec 5+ stages

### Actions:
1. Edit stage title: "Test Compression"
2. Reorder 2 stages (drag & drop)
3. Add POI suggestion

### Résultat attendu (Console):
```
📦 Compression diff: { full: 102400, diff: 2048, ratio: '98.0%' }
📦 Compression diff: { full: 104500, diff: 1820, ratio: '98.3%' }
📦 Compression diff: { full: 107200, diff: 3100, ratio: '97.1%' }
```

### ✅ Success Criteria:
- [ ] Logs compression visibles
- [ ] Ratio > 95%
- [ ] diff < 5KB

---

## Test 2: Debounce Sync (3 min) ⚡

### Setup:
1. DevTools → Network tab
2. Filter: "sync"
3. Disable cache
4. Plan avec 3+ stages ouvert

### Actions:
1. **Typing test:** Edit titre stage rapidement (10 caractères)
2. **Drag test:** Reorder 5 stages rapidement
3. **Batch test:** Edit titre + notes + location (rapide)

### Résultat attendu:
| Action | Requests AVANT | Requests APRÈS | Gain |
|--------|----------------|----------------|------|
| Typing (10 chars) | 10 | 1 | 90% ✅ |
| Reorder (5 stages) | 5 | 1 | 80% ✅ |
| Batch edit | 8 | 1-2 | 87% ✅ |

### ✅ Success Criteria:
- [ ] 1 seule requête POST /sync par action
- [ ] Délai ~1s après dernière modification
- [ ] Pas de perte de données

---

## Test 3: Bandwidth Réel (5 min) 📊

### Setup:
1. DevTools → Network tab
2. Disable cache
3. Clear network log
4. Plan vierge ouvert

### Actions (séquence complète):
1. Add 5 stages avec locations
2. Edit tous les titres
3. Reorder toutes les stages
4. Add 2 POI
5. Toggle completed status

### Mesures AVANT Sprint 2:
- Total transfered: ~500KB
- Requests: ~30
- Largest payload: 100KB

### Résultat attendu APRÈS Sprint 2:
- Total transfered: < 20KB (97% reduction)
- Requests: < 8 (75% reduction)
- Largest payload: < 5KB (95% reduction)

### ✅ Success Criteria:
- [ ] Total < 20KB
- [ ] Requests < 10
- [ ] Max payload < 5KB

---

## Test 4: Worker Infrastructure (2 min) 🔧

**Note:** Worker pas encore intégré, test infrastructure seulement

### Console DevTools:
```javascript
// Import worker client
const { getIndexedDBWorker } = await import('@/workers/indexedDBWorkerClient')

// Get worker instance
const worker = getIndexedDBWorker()

// Test persist
const testUpdate = new Uint8Array([1, 2, 3, 4, 5])
await worker.persist('test_plan_id', testUpdate)
console.log('✅ Persist OK')

// Test load
const loaded = await worker.load('test_plan_id')
console.log('✅ Load OK:', loaded)

// Test delete
await worker.delete('test_plan_id')
console.log('✅ Delete OK')

// Test clear
await worker.clear()
console.log('✅ Clear OK')
```

### ✅ Success Criteria:
- [ ] Pas d'erreurs console
- [ ] Persist returns success
- [ ] Load returns Uint8Array
- [ ] Delete/clear no errors

---

## 📊 RÉSULTATS ATTENDUS GLOBAUX

| Métrique | Cible | Measurement |
|----------|-------|-------------|
| **Compression ratio** | > 95% | ______% |
| **Bandwidth reduction** | > 90% | ______% |
| **Requests reduction** | > 75% | ______% |
| **Debounce latency** | ~1s | ______s |
| **Worker ready** | ✅ | ☐ |

---

## 🚨 TROUBLESHOOTING

### Compression logs pas visibles:
```bash
# Vérifier NODE_ENV
echo $NODE_ENV  # Doit être "development"

# Ou forcer en dev:
NODE_ENV=development pnpm dev
```

### Requests pas débounced:
```typescript
// Vérifier syncService.ts ligne 12-20
// debouncedSync() doit être appelé au lieu de sync()
```

### Worker errors:
```bash
# Vérifier build Vite
pnpm build
# Worker doit être dans dist/assets/
```

---

## ✅ VALIDATION FINALE

Si tous les tests passent:
- ✅ **Ready to deploy staging**
- ✅ **Monitor production logs**
- ✅ **Sprint 2 VALIDÉ**

Si problèmes:
- Check SPRINT2_PERFORMANCE_COMPLETE.md section "DÉTAILS TECHNIQUES"
- Check code files (syncService.ts, worker files)
- Report issues avec screenshots/logs

---

**Temps total estimé: 15 minutes**
**Criticité: MOYENNE (validation recommandée mais optionnelle)**
