/Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal
…(truncated, 112 more chars)
Tools used:
- Bash: grep -rn "truncate" /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src --include=".tsx" --include=".ts" 2
…(truncated, 3 more chars)
Tool results:
→ result (ok): /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal/NhrDocumentListTable/NhrDocumentListTableBody/NhrDocumentListTableBody.tsx:33:
Tools used:
- Bash: # Check if any column render function returns a React element (not just strings) to understand if getTextContent handles real-world render() outputs …
Tool results:
→ result (ok): render: (doc) => doc.classification?.codes[0]?.code ?? '-',
},
{
key: 'title',
header: 'Document name',
sortable: true,
--
render: (doc) => doc.title,
},
{
key: 'procedureDate',
header: 'Procedure date',
sortable: true,
--
render: (doc) => doc.serviceInformation?.startDate ?? '-',
},
{
key: 'submissionDate',
header: 'Share date',
sortable: true,
--
render: (doc) => doc.submissionDate ?? '-',
},
{
key: 'author',
header: 'Shar
…(truncated, 347 more chars)
Tools used:
- Bash: # Check for any column factory files that may create columns with React element renders (the consuming doctolib repo adds actual widths) …
Tool results:
→ result (ok): /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrDocumentCategoryColumn.test.tsx
/Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrDocumentCategoryColumn.tsx
/Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncat
…(truncated, 2286 more chars)
Tools used:
- Bash: grep -h "render" /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrDoc
…(truncated, 426 more chars)
Tool results:
→ result (ok): render: (doc: NhrDocument) => (
render: (doc: NhrDocument) =>
,
When absent, doc.status is rendered as a single badge with the raw string as the label (no statusMap lookup).
Pill config rendered when doc.status is undefined or empty,
render: (doc: NhrDocument) => (
Tools used:
- Read: /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrDocumentCategoryColumn.tsx
Tool results:
→ result (ok): 1 import type { NhrDocument } from '@doctolib/tpf-national-health-records'
2
3 import { NhrDocumentCategoryCell } from '../../../components/NhrDocumentList/NhrDocumentCategoryCell/NhrDocumentCategoryCell'
4 import type { IconMap } from '../../../components/NhrDocumentList/NhrDocumentCategoryCell/NhrDocumentCategoryCell'
5 import type { ColumnConfig } from '../../../types'
6
7 export type NhrDocumentCategoryColumnOptions = {
8 / Translated column header /
9 header: string
10 / Extrac
…(truncated, 1071 more chars)
Tools used:
- Read: /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrStatusColumn.tsx
Tool results:
→ result (ok): 1 import type { PillColor } from '@doctolib/design-system/Pill'
2 import type { NhrDocument } from '@doctolib/tpf-national-health-records'
3
4 import { NhrStatusCell } from '../../../components/NhrDocumentList/NhrStatusCell'
5 import type { ColumnConfig } from '../../../types'
6
7 / Pill config for a single recognized status token /
8 export type NhrDocumentStatusConfig = {
9 label: string
10 color?: PillColor
11 }
12
13 export type NhrStatusColumnOptions = {
14 / Translated column
…(truncated, 1764 more chars)
Tools used:
- Read: /Users/USER/workspace/doctolib/worktrees/treatment-plan/fhir-2223_fix-column-widths-truncation/packages/tpf-national-health-records-ui/src/business/factories/columns/createNhrVisibilityColumn.tsx
Tool results:
→ result (ok): 1 import type { NhrDocument } from '@doctolib/tpf-national-health-records'
2
3 import { NhrVisibilityCell } from '../../../components/NhrDocumentList/NhrVisibilityCell'
4 import type { ColumnConfig, NhrVisibilityEntry } from '../../../types'
5
6 export type NhrVisibilityColumnOptions = {
7 / Translated column header /
8 header: string
9 / Decodes document visibility into badge entries /
10 getVisibilityEntries: (doc: NhrDocument) => NhrVisibilityEntry[]
11 }
12
13 /
14 * Feat
…(truncated, 474 more chars)
I now have all the information I need. Let me compile the final analysis.
---
Summary
The PR adds four pieces of new functionality: a getTextContent pure helper, fixedLayout on the Table, initialWidth on TableHeadCell, and a truncation wrapper in TableBody. Each change has at least one test. Overall, test coverage is adequate for a presentational/UI change of this scope, and the tests follow the project's RTL/Vitest conventions. There are no critical uncovered paths, but a few meaningful gaps exist.
---
Critical Gaps
None rated 9-10
There are no security-critical, data-loss, or system-failure-level gaps. All new production branches are exercised.
---
Important Improvements
1. No test verifies that a column without width does NOT receive an inline style (rating: 6)
The new test in /packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal/NhrDocumentListTable/NhrDocumentListTableHead/NhrDocumentListTableHead.test.tsx covers the "width present" branch. The negative branch — col.width is undefined, so initialWidth receives undefined and no style attribute is emitted — is not tested. If someone accidentally changed initialWidth={col.width} to initialWidth={col.width ?? '10%'}, no existing test would fail.
A concrete regression it prevents: a future change that adds a default fallback width would silently break all columns that are supposed to auto-size, and no test would catch it.
Suggested assertion to add to the existing head test file (alongside the existing mockColumns tests, since none of those columns carry a width value):
expect(screen.getByRole('columnheader', { name: 'Document name' })).not.toHaveStyle('width')
2. The truncation tooltip test relies on a single hardcoded value tied to the fixture default (rating: 6)
The test at line 102-110 of /packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal/NhrDocumentListTable/NhrDocumentListTableBody/NhrDocumentListTableBody.test.tsx asserts getByTitle('SOPK test results'). This passes only because nhrDocumentFixtureBuilder() defaults to title: 'SOPK test results' and the render function for the title column returns doc.title directly.
The truncation wrapper is applied to every column in every row, but the test only confirms one specific title value. Two meaningful gaps:
- A React-element-returning column (like those produced by createNhrDocumentCategoryColumn, createNhrStatusColumn, createNhrVisibilityColumn) will produce an empty string tooltip. There is no test covering the case where a render function returns a React element, confirming that getTextContent is actually invoked and the tooltip is populated correctly. If getTextContent were removed from the title prop, the Pill/badge columns would silently show empty tooltips and this test would not catch it.
- The test says "includes a title tooltip" but actually only verifies one specific text value exists somewhere in the document. It does not verify it is on the wrapping div for that column.
Adding one test with a mock column whose render returns a React element (e.g., createElement('span', null, 'Category label')) and asserting getByTitle('Category label') would cover the real-world usage path where getTextContent does actual recursive work in production.
3. col.render(row) is called twice per cell in production (rating: 5)
In /packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal/NhrDocumentListTable/NhrDocumentListTableBody/NhrDocumentListTableBody.tsx lines 33-34:
{col.render(row)}
col.render(row) is invoked twice per cell. For pure string-returning columns this is harmless, but for render functions that trigger side effects or construct expensive sub-trees, this doubles the work. No test currently would catch a regression if the double-call introduced a visible bug (for instance, a render function that returns a component with an internal useEffect). This is worth a brief comment or a memoization of the result into a local variable in the production code, but the test gap here is lower priority — the current column factories are all pure.
---
Test Quality Issues
The dl-table-layout-fixed class assertion is acceptable but slightly implementation-coupled
The test in NhrDocumentListTable.test.tsx line 65 uses document.querySelector('.dl-table-layout-fixed'). The project's own testing rules note this pattern requires a justification comment, which is present ("Testing that Oxygen's fixedLayout prop applies the CSS class"). The justification is valid here: the intent of fixedLayout={true} is specifically that this CSS class is applied, so verifying the class is the most direct way to confirm the Oxygen component honored the prop. The test is correctly scoped and the comment satisfies the project's CSS-selector exception policy.
The getTextContent test correctly uses createElement instead of JSX
The unit test file /packages/tpf-national-health-records-ui/src/components/NhrDocumentListModal/NhrDocumentListTable/NhrDocumentListTableBody/NhrDocumentListTableBody.helpers.test.ts uses .ts extension (not .tsx) and imports createElement directly, which is idiomatic for a non-JSX file. This is correct and avoids an unnecessary .tsx conversion.
---
Positive Observations
- All 8 getTextContent cases cover the complete TypeScript union of ReactNode (string, number, ReactElement, ReactNode[], null, undefined, boolean). The recursive case is covered. This is thorough for a pure helper.
- The width test in NhrDocumentListTableHead.test.tsx creates its own isolated ColumnConfig fixture rather than mutating shared mockColumns, keeping the test hermetic.
- The tooltip test uses getByTitle (a semantic query), not a CSS selector, which will survive DOM restructuring.
- The fixedLayout test is appropriately placed at the integration level (NhrDocumentListTable) rather than duplicated in both child components, since the prop is set at that layer.
- The PR correctly avoids testing that width?: string appears in the TypeScript type definition — that is a type-system concern verified by tsc`, not a runtime test.