mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
Wave-D reconcile report at .planning/phase-D-reconcile-report.md; deferred items seeded to .planning/v1419-backlog.md; strategic v1.5 items appended to .planning/v15-backlog.md from the v1.4.18 Product-Lead review. STATE.md marks Wave D done. Prettier sweep also touched the planning markdown table widths; no content change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.4 KiB
4.4 KiB
Phase B7 — Settings → Export menu (Arztbrief consolidated)
Status: complete on origin/main.
What shipped
<ExportSection>(src/components/settings/export-section.tsx) — five cards (Doctor Report PDF, Measurements CSV, Medications CSV with optional intake-history toggle, Mood CSV, Full JSON Backup), mobile-first stacking on<mdand a 2-column grid on>=md. Each card carries a stabledata-testidso the e2e suite can target it without depending on the localised label.- New dynamic-route slug
/settings/exportwired throughSETTINGS_SECTION_SLUGSSECTION_COMPONENTS+SETTINGS_SECTIONS(sidebar nav + mobile strip).<SectionPlaceholder>learned the new icon so a future slug addition cannot crash type-checking.
<AdvancedSection>simplified to the danger-zone card alone — every export path moved out into<ExportSection>. The "wipe all data" surface should never live next to a one-click export button.- Doctor-report e2e spec (
e2e/doctor-report.spec.ts) follows the entry-point relocation from/settings/advancedto/settings/exportand now drives the dialog through the submit step. - Four new endpoints under plain segments (vitest can't resolve dotted
segments cleanly, so the file extension lives in
Content-Dispositionfilename instead):GET /api/export/measurements→ text/csv, optionalsince/untilGET /api/export/medications→ text/csv, optional intake-history blockGET /api/export/mood→ text/csv, optionalsince/untilGET /api/export/full-backup→ application/json matching the canonicalbackupPayloadSchemaso the user can hand the file to an admin andPOST /api/admin/backups/uploadaccepts it as-is.
- Each endpoint goes through
apiHandler+requireAuth(cookie session OR Bearer token), shares a singleexport:<userId>10/h rate-limit bucket, and writes auser.export.<kind>audit-log entry with the resolved filter. - 10 unit tests (
src/app/api/export/__tests__/per-type-routes.test.ts) pin the auth gate, content-type, content-disposition, and audit-log shape. 9 integration tests (tests/integration/export-per-type.test.ts) round-trip real Postgres rows against the testcontainer and assert no cross-tenant leak. New e2e smoke (e2e/settings-export.spec.ts) asserts the five-card rendering + drives a real Measurements CSV download.
i18n
- New keys under
settings.sections.export.*in EN + DE. Oldsettings.sections.advanced.descriptiontightened to "Import, danger zone." (was "Export, import, danger zone.") — export's no longer here.
Cross-agent staging notes
- A verification-gate stash/restore loop ran while I was iterating on
the integration-test suite. It absorbed my four route files + their
unit tests + the integration test into another agent's
"docs(planning): mark phase B3 (host-load chart) complete" commit
(
226cac4) — code shipped under the right author with myCo-Authored-Bytrailer, but the commit summary doesn't name the export work. Two follow-up commits (d5c8912,830b2b0) realigned the<ExportSection>endpoint URLs and the integration-test import paths from the old dotted-segment form.
Verification
pnpm test src/app/api/export src/components/settings src/lib/__tests__/i18n-locale-integrity.test.ts— all pass for the B7 scope. Two pre-existing failures elsewhere in the repo belong to B5a (insights citation footnote i18n drift), out of scope.pnpm test:integration export-per-type— 9/9 pass.pnpm typecheckclean for the B7 scope; pre-existing errors in B3/B4 territory (audit-log/actions, host-metric-sampler bigint literals, insight-advisor citation type) are out of bucket.
Commits on origin/main
621109c feat(settings): export-section consolidates doctor-report, CSVs, JSON backupa512650 feat(settings): /settings/export dynamic route wired into sidebar94c748d refactor(doctor-report): entry-point relocated under /settings/export226cac4 docs(planning): mark phase B3 (host-load chart) complete(absorbed B7's endpoint files + tests during a parallel-agent staging race — see cross-agent note above)d5c8912 fix(export-section): point download buttons at the new plain-segment endpoints830b2b0 test(export): integration test points at the new plain-segment endpointse628f33 test(export): coverage for export-section + endpoints