task(CAD-14): phase 4c - legacy interaction engine DELETED (1173 lines), dispatcher is the single engine (native snap/ortho/pan/wheel/cursor), ToolState moved to ui.types

This commit is contained in:
Agent Zero
2026-09-18 08:58:02 +02:00
parent 2b5905506f
commit c244571dd6
7 changed files with 233 additions and 1269 deletions
+13 -5
View File
@@ -12,6 +12,9 @@ import type { ZoomPanController } from '../src/canvas/ZoomPanController';
function makeFakeZoomPan(): ZoomPanController {
return {
screenToWorld: (sx: number, sy: number) => ({ x: sx * 2, y: sy * 3 }),
// CAD-14 Phase 4c: natives Pan/Wheel im Dispatcher (spies für Assertions)
pan: vi.fn(),
zoomAt: vi.fn(),
} as unknown as ZoomPanController;
}
@@ -60,11 +63,12 @@ describe('InteractionDispatcher', () => {
function setup(tool?: ToolExtensionV2) {
canvas = document.createElement('canvas');
document.body.appendChild(canvas);
const zoomPan = makeFakeZoomPan();
const dispatcher = new InteractionDispatcher(canvas, {
zoomPan: makeFakeZoomPan(),
zoomPan,
toolLookup: tool ? () => tool : undefined,
});
return { dispatcher };
return { dispatcher, zoomPan };
}
it('routet down→move→up in Reihenfolge an das aktive Tool', () => {
@@ -103,13 +107,17 @@ describe('InteractionDispatcher', () => {
expect(log).toEqual(['down', 'cancel']);
});
it('Rechtsklick bricht ab, ohne down durchzureichen', () => {
it('Rechtsklick startet natives Pan (kein Tool-Event)', () => {
const { tool, log } = makeRecordingTool();
const { dispatcher } = setup(tool);
const { dispatcher, zoomPan } = setup(tool);
dispatcher.setActive('fake');
fire(canvas, 'pointerdown', { button: 2 });
expect(log).toEqual(['cancel']);
fire(window, 'pointermove', { clientX: 120, clientY: 60 });
fire(window, 'pointerup', { button: 2, clientX: 120, clientY: 60 });
// CAD-14 Phase 4c: Rechtsklick = natives Pan, Tool bleibt unberührt
expect(log).toEqual([]);
expect(zoomPan.pan).toHaveBeenCalled();
});
it('setActive(null) deaktiviert Routing komplett', () => {