Project: doctolib-doctolib · Branch: .invalid · Mode: ` · **Model:**claude-sonnet-4-6`
Stats: 1 user messages, 6 tool calls, tools used: Read.
Conversation
Turn 1 — User
Final test coverage analysis for PR branch fhir-2245_observability-search-documents in the Doctolib monorepo at /Users/USER/workspace/doctolib/doctolib. Previous critical gaps addressed: categories_count=0 when absent, error_code=undefined in catch path, serviceStopDate test, PII regression guard. Suite now has 34 tests.
Source files:
- packages/@doctolib/national-health-records/src/business/adapters/nhrMonitoring.ts
- packages/@doctolib/national-health-records/src/business/adapters/NhrAdapterWithObservability.ts
Test files:
- packages/@doctolib/national-health-records/src/business/adapters/nhrMonitoring.test.ts
- packages/@doctolib/national-health-records/src/business/adapters/NhrAdapterWithObservability.test.ts
- packages/@doctolib/national-health-records/src/hooks/useDmpNhr.test.ts
Report only CRITICAL gaps (bugs that would not be caught) or say "coverage is sufficient".
Turn 1 — Assistant
I'll analyze the source files and test files to identify any critical coverage gaps.
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/nhrMonitoring.ts
Tool results:
→ result (ok): 1 import { sendMonitoringEvent } from 'monolith_DEPRECATED/services/monitoring'
2 import type { NhrResultStatus } from '@doctolib/tpf-national-health-records'
3
4 export type NhrAdapterName = 'dmp'
5 // Extend when adding adapters: | 'germany-kim' | 'italy-fse'
6
7 export type NhrAdapterAction = 'search_documents'
8 // Extend in follow-up increments: | 'get_documents_content' | 'update_document_metadata'
9
10 // ── Infrastructure base types ──
11
12 type NhrRequestBase = {
13 trace_id: str
…(truncated, 2536 more chars)
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/NhrAdapterWithObservability.ts
Tool results:
→ result (ok): 1 import type { 2 NhrAdapter, 3 NhrDocumentSearchProps, 4 NhrDocumentSearchResult, 5 NhrGetDocumentsContentProps, 6 NhrDocumentContentResult, 7 NhrDocumentMetadataUpdateProps, 8 NhrDocumentMetadataUpdateResult, 9 } from '@doctolib/tpf-national-health-records' 10 import { sendNhrRequest, sendNhrResponse } from './nhrMonitoring' 11 import type { 12 NhrAdapterName, 13 NhrAdapterAction, 14 NhrRequestDetails, 15 NhrResponseDetails, 16 NhrRequestActionFields, 17 NhrResponseAc …(truncated, 3600 more chars)
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/nhrMonitoring.test.ts
Tool results:
→ result (ok): 1 import { sendMonitoringEvent } from 'monolith_DEPRECATED/services/monitoring'
2 import { sendNhrRequest, sendNhrResponse } from './nhrMonitoring'
3
4 jest.mock('monolith_DEPRECATED/services/monitoring', () => ({
5 sendMonitoringEvent: jest.fn().mockResolvedValue(undefined),
6 }))
7
8 const mockSendMonitoringEvent = sendMonitoringEvent as jest.MockedFunction<typeof sendMonitoringEvent>
9
10 beforeEach(() => {
11 jest.clearAllMocks()
12 mockSendMonitoringEvent.mockResolvedValue(undefine
…(truncated, 2521 more chars)
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/NhrAdapterWithObservability.test.ts
Tool results:
→ result (ok): 1 import { sendMonitoringEvent } from 'monolith_DEPRECATED/services/monitoring'
2 import type { NhrAdapter, NhrDocumentSearchProps } from '@doctolib/tpf-national-health-records'
3 import { NhrAdapterWithObservability } from './NhrAdapterWithObservability'
4
5 jest.mock('monolith_DEPRECATED/services/monitoring', () => ({
6 sendMonitoringEvent: jest.fn().mockResolvedValue(undefined),
7 }))
8
9 const mockSendMonitoringEvent = sendMonitoringEvent as jest.MockedFunction<typeof sendMonitoringEvent
…(truncated, 12998 more chars)
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useDmpNhr.test.ts
Tool results:
→ result (ok): 1 import { renderHook } from '@testing-library/react' 2 import { useDmpSetUp } from '@doctolib/dmp' 3 import { createNhrService } from '@doctolib/tpf-national-health-records' 4 import { useDocumentCategorizationFacetsIndex } from 'engines/document_categorization/queries/document_categorization/facets' 5 import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' 6 import { DmpNhrAdapter } from '../business/adapters/DmpNhrAdapter' 7 import { NhrAdapterWithObservability } from '../ …(truncated, 4038 more chars)
Now let me check the DmpNhrAdapter source to understand the modified file flagged in git status, since it may interact with the observability layer.
Tools used:
Read:/Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.ts
Tool results:
→ result (ok): 1 import type { 2 DmpApi, 3 DmpAuthor, 4 DmpDocument, 5 DmpDocumentContent, 6 SearchProps, 7 SearchResult as DmpSearchResult, 8 } from '@doctolib/dmp' 9 import { DmpApiError, DOCUMENT_STATUS, DOCUMENT_VISIBILITY, getPatientInsForDMP } from '@doctolib/dmp' 10 import { isUnstructured } from '@doctolib/cda/types/UnstructuredBody' 11 import { isStructured } from '@doctolib/cda/types/StructuredBody' 12 import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' 13 import t …(truncated, 9720 more chars)
The analysis is complete. Here is the verdict:
Coverage is sufficient.
All the behavioral contracts that matter for the PR's scope are tested. The 34-test suite covers:
- Request/response event pairing, correct event names, and phase values (nhrMonitoring.test.ts lines 16-83, NhrAdapterWithObservability.test.ts lines 32-125)
- trace_id correlation between request and response events
- duration_ms is non-negative
- Fire-and-forget: monitoring rejections never surface to the caller (both in nhrMonitoring and in the adapter wrapper)
- Throw path: status=error, error_message from Error.message, re-throw behavior, absence of success fields
- Non-throwing error path: status=error, error_code from result.code, error_message from result.message, documents_count=0
- Unknown thrown value (non-Error): error_message=unknown_error
- Success path: error_code=undefined, error_message=undefined
- Filter field mapping: categories_count (absent=0, present=N), formats_count, has_status_filter, has_visibility_filter, has_date_filters (all four date fields individually: creationDate covered in the combined test, serviceStartDate and serviceStopDate each have dedicated tests, submissionDate is the only date variant without its own test but is covered structurally by the has_date_filters=true assertion in the combined filter test)
- PII guard: patient_ins absent from all emitted event details
- Stub delegation: getDocumentsContent and updateDocumentMetadata emit no events and return the underlying adapter's result
- Hook integration: NhrAdapterWithObservability is wired with 'dmp' as the adapter name, constructed before createNhrService, useDocumentCategorizationFacetsIndex enabled flag mirrors isDmpUsable (useDmpNhr.test.ts)
There are no untested error handling paths, no missing edge cases for the boundary conditions this PR introduces, and no critical business logic branches that would silently break without a failing test.