Files
app-padel/backend/prisma/seed-beta.ts
Ivan Alcaraz dd10891432
Some checks failed
CI/CD Pipeline / 🧪 Tests (push) Has been cancelled
CI/CD Pipeline / 🏗️ Build (push) Has been cancelled
CI/CD Pipeline / 🚀 Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / 🚀 Deploy to Production (push) Has been cancelled
CI/CD Pipeline / 🏷️ Create Release (push) Has been cancelled
CI/CD Pipeline / 🧹 Cleanup (push) Has been cancelled
FASE 7 COMPLETADA: Testing y Lanzamiento - PROYECTO FINALIZADO
Implementados 4 módulos con agent swarm:

1. TESTING FUNCIONAL (Jest)
   - Configuración Jest + ts-jest
   - Tests unitarios: auth, booking, court (55 tests)
   - Tests integración: routes (56 tests)
   - Factories y utilidades de testing
   - Coverage configurado (70% servicios)
   - Scripts: test, test:watch, test:coverage

2. TESTING DE USUARIO (Beta)
   - Sistema de beta testers
   - Feedback con categorías y severidad
   - Beta issues tracking
   - 8 testers de prueba creados
   - API completa para gestión de feedback

3. DOCUMENTACIÓN COMPLETA
   - API.md - 150+ endpoints documentados
   - SETUP.md - Guía de instalación
   - DEPLOY.md - Deploy en VPS
   - ARCHITECTURE.md - Arquitectura del sistema
   - APP_STORE.md - Material para stores
   - Postman Collection completa
   - PM2 ecosystem config
   - Nginx config con SSL

4. GO LIVE Y PRODUCCIÓN
   - Sistema de monitoreo (logs, health checks)
   - Servicio de alertas multi-canal
   - Pre-deploy check script
   - Docker + docker-compose producción
   - Backup automatizado
   - CI/CD GitHub Actions
   - Launch checklist completo

ESTADÍSTICAS FINALES:
- Fases completadas: 7/7
- Archivos creados: 250+
- Líneas de código: 60,000+
- Endpoints API: 150+
- Tests: 110+
- Documentación: 5,000+ líneas

PROYECTO COMPLETO Y LISTO PARA PRODUCCIÓN
2026-01-31 22:30:44 +00:00

270 lines
7.8 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcrypt';
const prisma = new PrismaClient();
// Contraseña por defecto para usuarios de prueba
const DEFAULT_PASSWORD = 'BetaTester123!';
// Usuarios beta de prueba
const betaTesters = [
{
email: 'beta1@padelapp.com',
firstName: 'Carlos',
lastName: 'Rodriguez',
phone: '+54 11 1234-5678',
city: 'Buenos Aires',
bio: 'Jugador avanzado, fanático del pádel desde hace 5 años',
playerLevel: 'ADVANCED',
platform: 'WEB',
},
{
email: 'beta2@padelapp.com',
firstName: 'María',
lastName: 'González',
phone: '+54 11 2345-6789',
city: 'Córdoba',
bio: 'Entusiasta del pádel, busco mejorar mi juego',
playerLevel: 'INTERMEDIATE',
platform: 'IOS',
},
{
email: 'beta3@padelapp.com',
firstName: 'Juan',
lastName: 'Pérez',
phone: '+54 11 3456-7890',
city: 'Rosario',
bio: 'Juego los fines de semana con amigos',
playerLevel: 'ELEMENTARY',
platform: 'ANDROID',
},
{
email: 'beta4@padelapp.com',
firstName: 'Ana',
lastName: 'Martínez',
phone: '+54 11 4567-8901',
city: 'Mendoza',
bio: 'Competidora amateur, me encanta la tecnología',
playerLevel: 'COMPETITION',
platform: 'WEB',
},
{
email: 'beta5@padelapp.com',
firstName: 'Diego',
lastName: 'López',
phone: '+54 11 5678-9012',
city: 'Buenos Aires',
bio: 'Ex jugador de tenis, ahora full pádel',
playerLevel: 'ADVANCED',
platform: 'IOS',
},
{
email: 'beta6@padelapp.com',
firstName: 'Lucía',
lastName: 'Fernández',
phone: '+54 11 6789-0123',
city: 'La Plata',
bio: 'Principiante pero muy dedicada',
playerLevel: 'BEGINNER',
platform: 'ANDROID',
},
{
email: 'beta7@padelapp.com',
firstName: 'Martín',
lastName: 'Silva',
phone: '+54 11 7890-1234',
city: 'Mar del Plata',
bio: 'Organizo torneos locales',
playerLevel: 'INTERMEDIATE',
platform: 'WEB',
},
{
email: 'beta8@padelapp.com',
firstName: 'Valentina',
lastName: 'Torres',
phone: '+54 11 8901-2345',
city: 'Córdoba',
bio: 'Jugadora profesional en formación',
playerLevel: 'PROFESSIONAL',
platform: 'IOS',
},
];
async function main() {
console.log('🌱 Iniciando seed de beta testers...\n');
// Hashear contraseña por defecto
const hashedPassword = await bcrypt.hash(DEFAULT_PASSWORD, 10);
for (const testerData of betaTesters) {
try {
// Crear o actualizar usuario
const user = await prisma.user.upsert({
where: { email: testerData.email },
update: {
firstName: testerData.firstName,
lastName: testerData.lastName,
phone: testerData.phone,
city: testerData.city,
bio: testerData.bio,
playerLevel: testerData.playerLevel,
isActive: true,
},
create: {
email: testerData.email,
password: hashedPassword,
firstName: testerData.firstName,
lastName: testerData.lastName,
phone: testerData.phone,
city: testerData.city,
bio: testerData.bio,
playerLevel: testerData.playerLevel,
role: 'PLAYER',
isActive: true,
isVerified: true,
},
});
// Crear o actualizar beta tester
const betaTester = await prisma.betaTester.upsert({
where: { userId: user.id },
update: {
platform: testerData.platform,
appVersion: '1.0.0-beta',
status: 'ACTIVE',
},
create: {
userId: user.id,
platform: testerData.platform,
appVersion: '1.0.0-beta',
status: 'ACTIVE',
feedbackCount: 0,
},
});
console.log(`✅ Beta tester creado/actualizado: ${testerData.firstName} ${testerData.lastName} (${testerData.email})`);
console.log(` - ID: ${user.id}`);
console.log(` - Plataforma: ${testerData.platform}`);
console.log(` - Nivel: ${testerData.playerLevel}`);
console.log('');
} catch (error) {
console.error(`❌ Error creando beta tester ${testerData.email}:`, error);
}
}
// Crear algunos feedbacks de ejemplo
console.log('📝 Creando feedbacks de ejemplo...\n');
const sampleFeedbacks = [
{
email: 'beta1@padelapp.com',
type: 'BUG',
category: 'BOOKING',
title: 'Error al reservar cancha los domingos',
description: 'Cuando intento reservar una cancha para el domingo, la aplicación me muestra un error 500. Esto solo ocurre con el día domingo.',
severity: 'HIGH',
},
{
email: 'beta2@padelapp.com',
type: 'FEATURE',
category: 'SOCIAL',
title: 'Sugerencia: chat de voz durante los partidos',
description: 'Sería genial poder tener un chat de voz integrado para comunicarme con mi compañero durante el partido sin salir de la app.',
severity: 'LOW',
},
{
email: 'beta3@padelapp.com',
type: 'IMPROVEMENT',
category: 'UI',
title: 'Mejorar contraste en modo oscuro',
description: 'En el modo oscuro, algunos textos son difíciles de leer porque el contraste es muy bajo. Sugiero usar colores más claros.',
severity: 'MEDIUM',
},
{
email: 'beta4@padelapp.com',
type: 'BUG',
category: 'PAYMENT',
title: 'El pago con MercadoPago se queda cargando',
description: 'Al intentar pagar una reserva con MercadoPago, el modal de pago se queda cargando infinitamente y nunca redirige.',
severity: 'CRITICAL',
},
{
email: 'beta5@padelapp.com',
type: 'FEATURE',
category: 'TOURNAMENT',
title: 'Sistema de estadísticas en vivo',
description: 'Me gustaría poder ver estadísticas en vivo de los torneos: puntajes actualizados, tiempos de juego, etc.',
severity: 'LOW',
},
];
for (const feedbackData of sampleFeedbacks) {
try {
const user = await prisma.user.findUnique({
where: { email: feedbackData.email },
});
if (!user) {
console.error(`❌ Usuario no encontrado: ${feedbackData.email}`);
continue;
}
// Verificar si ya existe un feedback similar
const existingFeedback = await prisma.feedback.findFirst({
where: {
userId: user.id,
title: feedbackData.title,
},
});
if (existingFeedback) {
console.log(`⚠️ Feedback ya existe: ${feedbackData.title}`);
continue;
}
const feedback = await prisma.feedback.create({
data: {
userId: user.id,
type: feedbackData.type,
category: feedbackData.category,
title: feedbackData.title,
description: feedbackData.description,
severity: feedbackData.severity,
status: 'PENDING',
},
});
// Incrementar contador de feedback del beta tester
await prisma.betaTester.update({
where: { userId: user.id },
data: {
feedbackCount: { increment: 1 },
},
});
console.log(`✅ Feedback creado: ${feedbackData.title}`);
console.log(` - Por: ${feedbackData.email}`);
console.log(` - Tipo: ${feedbackData.type} | Severidad: ${feedbackData.severity}`);
console.log('');
} catch (error) {
console.error(`❌ Error creando feedback:`, error);
}
}
console.log('\n✨ Seed de beta testers completado!');
console.log(`\n👥 Total de beta testers: ${betaTesters.length}`);
console.log(`📝 Total de feedbacks de ejemplo: ${sampleFeedbacks.length}`);
console.log(`\n🔑 Credenciales de acceso:`);
console.log(` Email: Cualquiera de los emails listados arriba`);
console.log(` Password: ${DEFAULT_PASSWORD}`);
}
main()
.catch((e) => {
console.error('Error en seed:', e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});