feat(#38): document edit history with diff and compare mode #52

Merged
marcel merged 13 commits from feat/38-document-edit-history into main 2026-03-23 17:27:57 +01:00
Owner

Summary

  • Adds a document_versions table (Flyway V9) storing JSONB snapshots of each document state after create/update
  • DocumentVersionService computes changedFields at write time by diffing against the previous snapshot; denormalizes editorName
  • Two new endpoints: GET /api/documents/{id}/versions and GET /api/documents/{id}/versions/{versionId}
  • Frontend: collapsible history panel on the document detail page with word-level diff (via diff npm package) and compare mode for any two versions
  • 19 new i18n keys (de/en/es)

Test plan

  • All 106 backend unit tests pass (./mvnw test)
  • DocumentVersionServiceTest — 12 tests covering editor name, snapshot content, changedFields tracking (title, location, sender, receivers, tags), getSummaries, getVersion
  • DocumentServiceTest — 2 new tests verifying version is recorded after create and update
  • DocumentControllerTest — 4 new tests for the two version endpoints (401 + 200)
  • svelte-check passes (0 errors related to history feature)
  • E2E spec history.spec.ts — 3 scenarios: versions list, diff after title edit, compare mode

Closes #38

🤖 Generated with Claude Code

## Summary - Adds a `document_versions` table (Flyway V9) storing JSONB snapshots of each document state after create/update - `DocumentVersionService` computes `changedFields` at write time by diffing against the previous snapshot; denormalizes `editorName` - Two new endpoints: `GET /api/documents/{id}/versions` and `GET /api/documents/{id}/versions/{versionId}` - Frontend: collapsible history panel on the document detail page with word-level diff (via `diff` npm package) and compare mode for any two versions - 19 new i18n keys (de/en/es) ## Test plan - [ ] All 106 backend unit tests pass (`./mvnw test`) - [ ] `DocumentVersionServiceTest` — 12 tests covering editor name, snapshot content, changedFields tracking (title, location, sender, receivers, tags), getSummaries, getVersion - [ ] `DocumentServiceTest` — 2 new tests verifying version is recorded after create and update - [ ] `DocumentControllerTest` — 4 new tests for the two version endpoints (401 + 200) - [ ] `svelte-check` passes (0 errors related to history feature) - [ ] E2E spec `history.spec.ts` — 3 scenarios: versions list, diff after title edit, compare mode Closes #38 🤖 Generated with [Claude Code](https://claude.com/claude-code)
marcel added 1 commit 2026-03-23 16:05:31 +01:00
fix(e2e): wait for hydration on document detail page in history tests
Some checks failed
CI / Backend Unit Tests (pull_request) Waiting to run
CI / E2E Tests (pull_request) Waiting to run
CI / Unit & Component Tests (push) Successful in 2m11s
CI / Backend Unit Tests (push) Successful in 2m15s
CI / Unit & Component Tests (pull_request) Has been cancelled
CI / E2E Tests (push) Failing after 28m46s
62f62a89a1
All three history tests navigated to the doc page but didn't wait for
SvelteKit hydration, so the toggle onclick wasn't registered yet. Also
wait for versions to load (API call) before asserting on version items
or the compare button.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel force-pushed feat/38-document-edit-history from 8b422c8f06 to 62f62a89a1 2026-03-23 16:05:31 +01:00 Compare
marcel added 1 commit 2026-03-23 17:05:56 +01:00
fix(dev): inject Authorization header from cookie in Vite dev proxy
Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 2m13s
CI / Backend Unit Tests (pull_request) Successful in 2m9s
CI / E2E Tests (pull_request) Successful in 20m15s
CI / Unit & Component Tests (push) Successful in 2m4s
CI / Backend Unit Tests (push) Successful in 2m8s
CI / E2E Tests (push) Failing after 23s
4f69457a68
Browser-side fetch('/api/...') calls bypass SvelteKit's handleFetch hook
(which adds the Authorization header from the auth_token cookie for SSR).
As a result, client-side API calls in the dev server always got a 401.

Add a proxy configure hook that extracts the auth_token cookie from incoming
requests and sets it as the Authorization header before forwarding to the
backend. This makes browser-side fetches (history panel, file preview, etc.)
work correctly in dev mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marcel merged commit 4f69457a68 into main 2026-03-23 17:27:57 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#52