feat(stammbaum): family network — graph, badge, edit card, /stammbaum page (#358) #360

Merged
marcel merged 57 commits from feat/stammbaum-issue-358 into main 2026-04-28 19:33:33 +02:00
2 changed files with 67 additions and 0 deletions
Showing only changes of commit f382bd9974 - Show all commits

View File

@@ -0,0 +1,57 @@
import { test, expect } from '@playwright/test';
test.describe('Stammbaum — issue #358', () => {
test('nav swap: /briefwechsel still renders without 404', async ({ page }) => {
// Plan journey 4: the /briefwechsel route must stay intact even though the
// AppNav now points at /stammbaum.
const response = await page.goto('/briefwechsel');
expect(response?.status()).toBeLessThan(400);
await expect(page).toHaveURL(/\/briefwechsel/);
});
test('/stammbaum renders the page heading', async ({ page }) => {
await page.goto('/stammbaum');
await expect(page.getByRole('heading', { name: 'Stammbaum' })).toBeVisible();
});
test('/stammbaum either shows an empty state or at least one node', async ({ page }) => {
// Plan journey 3 (empty branch) and journey 1 (populated branch) covered jointly:
// the test passes whenever the page renders one of the two coherent states.
await page.goto('/stammbaum');
const empty = page.getByRole('heading', { name: 'Noch keine Familienmitglieder' });
const anyNode = page.locator('svg[role="img"][aria-label="Stammbaum"] g[role="button"]');
await expect(async () => {
const emptyVisible = await empty.isVisible().catch(() => false);
const nodeCount = await anyNode.count();
expect(emptyVisible || nodeCount > 0).toBe(true);
}).toPass();
if (await empty.isVisible().catch(() => false)) {
await expect(page.getByRole('link', { name: /Zur Personenliste/ })).toBeVisible();
}
});
test('person edit Stammbaum card surfaces the year-range error', async ({ page }) => {
// Plan task 36: Bis < Von triggers the inline error and keeps the form unsubmitted.
// We pick the first person, open the edit page, expand the add-rel form, and
// inspect the validation message bound to the Bis field.
await page.goto('/persons');
const firstPerson = page.locator('a[href^="/persons/"]').first();
await firstPerson.click();
await expect(page).toHaveURL(/\/persons\/[^/]+/);
await page.goto(page.url() + '/edit');
// Open the add-rel form
const addBtn = page.getByRole('button', { name: /Beziehung hinzufügen/i });
await addBtn.click();
// Enter Von 1935, Bis 1920 → expect the year-range error
const fromInput = page.locator('input[name="fromYear"]');
const toInput = page.locator('input[name="toYear"]');
await fromInput.fill('1935');
await toInput.fill('1920');
await expect(page.locator('#add-rel-year-error')).toBeVisible();
await expect(page.locator('#add-rel-year-error')).toContainText(/Bis.*Von|nicht vor/i);
});
});

View File

@@ -27,6 +27,8 @@ describe('person detail load — happy path', () => {
.mockResolvedValueOnce({ response: { ok: true }, data: [{ id: 'd1', title: 'Brief' }] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
} as ReturnType<typeof createApiClient>);
const result = await load({ params: { id: 'p1' }, fetch: mockFetch, locals: mockLocals });
@@ -47,6 +49,8 @@ describe('person detail load — happy path', () => {
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
} as ReturnType<typeof createApiClient>);
const result = await load({ params: { id: 'p1' }, fetch: mockFetch, locals: mockLocalsWriter });
@@ -65,6 +69,8 @@ describe('person detail load — happy path', () => {
.mockResolvedValueOnce({ response: { ok: false }, data: null })
.mockResolvedValueOnce({ response: { ok: false }, data: null })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
} as ReturnType<typeof createApiClient>);
const result = await load({ params: { id: 'p1' }, fetch: mockFetch, locals: mockLocals });
@@ -85,6 +91,8 @@ describe('person detail load — error paths', () => {
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
} as ReturnType<typeof createApiClient>);
await expect(
@@ -102,6 +110,8 @@ describe('person detail load — error paths', () => {
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
.mockResolvedValueOnce({ response: { ok: true }, data: [] })
} as ReturnType<typeof createApiClient>);
await expect(