diff --git a/README.md b/README.md index 66a6204..66151a4 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,11 @@ graph TD - Environment variable validation (`src/server.ts`, `src/services/webhook-manager.ts`). - Health check endpoint (`/health`). - **User validation integration**: Normalization and `ensureUserExists` are now fully integrated in the main message handling flow (`src/server.ts`). -- **Comprehensive test suite**: All tests pass (86 pass, 0 fail), including integration tests for user validation. +- **Comprehensive test suite**: All tests pass (97 pass, 0 fail), including integration tests for user validation. +- **Database isolation in unit tests**: Implemented using in-memory instances to avoid conflicts between tests. ### Incomplete / Missing Core Functionality -- **User/Group Validation Integration:** Although normalization (`normalizeWhatsAppId`) and user creation (`ensureUserExists`) functions exist, they are **not yet integrated** into the main request handling flow in `src/server.ts` to validate senders or automatically add users on first message. Similarly, the active group cache from `group-sync.ts` is **not yet used** in `server.ts` to filter messages from inactive/unknown groups. +- **User/Group Validation Integration:** Although normalization (`normalizeWhatsAppId`) and user creation (`ensureUserExists`) functions exist, they are **not yet integrated** into the main request handling flow in `src/server.ts` to validate senders or automatically add users on first message. Similarly, the active group cache from `group-sync.ts` is **not yet used** in `src/server.ts` to filter messages from inactive/unknown groups. - **Core Command Logic:** Actual processing of `/tarea nueva` (parsing args, calling `TaskService`) is missing in `CommandService`. Other commands (`mostrar`, `completar`) not implemented. - **Task Service Implementation:** `TaskService` needs updating to handle `created_by`, assignments, and potentially methods for listing/completing tasks. - **Response Sending:** `ResponseQueue` does not yet send messages back via the Evolution API. @@ -110,8 +111,9 @@ bun test ### Phase 1: User & Group Foundation (Highest Priority - In Progress) - [x] **Create WhatsApp ID Normalization Utility:** (`src/utils/whatsapp.ts`) Handle different ID formats. - [x] **Implement `ensureUserExists`:** (`src/db.ts`) Add users to DB on first interaction. -- [x] **Implement `isGroupActive` Check:** (`src/services/group-sync.ts`, `src/server.ts`) Cache exists in `group-sync.ts`. **Needs integration** into `server.ts`. +- [x] **Implement `isGroupActive` Check:** (`src/services/group-sync.ts`, `src/server.ts`) Cache exists in `group-sync.ts`. **Needs integration** into `src/server.ts`. - [x] **Integrate Validation in Server:** (`src/server.ts`) Use normalization, `ensureUserExists`, and active group check before processing commands. +- [x] **Implement DB isolation in tests:** (`tests/unit/services/group-sync.test.ts`) Use in-memory instances to avoid conflicts. ### Phase 2: Implement `/tarea nueva` Command (High Priority) - [ ] **Update `TaskService.createTask`:** (`src/tasks/service.ts`) Handle `created_by` and assignments (including adding assigned users via `ensureUserExists`). @@ -159,6 +161,7 @@ bun test - 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. +- All tests now pass (97 pass, 0 fail), including isolated DB instances for group-sync tests. ### Test Coverage - Database initialization and basic operations (`db.test.ts`). diff --git a/STATUS.md b/STATUS.md index 213eb95..d6d99eb 100644 --- a/STATUS.md +++ b/STATUS.md @@ -20,10 +20,12 @@ - Parser básico de acciones/fechas - **Testing** - Suite completa de tests unitarios - - Todos los tests pasan (86 pass, 0 fail) + - Todos los tests pasan (97 pass, 0 fail) - **Validaciones de Usuario** - Integración completa de normalización y `ensureUserExists` en el flujo principal de mensajes - Tests de integración para validaciones de usuarios +- **Aislamiento de Base de Datos en Pruebas** + - Uso de instancias en memoria para evitar conflictos entre tests ## ⚠️ Funcionalidades Pendientes - **Gestión de Tareas** @@ -36,8 +38,6 @@ - **Validaciones** - Permisos de usuario no implementados - Sin verificación de pertenencia a grupos -- **Eventos** - - GROUPS_UPSERT/MESSAGES_UPDATE sin manejar - **Comandos** - Acciones de tareas no implementadas (crear/listar)