import { describe, expect, it } from 'vitest'; import { renderPdf } from '@/lib/pdf/render'; import { ActivityReportPdf } from '@/lib/pdf/templates/reports/activity-report'; import { OccupancyReportPdf } from '@/lib/pdf/templates/reports/occupancy-report'; import { PipelineReportPdf } from '@/lib/pdf/templates/reports/pipeline-report'; import { RevenueReportPdf } from '@/lib/pdf/templates/reports/revenue-report'; const PORT_NAME = 'Port Test'; describe('report templates render', () => { it('activity report renders with logs + summary', async () => { const bytes = await renderPdf( ({ id: `id-${i}`, action: i % 3 === 0 ? 'create' : i % 3 === 1 ? 'update' : 'delete', entityType: i % 2 === 0 ? 'client' : 'berth', entityId: `e-${i}`, userId: `user-${i % 3}`, createdAt: new Date(2026, 4, (i % 28) + 1), })), summary: { create: 10, update: 10, delete: 10 }, generatedAt: new Date().toISOString(), }} />, ); expect(bytes.subarray(0, 5).toString('utf8')).toBe('%PDF-'); expect(bytes.length).toBeGreaterThan(2000); }, 30_000); it('revenue report renders with multi-stage breakdown', async () => { const bytes = await renderPdf( , ); expect(bytes.subarray(0, 5).toString('utf8')).toBe('%PDF-'); }, 30_000); it('pipeline report renders funnel + top interests', async () => { const bytes = await renderPdf( ({ id: `i-${i}`, clientId: `client-${i.toString().padStart(8, '0')}`, pipelineStage: 'eoi_sent', berthPrice: String(50000 + i * 5000), })), generatedAt: new Date().toISOString(), }} />, ); expect(bytes.subarray(0, 5).toString('utf8')).toBe('%PDF-'); }, 30_000); it('occupancy report renders pie + status table', async () => { const bytes = await renderPdf( , ); expect(bytes.subarray(0, 5).toString('utf8')).toBe('%PDF-'); }, 30_000); it('all reports gracefully handle empty data', async () => { const empty = await renderPdf( , ); expect(empty.length).toBeGreaterThan(500); }, 30_000); });