test(persons): cover personType icon paths + life-date branches

INSTITUTION/GROUP/UNKNOWN personType icons, birthYear-only and
deathYear-only life-date display.

5 new tests covering ~10 branches.

Refs #496.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-10 08:50:57 +02:00
parent eed59f50e5
commit 87e87e17f5

View File

@@ -187,4 +187,110 @@ describe('persons/+ page', () => {
await expect.element(page.getByText(/Anni/)).toBeVisible();
});
it('shows the institution svg icon for INSTITUTION personType', async () => {
render(PersonsListPage, {
props: {
data: baseData({
persons: [
{
id: 'p1',
firstName: '',
lastName: 'Bundesarchiv',
displayName: 'Bundesarchiv',
personType: 'INSTITUTION'
}
]
})
}
});
// SVG icon (not initials text)
const card = document.querySelector('a[href="/persons/p1"]');
expect(card?.querySelector('svg')).not.toBeNull();
});
it('shows the group svg icon for GROUP personType', async () => {
render(PersonsListPage, {
props: {
data: baseData({
persons: [
{
id: 'pg',
firstName: '',
lastName: 'Family X',
displayName: 'Family X',
personType: 'GROUP'
}
]
})
}
});
const card = document.querySelector('a[href="/persons/pg"]');
expect(card?.querySelector('svg')).not.toBeNull();
});
it('shows the unknown svg icon for UNKNOWN personType', async () => {
render(PersonsListPage, {
props: {
data: baseData({
persons: [
{
id: 'pu',
firstName: '',
lastName: 'Unknown',
displayName: 'Unknown',
personType: 'UNKNOWN'
}
]
})
}
});
const card = document.querySelector('a[href="/persons/pu"]');
expect(card?.querySelector('svg')).not.toBeNull();
});
it('renders only birthYear with em-dash when no death year', async () => {
render(PersonsListPage, {
props: {
data: baseData({
persons: [
{
id: 'p1',
firstName: 'Anna',
lastName: 'Schmidt',
displayName: 'Anna Schmidt',
personType: 'PERSON',
birthYear: 1899
}
]
})
}
});
expect(document.body.textContent).toContain('1899');
});
it('renders only deathYear with em-dash when no birth year', async () => {
render(PersonsListPage, {
props: {
data: baseData({
persons: [
{
id: 'p1',
firstName: 'Anna',
lastName: 'Schmidt',
displayName: 'Anna Schmidt',
personType: 'PERSON',
deathYear: 1950
}
]
})
}
});
expect(document.body.textContent).toContain('1950');
});
});