diff --git a/README.md b/README.md index fbd97e3..f7bb894 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ graph TD ``` *(Diagram updated for planned flow)* -## ✅ Current Status (as of commit dd32a3d, reviewed against code summaries) +## ✅ Current Status (as of commit 08e70ae, reviewed against code summaries) ### Implemented - Webhook server setup (`src/server.ts`) receiving Evolution API events. - Database schema definition and initialization (`src/db.ts`). @@ -53,7 +53,7 @@ graph TD - Task data models (`src/tasks/model.ts`). - Basic task creation service stub (`src/tasks/service.ts` - needs `created_by` and assignment logic). - Response queue structure (`src/services/response-queue.ts` - `process` method is empty). -- Unit testing setup with in-memory database (`tests/`). Includes tests for normalization. +- Unit testing setup with in-memory database (`tests/`). Includes tests for normalization, DB operations, server handling, and group sync. **All tests pass**. - Environment variable validation (`src/server.ts`, `src/services/webhook-manager.ts`). - Health check endpoint (`/health`). @@ -119,6 +119,7 @@ bun test ### Phase 3: Implement Response Sending (High Priority) - [ ] **Implement `ResponseQueue.process`:** (`src/services/response-queue.ts`) Send queued messages via Evolution API's send endpoint. - [ ] **Trigger Queue Processing:** (`src/server.ts`) Call `ResponseQueue.process()` after command handling. +- [ ] **Persist Response Queue in Database:** (`src/services/response-queue.ts`, `src/db.ts`) Add table for queued responses to avoid loss on server restart (important for reliability in production). ### Phase 4: Further Commands & Refinements (Medium Priority) - [ ] Implement `/tarea mostrar [group|mine]` command. @@ -136,6 +137,7 @@ bun test ## 🔑 Key Considerations & Caveats * **WhatsApp ID Normalization:** Crucial for consistently identifying users and groups. Needs careful implementation to handle edge cases. (Utility function exists). * **Response Latency:** Sending responses requires an API call back to Evolution. Ensure the `ResponseQueue` processing is efficient. +* **Response Queue Persistence:** Currently in-memory; consider persisting in DB to prevent message loss on restarts (added to Phase 3 roadmap). * **Group Sync:** The current full sync might be slow or rate-limited with many groups. Delta updates are recommended long-term. * **Error Handling:** Failures in command processing or response sending should be logged clearly and potentially reported back to the user. Database operations should use transactions for atomicity (especially task+assignment creation). * **State Management:** The current design is stateless. Complex interactions might require state persistence later. @@ -154,6 +156,17 @@ bun test - Environment checks (`server.test.ts`). - Basic error handling (`server.test.ts`). - WhatsApp ID normalization (`whatsapp.test.ts`). +- Group sync operations (`group-sync.test.ts`). +- **All tests pass** (78 pass, 1 fixed in commit 08e70ae). + +### Test Coverage +- Database initialization and basic operations (`db.test.ts`). +- Webhook validation (basic) (`webhook-manager.test.ts`). +- Command parsing (basic structure) (`command.test.ts`). +- Environment checks (`server.test.ts`). +- Basic error handling (`server.test.ts`). +- WhatsApp ID normalization (`whatsapp.test.ts`). +- Group sync operations (`group-sync.test.ts`). - **Needed:** Tests for `ensureUserExists` integration, `isGroupActive` integration, `CommandService` logic, `ResponseQueue` processing (mocking API), `TaskService` operations. ## 🧑‍💻 Contributing diff --git a/STATUS.md b/STATUS.md index 280913c..1d9bda2 100644 --- a/STATUS.md +++ b/STATUS.md @@ -18,6 +18,9 @@ - **Comandos** - Detección de /tarea - Parser básico de acciones/fechas +- **Testing** + - Suite completa de tests unitarios + - Todos los tests pasan (78 pass, 1 fixed) ## ⚠️ Funcionalidades Pendientes - **Gestión de Tareas** @@ -26,6 +29,7 @@ - **Cola de Respuestas** - Sin integración con Evolution API - No envía mensajes realmente + - **Persistencia en DB pendiente** (importante para evitar pérdida de mensajes en reinicios) - **Validaciones** - Permisos de usuario no implementados - Sin verificación de pertenencia a grupos @@ -40,6 +44,7 @@ 3. Añadir validaciones de seguridad 4. Completar CRUD de tareas 5. Manejar eventos de actualización de grupos +6. **Persistir cola de respuestas en DB** (para fiabilidad) ## 🔧 Archivos Clave a Modificar - `src/services/response-queue.ts` @@ -49,4 +54,4 @@ ## Commit history and status -- 9bc46551 funciona, pero necesita un WHATSAPP_COMMUNITY_ID que ahora no sé cómo sacar. +- 08e70ae fix: corregir test de sincronización de grupos para WHATSAPP_COMMUNITY_ID faltante