Skip to content

feat: alertas inteligentes, dashboard predictivo y cobertura de tests - #47

Merged
edwar merged 2 commits into
mainfrom
feat/alertas-predictivas-tests
Jun 29, 2026
Merged

feat: alertas inteligentes, dashboard predictivo y cobertura de tests#47
edwar merged 2 commits into
mainfrom
feat/alertas-predictivas-tests

Conversation

@edwar

@edwar edwar commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Cambios realizados

1. Alertas Inteligentes

  • Nuevo modelo Alert en Prisma con persistencia (read/dismissed states)
  • generateAlerts() con 6 tipos: stock_low, stock_critical, expense_high, low_margin, sales_drop, no_sales_today
  • Endpoint PATCH /api/alerts para marcar leída/descartar
  • Cron endpoint /api/cron/alerts (cada 6h vía Vercel Cron)
  • UI actualizada con botones "✓ Marcar leída" y "✕ Descartar"
  • Requiere agregar CRON_SECRET como env var en Vercel

2. Dashboard Predictivo

  • lib/predictions.ts — regresión lineal + media móvil ponderada para forecast de ventas
  • PredictionsCard — tendencia (↑/↓/→), proyección a 7 y 30 días, barra de confianza
  • Gráfico de ventas actualizado con línea punteada de predicción

3. Cobertura de Tests

  • conversions.test.ts — 13 tests (unidades, conversiones, display)
  • shopping-cart.test.ts — 16 tests (carrito completo con mock localStorage)
  • offline-sync.test.ts — 8 tests (IndexedDB con fake-indexeddb)
  • predictions.test.ts — 8 tests (tendencias, confianza, edge cases)
  • Vitest configurado con jsdom, coverage v8 y umbral 70%
  • Nuevo script: pnpm test:coverage

Total: 81 tests ✅ — Build ✅ — TypeScript ✅

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

Hobby accounts are limited to daily cron jobs. This cron expression (0 */6 * * *) would run more than once per day. Upgrade to the Pro plan to unlock all Cron Jobs features on Vercel.

Learn More: https://vercel.link/3Fpeeb1

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
loki Ready Ready Preview, Comment Jun 29, 2026 9:34pm

@edwar
edwar merged commit 14065b1 into main Jun 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant