feat(stammbaum): recentre on a node via centreOnId prop (#692)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -578,6 +578,38 @@ describe('StammbaumTree keyboard pan/zoom (#692)', () => {
|
||||
expect(onSelect).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('recentres on a node when centreOnId is set, auto-zooming to legible (US-PAN-005)', async () => {
|
||||
const onPanZoom = vi.fn();
|
||||
render(StammbaumTree, {
|
||||
nodes: [
|
||||
{ id: ID_A, displayName: 'Anna', familyMember: true },
|
||||
{ id: ID_B, displayName: 'Bertha', familyMember: true }
|
||||
],
|
||||
edges: [
|
||||
{
|
||||
id: 'sp',
|
||||
personId: ID_A,
|
||||
relatedPersonId: ID_B,
|
||||
personDisplayName: 'Anna',
|
||||
relatedPersonDisplayName: 'Bertha',
|
||||
relationType: 'SPOUSE_OF'
|
||||
}
|
||||
],
|
||||
selectedId: null,
|
||||
panZoom: { x: 0, y: 0, z: 0.5 },
|
||||
centreOnId: ID_A,
|
||||
onPanZoom,
|
||||
onSelect: () => {}
|
||||
});
|
||||
|
||||
await vi.waitFor(() => expect(onPanZoom).toHaveBeenCalled());
|
||||
const view = onPanZoom.mock.calls.at(-1)![0];
|
||||
// Anna sits left of the two-node midpoint → pan x is negative.
|
||||
expect(view.x).toBeLessThan(0);
|
||||
// Zoomed out below legible → snapped up to 1.
|
||||
expect(view.z).toBe(1);
|
||||
});
|
||||
|
||||
it('does not call onSelect for other keys', async () => {
|
||||
const onSelect = vi.fn();
|
||||
render(StammbaumTree, {
|
||||
|
||||
Reference in New Issue
Block a user