From 49d92234dda224763c420e04d92ec645da96cadd Mon Sep 17 00:00:00 2001 From: Matt Ciaccio Date: Sun, 3 May 2026 16:14:04 +0200 Subject: [PATCH] fix(test): align stage names with consolidated pipeline enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to 886119c (refactor(sales): consolidate pipeline stages) — the runtime enum was renamed but a few test fixtures and PDF report templates still referenced the legacy names, leaving them broken at the type level (36 tsc errors before this fix). Renames in this commit: visited -> in_communication (alerts test) / removed (PDF reports) signed_eoi_nda -> eoi_signed contract -> contract_signed (interests test) / contract_sent (factory) Affected files: pipeline-report, revenue-report, makeCreateInterestInput factory, alerts-engine, pipeline-transitions, interest-scoring. Verification: tsc clean, 858/858 vitest passing. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib/pdf/templates/reports/pipeline-report.ts | 11 +++++------ src/lib/pdf/templates/reports/revenue-report.ts | 12 +++++------- tests/helpers/factories.ts | 7 ++++--- tests/integration/alerts-engine.test.ts | 2 +- tests/integration/pipeline-transitions.test.ts | 4 ++-- tests/unit/interest-scoring.test.ts | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/lib/pdf/templates/reports/pipeline-report.ts b/src/lib/pdf/templates/reports/pipeline-report.ts index 4fc2835..2c43a34 100644 --- a/src/lib/pdf/templates/reports/pipeline-report.ts +++ b/src/lib/pdf/templates/reports/pipeline-report.ts @@ -58,10 +58,11 @@ export function buildPipelineInputs( 'open', 'details_sent', 'in_communication', - 'visited', - 'signed_eoi_nda', + 'eoi_sent', + 'eoi_signed', 'deposit_10pct', - 'contract', + 'contract_sent', + 'contract_signed', 'completed', ]; @@ -73,9 +74,7 @@ export function buildPipelineInputs( }); // Include stages not in standard order - const unknownStages = Object.keys(data.stageCounts).filter( - (s) => !stageOrder.includes(s), - ); + const unknownStages = Object.keys(data.stageCounts).filter((s) => !stageOrder.includes(s)); for (const stage of unknownStages) { summaryLines.push(`${stage}: ${data.stageCounts[stage]} interest(s)`); } diff --git a/src/lib/pdf/templates/reports/revenue-report.ts b/src/lib/pdf/templates/reports/revenue-report.ts index 0bad026..782bb1f 100644 --- a/src/lib/pdf/templates/reports/revenue-report.ts +++ b/src/lib/pdf/templates/reports/revenue-report.ts @@ -50,18 +50,16 @@ export const revenueReportTemplate: Template = { ], }; -export function buildRevenueInputs( - data: RevenueData, - portName?: string, -): Record[] { +export function buildRevenueInputs(data: RevenueData, portName?: string): Record[] { const stageOrder = [ 'open', 'details_sent', 'in_communication', - 'visited', - 'signed_eoi_nda', + 'eoi_sent', + 'eoi_signed', 'deposit_10pct', - 'contract', + 'contract_sent', + 'contract_signed', 'completed', ]; diff --git a/tests/helpers/factories.ts b/tests/helpers/factories.ts index cd5e1d6..d3366f0 100644 --- a/tests/helpers/factories.ts +++ b/tests/helpers/factories.ts @@ -635,10 +635,11 @@ export function makeCreateInterestInput(overrides?: { | 'open' | 'details_sent' | 'in_communication' - | 'visited' - | 'signed_eoi_nda' + | 'eoi_sent' + | 'eoi_signed' | 'deposit_10pct' - | 'contract' + | 'contract_sent' + | 'contract_signed' | 'completed'; }) { return { diff --git a/tests/integration/alerts-engine.test.ts b/tests/integration/alerts-engine.test.ts index e2a4401..5b764ed 100644 --- a/tests/integration/alerts-engine.test.ts +++ b/tests/integration/alerts-engine.test.ts @@ -181,7 +181,7 @@ describe('alert engine', () => { await db.insert(interests).values({ portId: port.id, clientId: client.id, - pipelineStage: 'visited', + pipelineStage: 'in_communication', leadCategory: 'hot_lead', dateLastContact: stale, updatedAt: stale, diff --git a/tests/integration/pipeline-transitions.test.ts b/tests/integration/pipeline-transitions.test.ts index 5d7b5ce..5249943 100644 --- a/tests/integration/pipeline-transitions.test.ts +++ b/tests/integration/pipeline-transitions.test.ts @@ -170,7 +170,7 @@ describe('Pipeline Transitions', () => { await import('@/lib/services/interests.service'); const meta = makeAuditMeta({ portId }); - await changeInterestStage(interestId, portId, { pipelineStage: 'signed_eoi_nda' }, meta); + await changeInterestStage(interestId, portId, { pipelineStage: 'eoi_signed' }, meta); const updated = await getInterestById(interestId, portId); expect(updated.dateEoiSigned).not.toBeNull(); @@ -181,7 +181,7 @@ describe('Pipeline Transitions', () => { await import('@/lib/services/interests.service'); const meta = makeAuditMeta({ portId }); - await changeInterestStage(interestId, portId, { pipelineStage: 'contract' }, meta); + await changeInterestStage(interestId, portId, { pipelineStage: 'contract_signed' }, meta); const updated = await getInterestById(interestId, portId); expect(updated.dateContractSigned).not.toBeNull(); diff --git a/tests/unit/interest-scoring.test.ts b/tests/unit/interest-scoring.test.ts index e3322bc..a2a65c1 100644 --- a/tests/unit/interest-scoring.test.ts +++ b/tests/unit/interest-scoring.test.ts @@ -142,7 +142,7 @@ describe('calculateInterestScore', () => { portId: 'p1', clientId: 'c1', createdAt: daysAgo(10), - pipelineStage: 'contract', + pipelineStage: 'contract_signed', eoiStatus: 'signed', contractStatus: 'signed', depositStatus: 'received',