feat(stammbaum): mobile read path — pan, zoom, fit-to-view (#692) #694
@@ -54,10 +54,12 @@ describe('StammbaumTree viewBox', () => {
|
|||||||
expect(w).toBe(1200);
|
expect(w).toBe(1200);
|
||||||
expect(h).toBe(800);
|
expect(h).toBe(800);
|
||||||
|
|
||||||
// …but the origin is shifted by the pan offset.
|
// …but the viewBox centre is the content centroid shifted by the pan
|
||||||
const unpannedX = -(1200 / 2 - 160 / 2); // single 160-wide node centred
|
// offset (at pan {0,0} the centre sits on the centroid — see the test
|
||||||
expect(x).toBeCloseTo(unpannedX + 100, 6);
|
// below). This avoids hard-coding the layout's absolute coordinates.
|
||||||
expect(y).toBeCloseTo(-(800 / 2 - 56 / 2) + 40, 6);
|
const c = rectsCentroid(svg);
|
||||||
|
expect(x + w / 2 - c.x).toBeCloseTo(100, 6);
|
||||||
|
expect(y + h / 2 - c.y).toBeCloseTo(40, 6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the minimum size and centers a single node', async () => {
|
it('uses the minimum size and centers a single node', async () => {
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ vi.mock('$app/state', () => ({
|
|||||||
|
|
||||||
const replaceState = vi.fn();
|
const replaceState = vi.fn();
|
||||||
vi.mock('$app/navigation', () => ({
|
vi.mock('$app/navigation', () => ({
|
||||||
replaceState: (...args: unknown[]) => replaceState(...args)
|
replaceState: (...args: unknown[]) => replaceState(...args),
|
||||||
|
// StammbaumSidePanel (rendered transitively) imports invalidateAll/goto, so
|
||||||
|
// the mock must provide every export the module graph uses.
|
||||||
|
invalidateAll: vi.fn(),
|
||||||
|
goto: vi.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(cleanup);
|
afterEach(cleanup);
|
||||||
|
|||||||
Reference in New Issue
Block a user