From ee3e0a7377764b094486b9271f6ad4f53b404358 Mon Sep 17 00:00:00 2001 From: Jackson Roberts Date: Mon, 9 Mar 2026 03:33:59 -0500 Subject: [PATCH] =?UTF-8?q?bypass=20checkColdStatus=20=E2=80=94=20always?= =?UTF-8?q?=20returns=20not-cold=20until=20feature=20ready?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/algorithms/algo.coldThreshold.ts | 27 +---- tests/unit/algoColdThreshold.test.ts | 111 +++---------------- tests/unit/wfOpportunity.test.ts | 36 +----- 3 files changed, 20 insertions(+), 154 deletions(-) diff --git a/src/modules/algorithms/algo.coldThreshold.ts b/src/modules/algorithms/algo.coldThreshold.ts index a26fe25..4abc01d 100644 --- a/src/modules/algorithms/algo.coldThreshold.ts +++ b/src/modules/algorithms/algo.coldThreshold.ts @@ -96,28 +96,7 @@ const STATUS_NAMES: Record = { * * @returns A `ColdCheckResult` indicating cold status and trigger metadata. */ -export function checkColdStatus(input: ColdCheckInput): ColdCheckResult { - const NOT_COLD: ColdCheckResult = { cold: false, triggeredBy: null }; - - if (!input.statusCwId) return NOT_COLD; - - const threshold = COLD_THRESHOLDS[input.statusCwId]; - if (!threshold) return NOT_COLD; - - if (!input.lastActivityDate) return NOT_COLD; - - const now = input.now ?? new Date(); - const elapsed = now.getTime() - input.lastActivityDate.getTime(); - - if (elapsed < threshold.ms) return NOT_COLD; - - return { - cold: true, - triggeredBy: { - statusCwId: input.statusCwId, - statusName: STATUS_NAMES[input.statusCwId] ?? "Unknown", - thresholdDays: threshold.days, - staleDays: Math.floor(elapsed / (24 * 60 * 60 * 1000)), - }, - }; +export function checkColdStatus(_input: ColdCheckInput): ColdCheckResult { + // Bypassed — always returns not-cold until cold-stall feature is ready + return { cold: false, triggeredBy: null }; } diff --git a/tests/unit/algoColdThreshold.test.ts b/tests/unit/algoColdThreshold.test.ts index 81c6130..815de52 100644 --- a/tests/unit/algoColdThreshold.test.ts +++ b/tests/unit/algoColdThreshold.test.ts @@ -1,7 +1,8 @@ /** * Tests for src/modules/algorithms/algo.coldThreshold.ts * - * Pure function — no mocking needed. + * checkColdStatus is currently bypassed (always returns not-cold). + * COLD_THRESHOLDS config is still tested. */ import { describe, test, expect } from "bun:test"; @@ -24,106 +25,20 @@ describe("COLD_THRESHOLDS", () => { }); }); -describe("checkColdStatus", () => { - test("returns not cold when statusCwId is null", () => { - const result = checkColdStatus({ - statusCwId: null, - lastActivityDate: new Date(), - }); - expect(result.cold).toBe(false); - expect(result.triggeredBy).toBeNull(); - }); +describe("checkColdStatus (bypassed)", () => { + test("always returns not-cold regardless of input", () => { + // With null status + expect(checkColdStatus({ statusCwId: null, lastActivityDate: new Date() })) + .toEqual({ cold: false, triggeredBy: null }); - test("returns not cold for non-eligible status", () => { - const result = checkColdStatus({ - statusCwId: 24, // New — not in threshold table - lastActivityDate: new Date("2020-01-01"), - now: new Date("2026-06-01"), - }); - expect(result.cold).toBe(false); - }); - - test("returns not cold when lastActivityDate is null", () => { - const result = checkColdStatus({ - statusCwId: 43, // QuoteSent - lastActivityDate: null, - }); - expect(result.cold).toBe(false); - }); - - test("returns not cold when within threshold (QuoteSent, 13 days)", () => { - const now = new Date("2026-03-14T00:00:00Z"); - const lastActivity = new Date("2026-03-01T00:00:00Z"); // 13 days ago - const result = checkColdStatus({ - statusCwId: 43, - lastActivityDate: lastActivity, - now, - }); - expect(result.cold).toBe(false); - }); - - test("returns cold when QuoteSent exceeds 14 days", () => { + // With eligible status and stale activity const now = new Date("2026-03-16T00:00:00Z"); const lastActivity = new Date("2026-03-01T00:00:00Z"); // 15 days ago - const result = checkColdStatus({ - statusCwId: 43, - lastActivityDate: lastActivity, - now, - }); - expect(result.cold).toBe(true); - expect(result.triggeredBy).not.toBeNull(); - expect(result.triggeredBy!.statusCwId).toBe(43); - expect(result.triggeredBy!.statusName).toBe("QuoteSent"); - expect(result.triggeredBy!.thresholdDays).toBe(14); - expect(result.triggeredBy!.staleDays).toBe(15); - }); + expect(checkColdStatus({ statusCwId: 43, lastActivityDate: lastActivity, now })) + .toEqual({ cold: false, triggeredBy: null }); - test("returns cold when ConfirmedQuote exceeds 30 days", () => { - const now = new Date("2026-04-01T00:00:00Z"); - const lastActivity = new Date("2026-02-28T00:00:00Z"); // 32 days - const result = checkColdStatus({ - statusCwId: 57, - lastActivityDate: lastActivity, - now, - }); - expect(result.cold).toBe(true); - expect(result.triggeredBy!.statusName).toBe("ConfirmedQuote"); - expect(result.triggeredBy!.thresholdDays).toBe(30); - expect(result.triggeredBy!.staleDays).toBeGreaterThanOrEqual(30); - }); - - test("returns not cold when ConfirmedQuote within 30 days", () => { - const now = new Date("2026-03-20T00:00:00Z"); - const lastActivity = new Date("2026-03-01T00:00:00Z"); // 19 days - const result = checkColdStatus({ - statusCwId: 57, - lastActivityDate: lastActivity, - now, - }); - expect(result.cold).toBe(false); - }); - - test("exactly at threshold is cold (>= threshold)", () => { - const now = new Date("2026-03-15T00:00:00Z"); - const lastActivity = new Date("2026-03-01T00:00:00Z"); // exactly 14 days - const result = checkColdStatus({ - statusCwId: 43, - lastActivityDate: lastActivity, - now, - }); - expect(result.cold).toBe(true); - expect(result.triggeredBy!.staleDays).toBe(14); - }); - - test("now override works as expected", () => { - const fixed = new Date("2026-06-01T00:00:00Z"); - const lastActivity = new Date("2026-05-01T00:00:00Z"); // 31 days - const result = checkColdStatus({ - statusCwId: 57, - lastActivityDate: lastActivity, - now: fixed, - }); - expect(result.cold).toBe(true); - expect(result.triggeredBy!.staleDays).toBe(31); + // With ConfirmedQuote exceeding threshold + expect(checkColdStatus({ statusCwId: 57, lastActivityDate: new Date("2026-02-01"), now: new Date("2026-04-01") })) + .toEqual({ cold: false, triggeredBy: null }); }); }); diff --git a/tests/unit/wfOpportunity.test.ts b/tests/unit/wfOpportunity.test.ts index 0cc5d01..2641ec9 100644 --- a/tests/unit/wfOpportunity.test.ts +++ b/tests/unit/wfOpportunity.test.ts @@ -93,38 +93,10 @@ const REAL_COLD_THRESHOLDS: Record = { 57: { days: 30, ms: 30 * 24 * 60 * 60 * 1000 }, }; -const REAL_STATUS_NAMES: Record = { - 43: "QuoteSent", - 57: "ConfirmedQuote", -}; - -/** Real checkColdStatus implementation — used as the default so that - * algoColdThreshold.test.ts gets the real function if it loads after us. */ -function realCheckColdStatus(input: { - statusCwId: number | null; - lastActivityDate: Date | null; - now?: Date; -}) { - const NOT_COLD = { cold: false as const, triggeredBy: null }; - if (!input.statusCwId) return NOT_COLD; - const threshold = REAL_COLD_THRESHOLDS[input.statusCwId]; - if (!threshold) return NOT_COLD; - if (!input.lastActivityDate) return NOT_COLD; - const now = input.now ?? new Date(); - const elapsed = now.getTime() - input.lastActivityDate.getTime(); - if (elapsed < threshold.ms) return NOT_COLD; - return { - cold: true as const, - triggeredBy: { - statusCwId: input.statusCwId, - statusName: REAL_STATUS_NAMES[input.statusCwId] ?? "Unknown", - thresholdDays: threshold.days, - staleDays: Math.floor(elapsed / (24 * 60 * 60 * 1000)), - }, - }; -} - -const mockCheckColdStatus = mock(realCheckColdStatus); +/** checkColdStatus is bypassed in source — always returns not-cold. */ +const mockCheckColdStatus = mock( + () => ({ cold: false as const, triggeredBy: null }), +); mock.module("../../src/modules/algorithms/algo.coldThreshold", () => ({ checkColdStatus: mockCheckColdStatus,