✨ Características Nuevas: - Cálculo automático de SLA en tickets basado en categoría - Auto-asignación de tickets según configuración de categoría - Auditoría completa en operaciones de categorías (create/update/delete) - Visualización de estado SLA en listado y detalle de tickets 🐛 Correcciones: - Fix actualización de status en tenants (manejo correcto de enum TenantStatus) - Corrección de campos contact_phone y contact_email en tenants - Corrección de modelo TicketResponse (agregar campos SLA y usar ConfigDict) - Eliminación de archivo changelog duplicado 🔧 Mejoras de Infraestructura: - Agregar montaje de backend en workers y beat para imports correctos - Mejorar path handling en sla_tasks.py para Docker - Scripts de testing integrados (test_frontend_integration, test_manual, test_tenant_update) - Agregar database.py en workers/app/core para sesiones async 📝 Frontend: - Actualizar UI de tenants con nuevos campos (email, teléfono, status enum) - Agregar columna de SLA en listado de tickets - Mostrar información detallada de SLA en vista de ticket individual - Indicadores visuales de estado de SLA (vencido, cumplido, en plazo)
143 lines
6.8 KiB
PowerShell
143 lines
6.8 KiB
PowerShell
# Script de Pruebas Manuales - ServiceManagerWeb
|
|
# Fecha: 2026-02-17
|
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
|
Write-Host "PRUEBAS MANUALES - ServiceManagerWeb" -ForegroundColor Cyan
|
|
Write-Host "========================================`n" -ForegroundColor Cyan
|
|
|
|
# PRUEBA 1: Login
|
|
Write-Host "PRUEBA 1: Login y obtener token..." -ForegroundColor Yellow
|
|
|
|
$loginBody = @{
|
|
email = "admin@aduanasoft.com"
|
|
password = "admin123"
|
|
tenant_slug = "aduanasoft-demo"
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$response = Invoke-RestMethod -Uri "http://localhost:8000/v1/auth/login" -Method Post -ContentType "application/json" -Body $loginBody
|
|
$token = $response.access_token
|
|
Write-Host "[OK] Token obtenido exitosamente" -ForegroundColor Green
|
|
$headers = @{ "Authorization" = "Bearer $token" }
|
|
} catch {
|
|
Write-Host "[ERROR] $($_.Exception.Message)" -ForegroundColor Red
|
|
exit
|
|
}
|
|
|
|
# PRUEBA 2: Listar categorias
|
|
Write-Host "`nPRUEBA 2: Listar categorias..." -ForegroundColor Yellow
|
|
|
|
try {
|
|
$categories = Invoke-RestMethod -Uri "http://localhost:8000/v1/categories/" -Method Get -Headers $headers
|
|
Write-Host "[OK] Categorias encontradas: $($categories.Count)" -ForegroundColor Green
|
|
$categoryId = $categories[0].id
|
|
Write-Host "Usaremos: $($categories[0].name) (ID: $categoryId)" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host "[ERROR] $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
# PRUEBA 3: Crear ticket con SLA
|
|
Write-Host "`nPRUEBA 3: Crear ticket con SLA automatico..." -ForegroundColor Yellow
|
|
|
|
$ticketBody = @{
|
|
subject = "Prueba SLA $(Get-Date -Format 'HH:mm:ss')"
|
|
description = "Ticket de prueba para verificar calculo automatico de SLA"
|
|
category_id = $categoryId
|
|
priority = "HIGH"
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$newTicket = Invoke-RestMethod -Uri "http://localhost:8000/v1/tickets/" -Method Post -ContentType "application/json" -Headers $headers -Body $ticketBody
|
|
Write-Host "[OK] Ticket creado: $($newTicket.ticket_number)" -ForegroundColor Green
|
|
$ticketId = $newTicket.id
|
|
Write-Host "ID: $ticketId" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host "[ERROR] $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
# PRUEBA 4: Verificar ticket en BD
|
|
Write-Host "`nPRUEBA 4: Verificar ticket en base de datos..." -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 2
|
|
|
|
Write-Host "Consultando BD..." -ForegroundColor Gray
|
|
docker exec servicemanager-db psql -U servicemanager -d servicemanager -c "SELECT ticket_number, created_at, sla_response_due, sla_resolution_due FROM tickets WHERE id = '$ticketId'::uuid;"
|
|
|
|
# PRUEBA 5: Verificar auditoria del ticket
|
|
Write-Host "`nPRUEBA 5: Verificar auditoria del ticket..." -ForegroundColor Yellow
|
|
|
|
Write-Host "Consultando audit logs..." -ForegroundColor Gray
|
|
docker exec servicemanager-db psql -U servicemanager -d servicemanager -c "SELECT action, resource_type, created_at FROM audit_logs WHERE resource_id = '$ticketId'::uuid;"
|
|
|
|
# PRUEBA 6: Crear categoria nueva
|
|
Write-Host "`nPRUEBA 6: Crear nueva categoria (probar auditoria)..." -ForegroundColor Yellow
|
|
|
|
$newCategoryBody = @{
|
|
name = "Prueba Auditoria $(Get-Date -Format 'HH:mm:ss')"
|
|
description = "Categoria de prueba para verificar auditoria"
|
|
sla_response_hours = 6
|
|
sla_resolution_hours = 48
|
|
is_active = $true
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$newCategory = Invoke-RestMethod -Uri "http://localhost:8000/v1/categories/" -Method Post -ContentType "application/json" -Headers $headers -Body $newCategoryBody
|
|
Write-Host "[OK] Categoria creada: $($newCategory.name)" -ForegroundColor Green
|
|
$newCategoryId = $newCategory.id
|
|
Write-Host "ID: $newCategoryId" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host "[ERROR] $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
# PRUEBA 7: Verificar auditoria de CREATE
|
|
Write-Host "`nPRUEBA 7: Verificar auditoria de categoria CREATE..." -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 2
|
|
|
|
Write-Host "Consultando audit logs..." -ForegroundColor Gray
|
|
docker exec servicemanager-db psql -U servicemanager -d servicemanager -c "SELECT action, resource_type, created_at FROM audit_logs WHERE resource_id = '$newCategoryId'::uuid AND action = 'category.create';"
|
|
|
|
# PRUEBA 8: Actualizar categoria
|
|
Write-Host "`nPRUEBA 8: Actualizar categoria (probar auditoria UPDATE)..." -ForegroundColor Yellow
|
|
|
|
$updateBody = @{
|
|
sla_response_hours = 12
|
|
sla_resolution_hours = 72
|
|
} | ConvertTo-Json
|
|
|
|
try {
|
|
$updated = Invoke-RestMethod -Uri "http://localhost:8000/v1/categories/$newCategoryId" -Method Put -ContentType "application/json" -Headers $headers -Body $updateBody
|
|
Write-Host "[OK] Categoria actualizada" -ForegroundColor Green
|
|
Write-Host "Nuevo Response: $($updated.sla_response_hours)h, Resolution: $($updated.sla_resolution_hours)h" -ForegroundColor Gray
|
|
} catch {
|
|
Write-Host "[ERROR] $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
|
|
# PRUEBA 9: Verificar auditoria de UPDATE
|
|
Write-Host "`nPRUEBA 9: Verificar auditoria de categoria UPDATE..." -ForegroundColor Yellow
|
|
Start-Sleep -Seconds 2
|
|
|
|
Write-Host "Consultando audit logs..." -ForegroundColor Gray
|
|
docker exec servicemanager-db psql -U servicemanager -d servicemanager -c "SELECT action, created_at FROM audit_logs WHERE resource_id = '$newCategoryId'::uuid AND action = 'category.update';"
|
|
|
|
# PRUEBA 10: Resumen final
|
|
Write-Host "`n========================================" -ForegroundColor Cyan
|
|
Write-Host "RESUMEN FINAL" -ForegroundColor Cyan
|
|
Write-Host "========================================`n" -ForegroundColor Cyan
|
|
|
|
$totalTickets = docker exec servicemanager-db psql -U servicemanager -d servicemanager -t -c "SELECT COUNT(*) FROM tickets;"
|
|
$ticketsWithSLA = docker exec servicemanager-db psql -U servicemanager -d servicemanager -t -c "SELECT COUNT(*) FROM tickets WHERE sla_response_due IS NOT NULL;"
|
|
$totalAudits = docker exec servicemanager-db psql -U servicemanager -d servicemanager -t -c "SELECT COUNT(*) FROM audit_logs;"
|
|
$categoryAudits = docker exec servicemanager-db psql -U servicemanager -d servicemanager -t -c "SELECT COUNT(*) FROM audit_logs WHERE action LIKE 'category.%';"
|
|
|
|
Write-Host "Tickets totales: $($totalTickets.Trim())"
|
|
Write-Host "Tickets con SLA calculado: $($ticketsWithSLA.Trim())" -ForegroundColor Green
|
|
Write-Host "Audit logs totales: $($totalAudits.Trim())"
|
|
Write-Host "Audit logs de categorias: $($categoryAudits.Trim())" -ForegroundColor Green
|
|
|
|
Write-Host "`n========================================" -ForegroundColor Green
|
|
Write-Host "VERIFICACIONES COMPLETADAS" -ForegroundColor Green
|
|
Write-Host "========================================" -ForegroundColor Green
|
|
Write-Host "[OK] Calculo automatico de SLA" -ForegroundColor Green
|
|
Write-Host "[OK] Auditoria de tickets" -ForegroundColor Green
|
|
Write-Host "[OK] Auditoria de categorias (CREATE)" -ForegroundColor Green
|
|
Write-Host "[OK] Auditoria de categorias (UPDATE)" -ForegroundColor Green
|
|
Write-Host "`nRevisa los resultados arriba para confirmar que todo funciona.`n" -ForegroundColor White
|