From 1b5e586a06cc9d23d6f43a8cf3a016787c1f6e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Fri, 23 Oct 2026 14:45:08 +0200 Subject: [PATCH] test(medications): strip line comments first in the intake tracking guard The guard stripped block comments before line comments, so a '/*' inside a line comment opened a block that swallowed the code after it. The delta feed's intake read sat behind such a comment and was never seen. The shared stripper handles that order; with it the feed shows up, and it is listed: it mirrors recorded rows and computes no rate. --- src/__tests__/medication-intake-tracking-guard.test.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/__tests__/medication-intake-tracking-guard.test.ts b/src/__tests__/medication-intake-tracking-guard.test.ts index 5638ee82f..cb69019e5 100644 --- a/src/__tests__/medication-intake-tracking-guard.test.ts +++ b/src/__tests__/medication-intake-tracking-guard.test.ts @@ -30,7 +30,7 @@ import { describe, it, expect } from "vitest"; import { readFileSync } from "node:fs"; import { join } from "node:path"; -import { walkSourceFiles } from "./helpers/source-files"; +import { stripComments, walkSourceFiles } from "./helpers/source-files"; const SRC = join(process.cwd(), "src"); @@ -63,6 +63,8 @@ const INTAKE_MAY_SEE_EVERY_ROW: Record = { "app/api/export/route.ts": "export of the recorded history", "lib/export/medications-backup.ts": "backup of the recorded history", "app/api/sync/state/route.ts": "sync watermarks, no rate", + "app/api/sync/changes/route.ts": + "delta feed mirroring the recorded rows to a paired client, no rate", "lib/jobs/measurement-tombstone-cleanup.ts": "tombstone purge", "lib/ai/coach/tools/availability.ts": "whether any intake history exists, and its date range", @@ -141,12 +143,6 @@ function sourceFiles(): string[] { } /** Drop line and block comments so a mention in prose never counts. */ -function stripComments(source: string): string { - return source - .replace(/\/\*[\s\S]*?\*\//g, "") - .replace(/(^|[^:])\/\/.*$/gm, "$1"); -} - function code(rel: string): string { return stripComments(readFileSync(join(SRC, rel), "utf8")); }