From d2707ac3df8d42736aa9ae12aacb6d8e858e8f93 Mon Sep 17 00:00:00 2001 From: weeihan Date: Wed, 30 Sep 2026 14:53:10 +0800 Subject: [PATCH] fix: resolve TypeScript test type errors in report-pdf and bulk-import tests - Updated mockSession to include required SessionPayload fields (siteId, name) - Added optional chaining for metadata.location to handle null/undefined cases - Tests now pass without validation errors Deployed to production 2026-09-30. App running with local postgres migration complete. Co-Authored-By: Claude Haiku 4.5 Claude-Session: https://claude.ai/code/session_015e81pY6swiKHQZDcN86CTD --- lib/incidents/bulk-import.test.ts | 2 +- tests/app/api/incidents/report-pdf.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/incidents/bulk-import.test.ts b/lib/incidents/bulk-import.test.ts index bcb1b22..0554b1d 100644 --- a/lib/incidents/bulk-import.test.ts +++ b/lib/incidents/bulk-import.test.ts @@ -45,7 +45,7 @@ describe('analyzePdfsWithDeepSeek', () => { const metadata = await analyzePdfsWithDeepSeek(pdfTexts) expect(metadata.description).toBeDefined() expect(metadata.date).toBeDefined() - expect(metadata.location.site).toBeDefined() + expect(metadata.location?.site).toBeDefined() }) }) diff --git a/tests/app/api/incidents/report-pdf.test.ts b/tests/app/api/incidents/report-pdf.test.ts index 6fb182c..f05ccc2 100644 --- a/tests/app/api/incidents/report-pdf.test.ts +++ b/tests/app/api/incidents/report-pdf.test.ts @@ -21,7 +21,7 @@ import { withUser } from '@/lib/db/with-user' import { buildIncidentReportPdf } from '@/lib/pdf/incident-report' import { NextRequest } from 'next/server' -const mockSession = { sub: 'user-1', role: 'hse' as const } +const mockSession = { sub: 'user-1', role: 'hse' as const, siteId: 'site-1', name: 'Test User' } const MOCK_INCIDENT = { id: 'inc-1',