Discovered while addressing #71 (Telemetry coverage expansion: backend Functions). After #71 shipped, the __setTelemetryClientForTesting / __resetTelemetryInitForTesting wiring per-spec is the dominant pattern in api/src/functions/blobs.test.ts (4 describe blocks) and is also installed at the file-scope beforeEach in api/src/shared/blobs.test.ts. A shared helper would consolidate the boilerplate without semantic change.
PR #403's rubber-duck panel (architect finding 1 + skeptic finding 2) explicitly recommended NOT extracting helpers ad-hoc inside #403 and folding the consolidation into this issue instead, so the next contributor designs the shape once rather than discovering it in pieces.
Acceptance criteria
References
api/src/shared/auth.test.ts:387,504 -- canonical existing pattern for the seam.
api/src/functions/blobs.test.ts:749-760, 802-813, 877-886, 935-944 -- four describe blocks now each wire the seam by hand.
AGENTS.md §4 Telemetry (Test requirement section): "The repo pattern uses __setTelemetryClientForTesting / __resetTelemetryInitForTesting (backend)..."
docs/telemetry.md Backend events Deferral notes (records this issue as the consolidation target).
Discovered while addressing #71 (Telemetry coverage expansion: backend Functions). After #71 shipped, the
__setTelemetryClientForTesting/__resetTelemetryInitForTestingwiring per-spec is the dominant pattern inapi/src/functions/blobs.test.ts(4 describe blocks) and is also installed at the file-scopebeforeEachinapi/src/shared/blobs.test.ts. A shared helper would consolidate the boilerplate without semantic change.PR #403's rubber-duck panel (architect finding 1 + skeptic finding 2) explicitly recommended NOT extracting helpers ad-hoc inside #403 and folding the consolidation into this issue instead, so the next contributor designs the shape once rather than discovering it in pieces.
Acceptance criteria
api/src/shared/__testing__/(new directory; mirrors the frontendsrc/testing/carve-out from production builds viaapi/tsconfig.jsonexcludes) exporting amakeTrackEventSpy()helper that returns{spy, install, uninstall}:install()calls__setTelemetryClientForTesting({ trackEvent: spy } as unknown as TelemetryClient)and__resetTelemetryInitForTesting().uninstall()reverses both.api/src/functions/blobs.test.tsapi/src/functions/ruleSets.test.tsapi/src/shared/auth.test.tsapi/src/shared/http.test.tsapi/src/shared/blobs.test.ts(file-scopebeforeEachinstalled by Add backend telemetry: blob.autoDeleted, blob.versionConflict, slug.collisions.exhausted (#71) #403)api/src/shared/telemetry.test.ts(already self-tests the seam; keep as-is)manyBlobsForQuotatest-data builders currently duplicated between thequota.exceededandblob.autoDeleteddescribe blocks inblobs.test.ts(Add backend telemetry: blob.autoDeleted, blob.versionConflict, slug.collisions.exhausted (#71) #403 left them duplicated intentionally, deferring to this issue).api/tsconfig.jsonexcludes__testing__/from production build inclusion (mirrors howapi/integration/is excluded).References
api/src/shared/auth.test.ts:387,504-- canonical existing pattern for the seam.api/src/functions/blobs.test.ts:749-760, 802-813, 877-886, 935-944-- four describe blocks now each wire the seam by hand.AGENTS.md§4 Telemetry (Test requirement section): "The repo pattern uses__setTelemetryClientForTesting/__resetTelemetryInitForTesting(backend)..."docs/telemetry.mdBackend events Deferral notes (records this issue as the consolidation target).