Session: you-are-a-senior-indexed-clarke-subagent-a84f1d2f — 2026-04-27

doctolib-doctolib · Claude · branch .invalid · claude-sonnet-4-6 · 2026-04-27 13:21 · 1 msgs · 30 tools · 16 min read · updated 10 days ago

You are analyzing test coverage for PR #241005 in the doctolib/doctolib monorepo (branch FHIR-2195).

tools: Bash, Read
← doctolib-doctolib Download .md .txt .json
Tool calls
Bash Bash: 28 calls (93.3%) 28 Read Read: 2 calls (6.7%) 2
Token usage1.3M total
Input37
Cache creation60.0K
Cache read1.3M
Output7.2K
Cache hit ratio95%· healthy

Project: doctolib-doctolib · Branch: .invalid · Mode: ` · **Model:**claude-sonnet-4-6`

Stats: 1 user messages, 30 tool calls, tools used: Bash, Read.

Conversation

Turn 1 — User

You are analyzing test coverage for PR #241005 in the doctolib/doctolib monorepo (branch FHIR-2195).

PR Summary

Wires archive/unarchive document status actions into the NHR document list UI. Key new code: - useNhrDocumentStatusActions hook — full state machine (new, 101 lines) - useInvalidateNhrDocuments hook — query cache invalidation (new, 8 lines) - NhrDocumentActionDialog component — dialog wrapper (new, 32 lines) - dmpDocumentHelpers.isActive predicate (new, 1 line) - actionsBuilder signature change

Test file added

=== packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.test.ts (191 lines) ===

import { act, renderHook } from '@testing-library/react'
import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient'
import type { NhrDocument } from '@doctolib/tpf-national-health-records'
import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui'
import { useNhrDocumentStatusActions } from './useNhrDocumentStatusActions'
import { useNationalHealthRecords } from './useNationalHealthRecords'
import { useInvalidateNhrDocuments } from './useInvalidateNhrDocuments'

const findOption = (options: DropdownActionOption[], key: string): DropdownActionOption => {
  const opt = options.find((o) => o.key === key)
  if (!opt) throw new Error(`Option "${key}" not found`)
  return opt
}

jest.mock('./useNationalHealthRecords')
jest.mock('./useInvalidateNhrDocuments')
jest.mock('monolith_DEPRECATED/services/i18n', () => ({
  __esModule: true,
  default: { t: (key: string) => key },
}))

const mockUpdateDocumentMetadata = jest.fn()
const mockInvalidate = jest.fn()

const patient = { ins: 'INS-123' } as unknown as Patient
const activeDoc = { id: 'doc-1', status: '1' } as unknown as NhrDocument
const archivedDoc = { id: 'doc-2', status: '4' } as unknown as NhrDocument

describe('useNhrDocumentStatusActions', () => {
  beforeEach(() => {
    jest.clearAllMocks()
    jest.mocked(useNationalHealthRecords).mockReturnValue({
      searchDocuments: jest.fn(),
      getDocumentsContent: jest.fn(),
      updateDocumentMetadata: mockUpdateDocumentMetadata,
    })
    jest.mocked(useInvalidateNhrDocuments).mockReturnValue(mockInvalidate)
  })

  describe('options', () => {
    it('exposes archive and unarchive options', () => { ... })
    it('archive option is only available for active documents', () => { ... })
    it('unarchive option is only available for archived documents', () => { ... })
  })

  describe('opening the dialog', () => {
    it('sets modalState when archive option is clicked', () => { ... })
    it('clears previous error when a new action is triggered', () => { ... })
  })

  describe('handleDismiss', () => {
    it('clears modalState and error', () => { ... })
  })

  describe('handleConfirm', () => {
    it('calls updateDocumentMetadata with propertyName status for archive', async () => { ... })
    it('calls updateDocumentMetadata with propertyName status for unarchive', async () => { ... })
    it('dismisses dialog and invalidates documents on success', async () => { ... })
    it('shows error and keeps dialog open on failure', async () => { ... })
    it('clears previous error before retrying', async () => { ... })
    it('does nothing when nhrOperations is null', async () => { ... })
  })
})

Source code being tested

=== useNhrDocumentStatusActions.ts ===

export const useNhrDocumentStatusActions = ({ patient }: { patient: Patient }): UseNhrDocumentStatusActionsResult => {
  const nhrOperations = useNationalHealthRecords({ patient })
  const invalidateNhrDocuments = useInvalidateNhrDocuments(patient)

  const [modalState, setModalState] = useState<ModalState | null>(null)
  const [isLoading, setIsLoading] = useState(false)
  const [error, setError] = useState<string | null>(null)

  const openModal = useCallback(
    (doc: NhrDocument, config: NhrActionModalConfig) => {
      setError(null)
      setModalState({ doc, config })

…(truncated, 1969 more chars)

Turn 1 — Assistant

I'll analyze the test coverage by examining the actual source files and tests in detail.

Tools used:

  • Bash: find /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src -type f | sort

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.test.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/DmpNhrAdapter.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/parseHl7DateToIso.test.ts /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/business/adapters/parseHl7DateToI …(truncated, 4697 more chars)

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.test.ts

Tool results:

→ result (ERROR): File does not exist. Note: your current working directory is /Users/USER/workspace/doctolib/doctolib.

Tools used:

  • Bash: find /Users/USER/workspace/doctolib/worktrees -maxdepth 3 -type d -name "FHIR-2195*" 2>/dev/null; git -C /Users/USER/workspace/doctolib/doctolib worktree list

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/doctolib 0df5cb0202e8 [fhir-2215_wire-dmp-errors-through-dmpnhradapter] /Users/USER/workspace/doctolib/doctolib/.claude/worktrees/crazy-volhard d2d21781dba4 [claude/crazy-volhard] /Users/USER/workspace/doctolib/worktrees/doctolib/fhir-2089 9c01fcf036d7 (detached HEAD) /Users/USER/workspace/doctolib/worktrees/doctolib/FHIR-2091-nhr-document-li …(truncated, 1099 more chars)

Tools used:

  • Bash: gh pr view 241005 --json headRefName,files 2>/dev/null | head -5 || echo "no gh access"

Tool results:

→ result (ok): {"files":[{"path":"config/locales/en_tmp.yml","additions":23,"deletions":0,"changeType":"MODIFIED"},{"path":"config/locales/key.yml","additions":20,"deletions":0,"changeType":"MODIFIED"},{"path":"package-lock.json","additions":402,"deletions":3140,"changeType":"MODIFIED"},{"path":"package.json","additions":1,"deletions":1,"changeType":"MODIFIED"},{"path":"packages/@doctolib/dmp/src/business/DmpApi.test.ts","additions":2,"deletions":5,"changeType":"MODIFIED"},{"path":"packages/@doctolib/dmp/src/b …(truncated, 2712 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib fetch origin FHIR-2195-monolith-add-action-config-to-handle-updating-document-status --depth=1 2>&1 | tail -3

Tool results:

→ result (ok): From https://github.com/doctolib/doctolib * branch FHIR-2195-monolith-add-action-config-to-handle-updating-document-status -> FETCH_HEAD * [new branch] FHIR-2195-monolith-add-action-config-to-handle-updating-document-status -> origin/FHIR-2195-monolith-add-action-config-to-handle-updating-document-status

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts

Tool results:

→ result (ok): import { useCallback, useMemo, useState } from 'react' import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import i18n from 'monolith_DEPRECATED/services/i18n' import { isActive, isArchived } from '../variants/dmp/mappers/dmpDocumentHelpers' import { toNhrPatientInformation } from '../business/mappers/toNhrPatientInf …(truncated, 3236 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.test.ts

Tool results:

→ result (ok): import { act, renderHook } from '@testing-library/react' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { DropdownActionOption } from '@doctolib/tpf-national-health-records-ui' import { useNhrDocumentStatusActions } from './useNhrDocumentStatusActions' import { useNationalHealthRecords } from './useNationalHealthRecords' import { useInvalidateNhrDocuments } from './useInvalidateNhrDo …(truncated, 7222 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts …

Tool results:

→ result (ok): import { useQueryClient } from '@tanstack/react-query-v5' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient'

export const useInvalidateNhrDocuments = (patient: Patient) => { const queryClient = useQueryClient() // Prefix key intentionally busts all filter variants cached for this patient return () => queryClient.invalidateQueries({ queryKey: ['dmp-documents', patient.ins] }) } import { Alert } from '@doctolib/design-system/Alert' import { Dialog } from '@doctolib/ …(truncated, 1820 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/variants/dmp/mappers/dmpDocumentHelpers.ts …

Tool results:

→ result (ok): import type { NhrDocument } from '@doctolib/tpf-national-health-records' import type { NhrVisibilityEntry } from '@doctolib/tpf-national-health-records-ui' import { DOCUMENT_STATUS, DOCUMENT_VISIBILITY } from '@doctolib/dmp'

const CLASS_CODE_SYSTEM = 'dmp:classCode' const TYPE_CODE_SYSTEM = 'dmp:typeCode' const PATIENT_CODE = '90' // EX_3.1-1040: class code for patient-authored documents

// classification.codes may contain both a classCode (JDV_J06) and a typeCode (JDV_J07/LOINC). // typeCode …(truncated, 8927 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/variants/types.ts …

Tool results:

→ result (ok): import type { ColumnConfig, FilterConfig } from '@doctolib/tpf-national-health-records-ui' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import type { NhrDocument, NhrDocumentSearchParams, NhrResultStatus } from '@doctolib/tpf-national-health-records'

interface SearchDocumentsResult { data: NhrDocument[] total?: number status: NhrResultStatus message?: string code?: string }

export type NhrDocumentListVariant = { columns: ColumnConfig[] filters: Filt …(truncated, 916 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/hooks/useSearchDocuments.ts …

Tool results:

→ result (ok): import { useQueryClient } from '@tanstack/react-query-v5' import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import { isFeatureEnabled } from '@doctolib/variation_management' import i18n from 'monolith_DEPRECATED/services/i18n' import type { NhrDocumentListVariant, MapFiltersToSearchDocumentsParams, ServerFilters } from '../variants/types' import { useNationalHealthRecords } from './useNationalHealthRecords' import { generateNhrDocuments } from '../mocks/generateNhrDocum …(truncated, 15939 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/PatientCard/PatientCard.tsx

Tool results:

→ result (ok): import PatientFileIcon from 'images/icons/patient-file-icon.svg?as-react-component' import PatientAppointmentIcon from 'images/icons/patient-appointment-icon.svg?as-react-component' import { type ComponentType, lazy, useContext, useMemo, Suspense } from 'react' import classNames from 'classnames' import AccountContext from 'monolith_DEPRECATED/contexts/doctor/AccountContext' import INSiAutomaticCallContext from '@doctolib/financial_os_api/public/contexts/INSiAutomaticCallContext' import InsiIden …(truncated, 7210 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/business/mappers/toNhrPatientInformation.ts …

Tool results:

→ result (ok): import type { NhrPatientInformation } from '@doctolib/tpf-national-health-records'

export function toNhrPatientInformation(ins: string): NhrPatientInformation { return { nationalHealthIdentifier: ins, } } export { useNationalHealthRecords, type UseNhrOperations } from './hooks/useNationalHealthRecords' export { useDmpNhr } from './hooks/useDmpNhr' export { useNhrDocumentListVariant } from './variants/useNhrDocumentListVariant' export type { DocumentSearchOptions, NhrDocumentListVariant …(truncated, 738 more chars)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib diff origin/master...FETCH_HEAD -- packages/@doctolib/national-health-records/src/business/builders/actionsBuilder.ts 2>/dev/null | head -60

Tool results:

→ result (ok): (Bash completed with no output)

Tools used:

  • Bash: git -C /Users/USER/workspace/doctolib/doctolib show FETCH_HEAD:packages/@doctolib/national-health-records/src/business/builders/actionsBuilder.ts …

Tool results:

→ result (ok): import { createMoreActionsAction as moreActionsActionFactory, createViewDocumentAction as viewDocumentActionFactory, type ActionConfig, type DropdownActionOption, } from '@doctolib/tpf-national-health-records-ui' import type { NhrDocument } from '@doctolib/tpf-national-health-records'

export type NhrActionsBuilder = { createViewDocumentAction: (onDocumentSelected: (document: NhrDocument) => Promise<void>) => NhrActionsBuilder createMoreActionsAction: (options: DropdownActionOption[] …(truncated, 510 more chars)

Tools used:

  • Bash: # Check what the actionsBuilder looked like before the PR (on master branch) …

Tool results:

→ result (ok): import { createMoreActionsAction as moreActionsActionFactory, createViewDocumentAction as viewDocumentActionFactory, type ActionConfig, } from '@doctolib/tpf-national-health-records-ui' import type { NhrDocument } from '@doctolib/tpf-national-health-records'

export type NhrActionsBuilder = { createViewDocumentAction: (onDocumentSelected: (document: NhrDocument) => Promise<void>) => NhrActionsBuilder createMoreActionsAction: (onDocumentSelected: (document: NhrDocument) => Promise<void> …(truncated, 545 more chars)

Tools used:

  • Bash: # Check handleDismiss: blocked while loading test …

Tool results:

→ result (ok): 81: describe('handleDismiss', () => { 87: act(() => result.current.handleDismiss())

Tools used:

  • Bash: # Check if patient.ins null guard is tested …

Tool results:

→ result (ok): 25:const patient = { ins: 'INS-123' } as unknown as Patient 42: const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) 47: const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) 54: const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) 63: const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) 73: const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) 83:
…(truncated, 755 more chars)

Tools used:

  • Bash: # Check what the handleConfirm early return includes: !modalState, !nhrOperations, !patient.ins …

Tool results:

→ result (ok): 62: it('sets modalState when archive option is clicked', () => { 68: expect(result.current.modalState).not.toBeNull() 69: expect(result.current.modalState?.doc).toBe(activeDoc) 82: it('clears modalState and error', () => { 89: expect(result.current.modalState).toBeNull() 140: expect(result.current.modalState).toBeNull() 154: expect(result.current.modalState).not.toBeNull()

Tools used:

  • Bash: # Check the exact lines around handleConfirm "does nothing when nhrOperations is null" test …

Tool results:

→ result (ok): expect(result.current.error).toBeNull() })

it('does nothing when nhrOperations is null', async () => {
  jest.mocked(useNationalHealthRecords).mockReturnValue(null as never)
  const { result } = renderHook(() => useNhrDocumentStatusActions({ patient }))
  const archiveOption = findOption(result.current.options, 'archive')

  act(() => archiveOption.onClick(activeDoc))
  await act(async () => {
    await result.current.handleConfirm()
  })

  expect(mockUp

…(truncated, 59 more chars)

Tools used:

  • Bash: # Examine the "clears previous error when a new action is triggered" test more carefully …

Tool results:

→ result (ok): it('clears previous error when a new action is triggered', () => { const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) const archiveOption = findOption(result.current.options, 'archive')

  act(() => archiveOption.onClick(activeDoc))
  expect(result.current.error).toBeNull()
})

})

describe('handleDismiss', () => { it('clears modalState and error', () => { const { result } = renderHook(() => useNhrDocumentStatusActions({ patient })) …(truncated, 283 more chars)

Tools used:

  • Bash: # Check if isLoading=true being set is verified anywhere, and check the isLoading state in tests …

Tool results:

→ result (ok): (Bash completed with no output)

Tools used:

  • Bash: # Check if there are any existing tests for the PatientCard component …

Tool results:

→ result (ok): /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/PatientCard/PatientCard.test.tsx /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/useBlockOrUnblockPatient.test.tsx /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/useMoveAppointment.test.ts /Users/USER/workspace/doctolib/doctol …(truncated, 1500 more chars)

Tools used:

  • Read: /Users/USER/workspace/doctolib/doctolib/packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/PatientCard/PatientCard.test.tsx

Tool results:

→ result (ok): 1 import '@testing-library/jest-dom' 2 import { screen } from '@testing-library/react' 3 import type { ReactElement, ReactNode } from 'react' 4 import { setup } from '@doctolib/test-helpers' 5 import dayjs from 'dayjs' 6 import { patientFixture } from 'monolith_DEPRECATED/test-helpers/patientFixtureBuilder' 7 import { DoctorDesktopProvidersMock } from 'monolith_DEPRECATED/entrypoints-content/doctor-desktop-providers.mock' 8 import { INSiAutomaticCallProvider } from '@doctolib/financial_os_api/pu …(truncated, 6457 more chars)

Now I have a complete picture of the coverage. Let me do a final check on the actionsBuilder change specifics and the NhrDocumentActionDialog rendering logic.

Tools used:

  • Bash: # Check how NhrDocumentActionDialog is used in PatientCard - specifically the isOpen logic …

Tool results:

→ result (ok): (Bash completed with no output)

Tools used:

  • Bash: # Check the DmpApi test changes and DmpApi.ts changes for context on the API …

Tool results:

→ result (ok): / eslint-disable @typescript-eslint/no-non-null-assertion / import type { Patient } from 'monolith_DEPRECATED/types/doctor/api/Patient' import type { MedicalFolder } from '@doctolib/ehr-core' import { getLoincCode } from 'monolith_DEPRECATED/models/document/document' import { sendMonitoringEvent } from 'monolith_DEPRECATED/services/monitoring' import { isMinor } from 'monolith_DEPRECATED/models/patient/patient' import { isMedicalSynthesis } from 'monolith_DEPRECATED/components/doctor/desktop/p …(truncated, 2737 more chars)

Tools used:

  • Bash: # Check how updateDocumentMetadata works in the NhrAdapter and DmpNhrAdapter …

Tool results:

→ result (ok): async updateDocumentMetadata(props: NhrDocumentMetadataUpdateProps): Promise<NhrDocumentMetadataUpdateResult> { if (!props.patient?.nationalHealthIdentifier) { throw new Error('patient_national_health_identifier_required') }

const ins = toEnvIns(props.patient.nationalHealthIdentifier)
const { payloads } = props.params

const payloadResults: NhrDocumentMetadataUpdatePayloadResult[] = await Promise.all(
  payloads.map(async (payload): Promise&lt;NhrDocumentMetadataUpdat

…(truncated, 678 more chars)

Tools used:

  • Bash: # Check the "clears previous error when a new action is triggered" test - is it actually testing …

Tool results:

→ result (ok): (Bash completed with no output)

Tools used:

  • Bash: # Check PatientCard.test.tsx mocking of national-health-records more carefully …

Tool results:

→ result (ok): 18:import { useGetDocumentsContent, useNhrDocumentListVariant } from '@doctolib/national-health-records' 60:jest.mock('@doctolib/national-health-records', () => ({ 61: ...jest.requireActual('@doctolib/national-health-records'),

Tools used:

  • Bash: # Check exactly what's mocked from @doctolib/national-health-records in PatientCard test …

Tool results:

→ result (ok): jest.mock('@doctolib/national-health-records', () => ({ ...jest.requireActual('@doctolib/national-health-records'), useNhrDocumentListVariant: jest.fn(), useGetDocumentsContent: jest.fn(), })) const useNhrDocumentListVariantMock = jest.mocked(useNhrDocumentListVariant) const useGetDocumentsContentMock = jest.mocked(useGetDocumentsContent)

Now I have all the information needed for a thorough analysis. Here is the structured findings.


Summary

The main hook useNhrDocumentStatusActions is reasonably well tested: happy paths, error recovery, and the nhrOperations === null guard are all covered. The isActive / isArchived predicates get dedicated coverage in dmpDocumentHelpers.test.ts. However, several non-trivial gaps remain, one of which is high-risk because it involves a breaking API change.


Critical Gaps

1. actionsBuilder.createMoreActionsAction — breaking signature change is completely untested

Criticality: 9/10

File: /packages/@doctolib/national-health-records/src/business/builders/actionsBuilder.ts

The old signature was createMoreActionsAction(onDocumentSelected: (document: NhrDocument) => Promise<void>) — it accepted a callback and passed it through the moreActionsActionFactory wrapper. The new signature is createMoreActionsAction(options: DropdownActionOption[]) — it passes the options array directly. No test file exists for actionsBuilder at all (on master or in this PR). Any caller still using the old callback-based form silently receives a DropdownActionOption[] as an argument, which would be wrapped in an array and passed as options to the factory — producing an options list that is itself a function rather than a list of objects. That would cause a silent runtime failure (the dropdown renders nothing or crashes).

The regression this would catch: a refactor that accidentally reverts the createMoreActionsAction implementation back to the callback pattern, or another team importing actionsBuilder and misusing the pre-PR API based on stale knowledge.

A minimal test suite for actionsBuilder should verify: - build() on a fresh builder returns [] - Chaining createViewDocumentAction then build() returns one action - Chaining createMoreActionsAction(options) then build() returns one action whose options array equals what was passed in - The builder is immutable — chaining does not mutate the original


2. handleDismiss while isLoading=true — guard is completely untested

Criticality: 8/10

File: /packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.ts lines 87–91, tested in /packages/@doctolib/national-health-records/src/hooks/useNhrDocumentStatusActions.test.ts

The source contains:

const handleDismiss = () => {
  if (isLoading) return
  setModalState(null)
  setError(null)
}

The single handleDismiss test calls dismiss after the modal is open but before any handleConfirm is in flight, so isLoading is always false. The case where a user clicks the cancel/dismiss button while the API call is in progress is entirely unexercised. This is the only place that prevents a race condition where the dialog is destroyed while updateDocumentMetadata is still awaiting.

A missing test scenario: open modal, call handleConfirm without awaiting it (so isLoading is true), then call handleDismiss mid-flight, assert that modalState is still set and isLoading is still true. Without this test, anyone removing or relaxing the if (isLoading) return guard will not be caught.


Important Improvements

3. handleConfirm with !patient.ins guard — untested early return branch

Criticality: 6/10

File: useNhrDocumentStatusActions.tshandleConfirm line: if (!modalState || !nhrOperations || !patient.ins) return

The nhrOperations === null branch is tested. The !modalState branch is implicitly tested (no test calls handleConfirm without first opening a modal, but the nhrOperations=null test does open a modal, so !modalState is never the sole reason the guard fires). The !patient.ins branch is not covered at all.

If the INS field is absent (e.g. a patient without a qualified INS, which is a real production scenario in France for non-qualified patients), handleConfirm silently does nothing. A test should verify: given patient = { ins: null }, after opening the dialog, handleConfirm does not call updateDocumentMetadata.

This matters because the useSearchDocuments hook has explicit coverage for the !ins case and returns a skipped status with a user-visible message — the status actions hook has no equivalent signal, just a silent no-op. A test documents that this is intentional.


4. "clears previous error when a new action is triggered" test is vacuously true

Criticality: 5/10

File: useNhrDocumentStatusActions.test.ts lines 72–78

The test opens the archive option and immediately asserts error === null. Since no error was ever set before the click, this assertion is trivially satisfied regardless of whether openModal calls setError(null) or not. The test would still pass if the setError(null) line were deleted from openModal.

The correct version of this scenario is: 1. Open modal → call handleConfirm → let it fail → assert error !== null 2. Click archive again (i.e. call openModal) → assert error has been reset to null

Without this, the setError(null) inside openModal is dead from a test-coverage perspective.


5. useInvalidateNhrDocuments — no dedicated unit test

Criticality: 5/10

File: /packages/@doctolib/national-health-records/src/hooks/useInvalidateNhrDocuments.ts

The hook is 8 lines but contains a specific contract: the queryKey prefix is ['dmp-documents', patient.ins], which is designed to bust all filter variants for a patient. This key must match the queryKey used in useSearchDocuments (['dmp-documents', ins, appliedFilters]). A test should verify: - The returned function calls queryClient.invalidateQueries with exactly { queryKey: ['dmp-documents', patient.ins] }

This is worth testing because the two-element prefix key is the load-bearing contract. If someone changes the query key in useSearchDocuments (e.g. adds a prefix, renames dmp-documents) without updating useInvalidateNhrDocuments, cache invalidation will silently break — archive/unarchive operations will appear to succeed but the document list will not refresh. A direct test pins this contract in place.

The hook is currently exercised indirectly via the useNhrDocumentStatusActions tests (which mock useInvalidateNhrDocuments entirely), so the actual invalidateQueries call shape is never verified at all.


6. NhrDocumentActionDialog — no test, but low-risk given its nature

Criticality: 4/10

File: /packages/@doctolib/national-health-records/src/components/NhrDocumentActionDialog.tsx

The component is 32 lines of pure JSX delegation to Dialog and Alert. The notable behaviors are: - Returns null when config is null (renders nothing) - Renders Alert only when error is non-null - Passes dismissText={undefined} when isLoading=true (hides the cancel button) - Passes the config.title, config.body, config.confirmLabel through to Dialog

These are integration-level rendering behaviors. A simple RTL test with three cases (config=null → renders nothing, error present → Alert visible, isLoading=true → no dismiss text) would lock in the contract between the hook state and the dialog rendering. Without it, a future refactor that e.g. passes dismissText="" instead of undefined (which would render a blank cancel button) is uncaught.

This is rated 4 rather than higher because Dialog and Alert are design system components under separate ownership, and the risk of silent behavioral regression is lower than for business logic.


7. PatientCard.test.tsx does not mock useNhrDocumentStatusActions — potential test instability

Criticality: 4/10

File: /packages/@doctolib/shared_patient_file_and_appointment_page_components/src/desktop/PatientCard/PatientCard.test.tsx

The mock at line 60–64 uses jest.requireActual('@doctolib/national-health-records') which will now load the real ` …(truncated, 2498 more chars)

Keyboard shortcuts

⌘K / Ctrl+KOpen command palette
/Focus search
g hGo to home
g pGo to projects
g sGo to sessions
j / kNext / prev row (tables)
?Show this help
EscClose dialogs

Structured queries

Mix key:value filters with free text in the palette:

type:sessionOnly session pages
project:llm-wikiFilter by project name (substring)
model:claudeFilter by model name (substring)
date:>2026-03-01Sessions after a date
date:<2026-04-01Sessions before a date
tags:rustPages mentioning a tag/topic
sort:dateSort results by date (newest first)

Example: type:session project:llm-wiki date:>2026-04 sort:date