Anchor the document visit-suggestion on a full instant

The suggestion anchored on the document's own date, which the DTO carries
as a date only. The suggest endpoint takes a full instant, so every
document asked the question as `2025-10-14` and got 422 back; the field
then rendered nothing and no document ever offered the visit its date
falls near. Lift the date to noon UTC before asking, the shape the two
lab moments already send.

The e2e that should have caught it never authenticated: the visits spec
carried no storage state, so its `page` redirected to login and its
`request` reads answered 401. It also asserts a global verdict — one
visit in the document's window — so clear the account's visits before
each test, run the file serially, and keep it to one project, since two
projects mutating the shared account would leave two candidates in the
window.

The accessibility mock lagged the same feature: the detail sheet reads
`encounterLinks` off the document and the mock omitted it, so the sheet
threw before it painted. Add the field the server always sends.
This commit is contained in:
Marc-André Bombeck committed 2026-08-08 18:46:55 +02:00
1 parent 9456b18497
commit 594898d350
5 files changed
+68 -2

No files matched your search

@@ -12,6 +12,14 @@
* of the two; `documentDate` is the person's own filing date and is the
* fallback.
*
* Both DTO fields are date-only (`YYYY-MM-DD`), but the suggest endpoint takes
* a full instant — the same shape the two lab moments already hand it. So the
* date is lifted to noon UTC here, exactly as the OCR review does: the rule is
* a ±7-day window, so the time of day never changes the verdict, and noon keeps
* a viewer's local midnight from rounding the day either way. Passing the bare
* date instead is what made this suggestion silently never appear — the API
* answered 422 and the field rendered nothing.
*
* It renders nothing once the document already names a visit that this session
* did not choose: an offer to file something already filed is noise.
*/
@@ -31,9 +39,10 @@ export function DocumentEncounterSuggestion({
onChange: (encounterId: string | null) => void;
}) {
if (alreadyLinked) return null;
const instant = anchor ? `${anchor}T12:00:00.000Z` : null;
return (
<EncounterSuggestionField
anchor={anchor}
anchor={instant}
value={value}
onChange={onChange}
disabled={disabled}