feat(stammbaum): centre-on-person control in the panel title row (#692)
Add an onCentre control to StammbaumSidePanel (title row, both desktop aside and mobile sheet). The page drives a one-shot centreOnId so StammbaumTree recentres the canvas on the focal node (US-PAN-005). Also tighten the panel spec's deathYear fixture to a valid type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ const makeNode = () => ({
|
||||
id: 'person-1',
|
||||
displayName: 'Alice Müller',
|
||||
birthYear: 1900,
|
||||
deathYear: null,
|
||||
deathYear: undefined,
|
||||
familyMember: true
|
||||
});
|
||||
|
||||
@@ -50,6 +50,23 @@ describe('StammbaumSidePanel', () => {
|
||||
await expect.element(page.getByText('Alice Müller')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the centre control when onCentre is not provided', async () => {
|
||||
render(StammbaumSidePanel, { node: makeNode(), onClose: vi.fn(), canWrite: false });
|
||||
await expect
|
||||
.element(page.getByRole('button', { name: 'Auf diese Person zentrieren' }))
|
||||
.not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onCentre when the centre control is clicked (US-PAN-005)', async () => {
|
||||
const onCentre = vi.fn();
|
||||
render(StammbaumSidePanel, { node: makeNode(), onClose: vi.fn(), onCentre, canWrite: false });
|
||||
const btn = [...document.querySelectorAll<HTMLButtonElement>('button')].find(
|
||||
(b) => b.getAttribute('aria-label') === 'Auf diese Person zentrieren'
|
||||
);
|
||||
btn!.click();
|
||||
expect(onCentre).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('shows empty-relationships message when no direct relationships are loaded', async () => {
|
||||
render(StammbaumSidePanel, { node: makeNode(), onClose: vi.fn(), canWrite: false });
|
||||
await expect.element(page.getByText('Noch keine Beziehungen bekannt.')).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user