trading-platform/orchestration/tareas/_archive/2026-01/TASK-2026-01-27-E2E-VIDEO-UPLOAD/README.md
Adrian Flores Cortes df43dd90cb [F0-F2] feat: Coherence analysis baseline + entity types + frontend stores
FASE 0 - Preparación y Purga:
- Archived 21 completed tasks to _archive/2026-01/
- Marked 4 docs as DEPRECATED
- Created 3 baseline coherence reports

FASE 1 - DDL-Backend Coherence:
- audit.types.ts: +4 types (SystemEvent, TradingAudit, ApiRequestLog, DataAccessLog)
- investment.types.ts: +4 types (RiskQuestionnaire, WithdrawalRequest, DailyPerformance, DistributionHistory)
- entity.types.ts: +5 types (Symbol, TradingBot, TradingSignal, TradingMetrics, PaperBalance)

FASE 2 - Backend-Frontend Coherence:
- investmentStore.ts: New Zustand store with 20+ actions
- mlStore.ts: New Zustand store with signal caching
- alerts.service.ts: New service with 15 functions

FASE 3 - Documentation:
- OQI-009: Updated to 100% coverage, added ET-MKT-004-productos.md
- OQI-010: Created full structure (STATUS.md, ROADMAP-MT4.md, ET-MT4-001-gateway.md)

Coherence Baseline Established:
- DDL-Backend: 31% (target 95%)
- Backend-Frontend: 72% (target 85%)
- Global: 39.6% (target 90%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:08:04 -06:00

7.2 KiB

E2E Tests: Video Upload Module

Fecha: 2026-01-27 Estado: Completado (100%) Total Estimado: 14h


Progreso

Suite Tests Estado Horas
Suite 1: Form Tests 27 Completado 3h
Suite 2: Service Tests 20 Completado 2h
Suite 3: Integration E2E 15 Completado 3h
Suite 4: Controller Tests 22 Completado 2h
Suite 5: Service Tests 29 Completado 2h
Suite 6: Storage Tests 35 Completado 1.5h
Suite 7: Full E2E Flow 5 Completado 0.5h
Total 153/153 100% 14h/14h

Suite 1: Frontend Form Tests

Ubicación: apps/frontend/src/__tests__/e2e/video-upload-form.test.tsx Tests: 27 Cobertura: VideoUploadForm component (3-step wizard)

Step 1: File Selection (9 tests)

  • Render upload area with drag & drop
  • Accept valid formats (mp4, webm)
  • Reject invalid formats (avi)
  • Reject oversized files (> max size)
  • Support drag and drop
  • Extract video duration
  • CRITICAL: NO video blob in state

Step 2: Metadata Entry (8 tests)

  • Title validation (required, max 100 chars)
  • Description validation (required, max 5000 chars)
  • Tag management (max 10 tags)
  • Thumbnail upload (optional)
  • Reject non-image thumbnails

Step 3: Upload Flow (10 tests)

  • Progress tracking (0% → 100%)
  • Status messages
  • Callback invocation
  • Error handling
  • Retry mechanism
  • Form disabled during upload

Suite 2: Service Tests

Ubicación: apps/frontend/src/__tests__/e2e/video-upload-service.test.ts Tests: 20 Cobertura: video-upload.service.ts (multipart upload logic)

File Chunking (3 tests)

  • Split into 5MB parts
  • Handle small files (< 5MB)
  • Handle large files (100MB = 20 parts)

Concurrent Uploads (2 tests)

  • Max 3 parts simultaneously
  • Process in batches of 3

Progress Tracking (3 tests)

  • Report 0% → 100%
  • Status messages
  • Callback parameters

ETag Extraction (5 tests)

  • Extract from headers
  • Remove quotes
  • Error if missing
  • Collect for all parts

Error Handling (3 tests)

  • Failed part upload
  • Network failures
  • Partial failures

Integration (1 test)

  • Full flow: init → upload → complete

Suite 3: Integration E2E

Ubicación: apps/frontend/src/__tests__/e2e/video-upload-integration.test.tsx Tests: 15 Cobertura: Full integration flow with mocked API

Happy Path (3 tests)

  • Complete upload: select → metadata → upload → callback
  • Multiple file uploads
  • Progress tracking throughout

Error Handling (6 tests)

  • Network failure during init
  • Part upload failure with retry
  • Completion failure recovery
  • Invalid API responses

User Actions (6 tests)

  • Cancel upload mid-process
  • Form validation errors
  • Navigation during upload

Suite 4: Backend Controller Tests

Ubicación: apps/backend/src/__tests__/integration/video-controller.test.ts Tests: 22 Cobertura: REST API endpoints

Upload Initialization (6 tests)

  • Valid payload success
  • Missing fields rejection
  • File size validation (max 2GB)
  • Content type validation
  • All valid formats accepted

Upload Completion (5 tests)

  • Complete with valid parts
  • Ownership validation
  • Status validation
  • Parts array validation

Other Endpoints (11 tests)

  • Abort upload
  • Get video by ID
  • Get course/lesson videos
  • Update metadata
  • Delete video
  • Update processing status

Suite 5: Backend Service Tests

Ubicación: apps/backend/src/__tests__/integration/video-service.test.ts Tests: 29 Cobertura: Business logic layer

Initialize Upload (5 tests)

  • Create DB record + storage init
  • Calculate parts correctly
  • Access validation
  • Error handling

Complete Upload (4 tests)

  • Ownership validation
  • Status validation
  • Storage completion
  • Error status update

CRUD Operations (12 tests)

  • Get video by ID
  • Get by course/lesson
  • Update metadata
  • Soft delete

Other Operations (8 tests)

  • Abort upload
  • Processing status updates
  • Access control

Suite 6: Storage Service Tests

Ubicación: apps/backend/src/__tests__/integration/storage-service.test.ts Tests: 35 Cobertura: S3/R2 integration

Multipart Upload (6 tests)

  • Initialize upload
  • Upload parts
  • Complete upload
  • Abort upload
  • Error handling

Presigned URLs (4 tests)

  • Upload URLs
  • Download URLs
  • Expiration settings
  • Error handling

Object Operations (10 tests)

  • Simple upload
  • Get object
  • Delete object
  • Copy object
  • Get metadata
  • List objects

URL Generation (4 tests)

  • CDN URLs
  • R2 URLs
  • S3 URLs
  • URL priority

Helpers (3 tests)

  • Generate unique keys
  • Sanitize filenames
  • Preserve extensions

Error Handling (8 tests)

  • S3 errors
  • Network errors
  • Unknown errors

Suite 7: Full E2E Flow

Ubicación: apps/backend/src/__tests__/e2e/video-upload-flow.test.ts Tests: 5 Cobertura: Complete pipeline validation

Happy Path (1 test)

  • Init → Upload → Complete (full lifecycle)

Error Paths (2 tests)

  • Abort upload with cleanup
  • Storage completion failure

Access Control (2 tests)

  • Course access validation
  • Ownership validation

Archivos Creados

apps/frontend/src/__tests__/e2e/
├── video-upload-form.test.tsx         (27 tests) ✅
├── video-upload-service.test.ts       (20 tests) ✅
└── video-upload-integration.test.tsx  (15 tests) ✅

apps/backend/src/__tests__/integration/
├── video-controller.test.ts           (22 tests) ✅
├── video-service.test.ts              (29 tests) ✅
└── storage-service.test.ts            (35 tests) ✅

apps/backend/src/__tests__/e2e/
└── video-upload-flow.test.ts          (5 tests) ✅

Total: 153 tests, ~2500 líneas de código


Comandos de Testing

Frontend:

cd apps/frontend
npm run test video-upload-form.test.tsx
npm run test video-upload-service.test.ts
npm run test -- --coverage

Backend (cuando estén listos):

cd apps/backend
npm run test video
npm run test -- --coverage

Cobertura Esperada

Componente Líneas Coverage
VideoUploadForm.tsx 670 > 80%
video-upload.service.ts 295 > 90%
video.controller.ts 353 > 80%
video.service.ts 536 > 85%
storage.service.ts 452 > 75%

Total: > 80% coverage en módulo de video upload


Próximos Pasos

  1. Suite 1 completada
  2. Suite 2 completada
  3. Suite 3 completada
  4. Suite 4 completada
  5. Suite 5 completada
  6. Suite 6 completada
  7. Suite 7 completada
  8. Ejecutar todos los tests
  9. Verificar coverage > 80%
  10. Commit y push

Status: Tests completados (100%) - Pendiente: Ejecución y validación