Data Validation Tools
Relevant source files
The following files were used as context for generating this wiki page:
- scripts/validate-demo-data.js
- scripts/test-all-modules.js (Referenced in REPORTE-EJECUCION-PRUEBAS.md)
- REPORTE-EJECUCION-PRUEBAS.md
- VALIDACION-COMPLETA.md
- REPORTE_FINAL_VALIDACION.md
- REPORTE_CHAT_MODULE.md
- REPORTE_PRUEBAS_CRUD.md
The Data Validation Tools within the ELMEC Mobile App v2 project comprise a suite of automated scripts and manual testing frameworks designed to ensure the integrity, security, and functionality of the application's backend and frontend components. These tools focus on validating Supabase database schemas, Row Level Security (RLS) policies, storage bucket configurations, and core module logic such as Authentication, Requests, and Chat.
The primary objective of these tools is to provide comprehensive coverage across the application's MVP features, identifying critical bugs and schema inconsistencies before production deployment. By utilizing automated validation scripts, the project maintains a "100% operative" status for core functionalities while tracking minor non-critical issues.
Sources: VALIDACION-COMPLETA.md:5-20, REPORTE-EJECUCION-PRUEBAS.md:5-15
Module Validation Framework
The validation framework is structured to test modules individually and collectively. Each module undergoes functionality checks, quality assessments, and automated testing via specialized scripts.
Core Modules under Validation
| Module | Validation Status | Key Metrics |
|---|---|---|
| Authentication | 100% Functional | Login/Logout, Session Persistence, Token Refresh |
| Requests | 100% Functional | CRUD operations, Attachment system, Status transitions |
| Chat | 100% Functional | Real-time latency < 1s, Typing indicators, Presence |
| Storage | 69.2% Functional | CRUD operations on files, MIME type validation |
Sources: VALIDACION-COMPLETA.md:43-100, REPORTE_PRUEBAS_CRUD.md:7-15
Validation Logic Flow
The following diagram illustrates the high-level process of the validate-demo-data.js script, which serves as a health check for the demo environment.
The script validates the existence and integrity of data across users, requests, chats, and system metrics.
Sources: scripts/validate-demo-data.js:19-245
Database & Schema Validation
A significant portion of the toolset is dedicated to ensuring that the Supabase PostgreSQL schema matches the requirements of the application code.
Request Schema Verification
Validation scripts verify the existence of specific columns in the requests table that are critical for attachments and feedback features. The tools identified a previous lack of archivos, feedback, and rating columns, leading to the implementation of migration scripts.
| Field | Type | Description |
|---|---|---|
archivos | TEXT[] | Array of public URLs for attachments |
feedback | TEXT | User comments on resolution |
rating | INTEGER | Rating from 1-5 stars |
Sources: REPORTE_FINAL_VALIDACION.md:25-50, REPORTE_PRUEBAS_REQUESTS_CRUD.md:55-75
Chat System Schema
The validation process for the Chat module specifically checks for WhatsApp-like features by verifying extended columns in the messages table.
Validation identifies missing columns required for replies, audio duration, and read receipts.
Sources: REPORTE_CHAT_MODULE.md:165-185, INSTRUCCIONES_CHAT_SQL.md:15-30
Storage and RLS Validation
The test-storage-crud.js script and associated reports validate the request-files bucket and its security policies.
Storage CRUD Operations
Validation covers the full lifecycle of files within the Supabase Storage system:
- CREATE: Uploading text, CSV, and image files (5MB limit).
- READ: Listing files and generating public URLs.
- UPDATE: Modifying existing files.
- DELETE: Removing individual or batch files.
Sources: REPORTE_PRUEBAS_CRUD.md:20-40, RESUMEN_FINAL.md:65-85
RLS Policy Verification
The tools verify four critical Row Level Security policies to ensure data privacy:
- SELECT: Public read access for the
request-filesbucket. - INSERT: Authenticated users can only upload files they own (
auth.uid() = owner_id). - UPDATE/DELETE: Only the file owner can modify or remove their content.
Sources: RESUMEN_FINAL.md:95-115, REPORTE_FINAL_VALIDACION.md:120-130
Automated Execution and Reports
Validation is executed via a series of Node.js scripts that output ANSI-colored logs and Markdown reports.
Execution Sequence
The standard testing sequence for the backend components is as follows:
Key Validation Scripts
scripts/validate-demo-data.js: Verifies demo environment integrity.scripts/test-all-modules.js: Executes 120+ test cases across all backend modules.scripts/check-requests-schema.js: Validates the physical structure of the requests table.scripts/test-storage-crud.js: Specifically targets the Storage API.
Sources: REPORTE-EJECUCION-PRUEBAS.md:5-15, REPORTE_FINAL_VALIDACION.md:135-150
Conclusion
The Data Validation Tools provide a robust framework for maintaining ELMEC Mobile App v2's high standards. By combining schema verification, automated CRUD testing, and RLS policy validation, the system ensures that the backend is production-ready. While frontend UI testing remains a manual or future E2E task, the backend validation suite provides a 100% success rate for critical operations.
Sources: VALIDACION-COMPLETA.md:165-180, REPORTE_FINAL_VALIDACION.md:230-245