From e3ee1480aae5f20dd75b740560bca385e9880caf Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 15 Jun 2026 13:42:03 +0000 Subject: [PATCH] dont hardcode expected file count in tests --- .../your-projects/live/propertyDocuments.test.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyDocuments.test.ts b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyDocuments.test.ts index 225ff996..55e71447 100644 --- a/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyDocuments.test.ts +++ b/src/app/portfolio/[slug]/(portfolio)/your-projects/live/propertyDocuments.test.ts @@ -5,6 +5,7 @@ import { getUnassignedInstallDocs, } from "./propertyDocuments"; import type { PropertyDocument, MeasureDocProgress } from "./types"; +import { EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES } from "./types"; function makeDoc(overrides: Partial = {}): PropertyDocument { return { @@ -75,22 +76,20 @@ describe("splitDocumentsByType", () => { describe("getMissingRetrofitTypes", () => { it("returns all mandatory types when no docs uploaded", () => { const missing = getMissingSurveyDocTypes([]); - expect(missing).toHaveLength(7); + expect(missing).toHaveLength(EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES.length); }); it("excludes types that have been uploaded", () => { const uploaded = [makeDoc({ docType: "photo_pack" })]; const missing = getMissingSurveyDocTypes(uploaded); expect(missing).not.toContain("photo_pack"); - expect(missing).toHaveLength(6); + expect(missing).toHaveLength(EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES.length - 1); }); it("returns empty array when all mandatory types uploaded", () => { - const uploaded = [ - "photo_pack", "site_note", "rd_sap_site_note", "pas_2023_ventilation", - "pas_2023_condition", "pas_significance", - "pas_2023_property", "pas_2023_occupancy", - ].map((docType, i) => makeDoc({ id: String(i), docType })); + const uploaded = EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES.map((docType, i) => + makeDoc({ id: String(i), docType }) + ); expect(getMissingSurveyDocTypes(uploaded)).toHaveLength(0); }); @@ -98,7 +97,7 @@ describe("getMissingRetrofitTypes", () => { const uploaded = [makeDoc({ docType: "ecmk_site_note" })]; const missing = getMissingSurveyDocTypes(uploaded); expect(missing).not.toContain("ecmk_site_note"); - expect(missing).toHaveLength(7); + expect(missing).toHaveLength(EXPECTED_RETROFIT_ASSESSMENT_DOC_TYPES.length); }); });