test(stammbaum): assert drag-pan before release to avoid inertia flake (#692)
Read the pan emission from the pointermove (deterministic) instead of the post-pointerup last call, which inertia could perturb when reduced-motion is not forced in vitest-browser (QA blocker). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -568,12 +568,15 @@ describe('StammbaumTree keyboard pan/zoom (#692)', () => {
|
|||||||
const opts = (x: number) => ({ pointerId: 1, clientX: x, clientY: 100, bubbles: true });
|
const opts = (x: number) => ({ pointerId: 1, clientX: x, clientY: 100, bubbles: true });
|
||||||
svg.dispatchEvent(new PointerEvent('pointerdown', opts(100)));
|
svg.dispatchEvent(new PointerEvent('pointerdown', opts(100)));
|
||||||
svg.dispatchEvent(new PointerEvent('pointermove', opts(160)));
|
svg.dispatchEvent(new PointerEvent('pointermove', opts(160)));
|
||||||
svg.dispatchEvent(new PointerEvent('pointerup', opts(160)));
|
|
||||||
|
|
||||||
|
// Assert on the move's emission *before* releasing: inertia starts on
|
||||||
|
// pointerup and could otherwise perturb the last recorded call.
|
||||||
expect(onPanZoom).toHaveBeenCalled();
|
expect(onPanZoom).toHaveBeenCalled();
|
||||||
// Dragging right reveals content to the left → pan x decreases.
|
// Dragging right reveals content to the left → pan x decreases.
|
||||||
expect(onPanZoom.mock.calls.at(-1)![0].x).toBeLessThan(0);
|
expect(onPanZoom.mock.calls.at(-1)![0].x).toBeLessThan(0);
|
||||||
|
|
||||||
|
svg.dispatchEvent(new PointerEvent('pointerup', opts(160)));
|
||||||
|
|
||||||
// The synthetic click after a real drag must not select the node.
|
// The synthetic click after a real drag must not select the node.
|
||||||
node.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
node.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
||||||
expect(onSelect).not.toHaveBeenCalled();
|
expect(onSelect).not.toHaveBeenCalled();
|
||||||
|
|||||||
Reference in New Issue
Block a user