From e0e237509d570a34d73ea9441174ced7552427ad Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 28 Apr 2026 12:25:34 +0200 Subject: [PATCH] fix(stammbaum): import chipLabel/otherName from shared relationshipLabels in PersonRelationshipsCard Removes local duplicates of the switch-statement label logic already exported from $lib/relationshipLabels.ts. Adds two direction-sensitive tests proving the Elternteil-von / Kind-von branch is covered. Co-Authored-By: Claude Sonnet 4.6 --- .../[id]/PersonRelationshipsCard.svelte | 34 ++-------------- .../PersonRelationshipsCard.svelte.test.ts | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte b/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte index 4579e762..b57032b5 100644 --- a/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte +++ b/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte @@ -1,6 +1,6 @@
@@ -67,13 +39,13 @@ function otherName(rel: RelationshipDTO): string { - {chipLabel(rel)} + {chipLabel(rel, personId)} - {otherName(rel)} + {otherName(rel, personId)} {/each} diff --git a/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte.test.ts b/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte.test.ts index b0a13ef6..c23a356e 100644 --- a/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte.test.ts +++ b/frontend/src/routes/persons/[id]/PersonRelationshipsCard.svelte.test.ts @@ -5,6 +5,7 @@ import PersonRelationshipsCard from './PersonRelationshipsCard.svelte'; const PERSON_ID = '00000000-0000-0000-0000-000000000001'; const SPOUSE_ID = '00000000-0000-0000-0000-000000000002'; +const PARENT_ID = '00000000-0000-0000-0000-000000000003'; describe('PersonRelationshipsCard', () => { it('hides an inferred relationship that is already a direct one', async () => { @@ -53,4 +54,42 @@ describe('PersonRelationshipsCard', () => { await expect.element(page.getByText('Carla Cousine')).toBeInTheDocument(); }); + + it('shows Elternteil-von chip when personId is the PARENT_OF subject', async () => { + render(PersonRelationshipsCard, { + personId: PERSON_ID, + relationships: [ + { + id: 'r1', + personId: PERSON_ID, + relatedPersonId: PARENT_ID, + personDisplayName: 'Anna Müller', + relatedPersonDisplayName: 'Kind Müller', + relationType: 'PARENT_OF' + } + ], + inferredRelationships: [] + }); + + await expect.element(page.getByText('Elternteil von')).toBeInTheDocument(); + }); + + it('shows Kind-von chip when personId is the PARENT_OF object', async () => { + render(PersonRelationshipsCard, { + personId: PERSON_ID, + relationships: [ + { + id: 'r2', + personId: PARENT_ID, + relatedPersonId: PERSON_ID, + personDisplayName: 'Eltern Müller', + relatedPersonDisplayName: 'Anna Müller', + relationType: 'PARENT_OF' + } + ], + inferredRelationships: [] + }); + + await expect.element(page.getByText('Kind von')).toBeInTheDocument(); + }); });