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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-28 12:25:34 +02:00
committed by marcel
parent 6074ac396f
commit 13bb3b451e
2 changed files with 42 additions and 31 deletions

View File

@@ -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();
});
});