refactor: remove unused attendee detail components and provider
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, mock, vi } from 'bun:test';
|
||||
import { RECENT_ATTENDANCE_LIMIT } from '@gruperly/shared';
|
||||
import { Hono } from 'hono';
|
||||
|
||||
mock.module('@/lib/prisma', () => ({
|
||||
@@ -18,7 +19,7 @@ import { attendeesRoutes } from '@/modules/attendees';
|
||||
const app = new Hono();
|
||||
app.route('/attendees', attendeesRoutes);
|
||||
|
||||
const attendee = {
|
||||
const attendeeRow = {
|
||||
id: 'attendee-1',
|
||||
groupId: 'group-1',
|
||||
fullName: 'Ana Pérez',
|
||||
@@ -32,6 +33,13 @@ const attendee = {
|
||||
updatedAt: new Date('2026-08-01T10:00:00.000Z'),
|
||||
};
|
||||
|
||||
// Lo que devuelve el mock de Prisma: la fila más las relaciones del resumen.
|
||||
const attendee = {
|
||||
...attendeeRow,
|
||||
attendances: [{ status: 'ABSENT' }, { status: 'PRESENT' }, { status: 'PRESENT' }],
|
||||
payments: [{ status: 'OVERDUE', dueDate: new Date('2026-09-10T00:00:00.000Z') }],
|
||||
};
|
||||
|
||||
describe('attendees routes', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
@@ -47,9 +55,13 @@ describe('attendees routes', () => {
|
||||
expect(await res.json()).toEqual({
|
||||
data: [
|
||||
{
|
||||
...attendee,
|
||||
createdAt: attendee.createdAt.toISOString(),
|
||||
updatedAt: attendee.updatedAt.toISOString(),
|
||||
...attendeeRow,
|
||||
createdAt: attendeeRow.createdAt.toISOString(),
|
||||
updatedAt: attendeeRow.updatedAt.toISOString(),
|
||||
// La consulta viene de más reciente a más antigua; la fila los
|
||||
// muestra al revés, con la clase más reciente a la derecha.
|
||||
recentAttendance: ['PRESENT', 'PRESENT', 'ABSENT'],
|
||||
payment: { status: 'OVERDUE', dueDate: '2026-09-10T00:00:00.000Z' },
|
||||
},
|
||||
],
|
||||
pagination: { page: 2, pageSize: 10, total: 21, totalPages: 3 },
|
||||
@@ -58,6 +70,19 @@ describe('attendees routes', () => {
|
||||
skip: 10,
|
||||
take: 10,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
attendances: {
|
||||
orderBy: { classSession: { startsAt: 'desc' } },
|
||||
take: RECENT_ATTENDANCE_LIMIT,
|
||||
select: { status: true },
|
||||
},
|
||||
payments: {
|
||||
where: { status: { not: 'CANCELLED' } },
|
||||
orderBy: { dueDate: 'desc' },
|
||||
take: 3,
|
||||
select: { status: true, dueDate: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(prisma.attendee.count).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user