From 6b9b9a3f8d89a09e271bd70b662357e6424897be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 25 Oct 2026 16:24:15 +0100 Subject: [PATCH] test(documents): type the index fixtures instead of casting them away The resource-limit cases and two older mocks now pass typed values, so the file carries fewer as-never casts than before; the outcome list's comment is a line shorter to keep its file at its length. Both ratchet baselines are written down, the source size one also for offhost-backup.ts, which had shrunk without its number following. --- src/__tests__/baselines/source-file-lines.json | 4 ++-- src/__tests__/baselines/test-as-never.json | 4 ++-- src/lib/documents/__tests__/index-document.test.ts | 12 +++++++----- src/lib/validations/inbound-documents.ts | 5 ++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/__tests__/baselines/source-file-lines.json b/src/__tests__/baselines/source-file-lines.json index 4d873805a..a34432d80 100644 --- a/src/__tests__/baselines/source-file-lines.json +++ b/src/__tests__/baselines/source-file-lines.json @@ -1,7 +1,7 @@ { "$comment": "Production files over 800 lines and their length. Maintained by src/__tests__/source-size-ratchet.test.ts.", "count": 84, - "total": 94948, + "total": 94928, "entries": { "app/medications/page-client.tsx": 839, "components/charts/mood-chart.tsx": 1166, @@ -66,7 +66,7 @@ "lib/jobs/coach-nudge.ts": 1084, "lib/jobs/insight-pregenerate.ts": 1189, "lib/jobs/medication-intake-import.ts": 819, - "lib/jobs/offhost-backup.ts": 1114, + "lib/jobs/offhost-backup.ts": 1094, "lib/jobs/reaction-line.ts": 803, "lib/managed-profiles/handover.ts": 986, "lib/mcp/record-search.ts": 1467, diff --git a/src/__tests__/baselines/test-as-never.json b/src/__tests__/baselines/test-as-never.json index 64018c1a6..330b6293f 100644 --- a/src/__tests__/baselines/test-as-never.json +++ b/src/__tests__/baselines/test-as-never.json @@ -1,7 +1,7 @@ { "$comment": "as never casts in tests, per test file under src/. Maintained by src/__tests__/test-realism-ratchet.test.ts.", "count": 524, - "total": 5489, + "total": 5488, "entries": { "__tests__/api/auth/login/mfa-branch.test.ts": 10, "__tests__/api/auth/mfa/verify.test.ts": 9, @@ -361,7 +361,7 @@ "lib/documents/__tests__/assist-kinds.test.ts": 1, "lib/documents/__tests__/commit.test.ts": 9, "lib/documents/__tests__/fenced-chat-pipeline.test.ts": 6, - "lib/documents/__tests__/index-document.test.ts": 23, + "lib/documents/__tests__/index-document.test.ts": 22, "lib/documents/__tests__/index-outcome-record.test.ts": 14, "lib/documents/__tests__/prepare-vision-raster-failure.test.ts": 6, "lib/documents/__tests__/provider-order.test.ts": 1, diff --git a/src/lib/documents/__tests__/index-document.test.ts b/src/lib/documents/__tests__/index-document.test.ts index 80a72e17a..75d69bdb7 100644 --- a/src/lib/documents/__tests__/index-document.test.ts +++ b/src/lib/documents/__tests__/index-document.test.ts @@ -115,7 +115,7 @@ beforeEach(() => { ok: true, text: "glucose fasting creatinine values report", source: "local-pdf", - } as never); + }); // Default: the auto-read toggle is ON (so the external-pick provider path is // exercised); the OFF-specific tests override this explicitly. vi.mocked(documentAutoReadEnabled).mockResolvedValue(true); @@ -284,7 +284,7 @@ describe("indexDocumentContent — local fallback path", () => { vi.mocked(localExtractText).mockResolvedValue({ ok: false, reason: "empty", - } as never); + }); const outcome = await indexDocumentContent("user-1", "doc-1"); expect(outcome).toEqual({ indexed: false, reason: "local-empty" }); @@ -295,7 +295,9 @@ describe("indexDocumentContent — local fallback path", () => { vi.mocked(resolveDocumentVisionProvider).mockResolvedValue({ chain: [], pick: null, - } as never); + localOcrEnabled: false, + withheld: null, + }); vi.mocked(localExtractText).mockResolvedValue({ ok: false, reason: "resource-limit", @@ -308,10 +310,10 @@ describe("indexDocumentContent — local fallback path", () => { it("keeps resource-limit over a provider note: the provider never got further either", async () => { vi.mocked(resolveDocumentVisionProvider).mockResolvedValue(PICK as never); - vi.mocked(prepareVisionInput).mockReturnValue({ + vi.mocked(prepareVisionInput).mockResolvedValue({ ok: false, reason: "rasterFailed", - } as never); + }); vi.mocked(localExtractText).mockResolvedValue({ ok: false, reason: "resource-limit", diff --git a/src/lib/validations/inbound-documents.ts b/src/lib/validations/inbound-documents.ts index a83a786d1..83b008c37 100644 --- a/src/lib/validations/inbound-documents.ts +++ b/src/lib/validations/inbound-documents.ts @@ -107,9 +107,8 @@ export type DocumentSummaryStateValue = /** * Refs #776 — why a document's most recent content-index attempt produced no * index. Mirrors the free-String `lastIndexOutcome` column (closed here, not - * in the schema, so a new reason needs no migration); the detail view renders - * a plain-words line per value instead of a bare "not indexed" that cannot - * tell "never tried" from "tried and failed". + * in the schema, so a new reason needs no migration); the detail view says + * each in plain words, so "never tried" and "tried and failed" differ. */ export const DOCUMENT_INDEX_OUTCOMES = [ "local-empty",