task(A4.9): migrate event domain tools (chair/row/block/table/stage) to v2
This commit is contained in:
@@ -6,8 +6,9 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { lineTool, coreDrawingPlugin } from '../src/plugins/builtin/core-drawing';
|
||||
import { selectTool, coreModifyPlugin } from '../src/plugins/builtin/core-modify';
|
||||
import { coreMeasurePlugin } from '../src/plugins/builtin/core-measure';
|
||||
import { coreAnnotatePlugin } from '../src/plugins/builtin/core-annotate';
|
||||
import { coreMeasurePlugin } from '../src/plugins/builtin/core-measure';
|
||||
import { eventToolsV2Plugin } from '../src/plugins/builtin/event-tools';
|
||||
import { CADDocument } from '../src/kernel/document/CADDocument';
|
||||
import { createInMemoryDoc } from './helpers/inMemoryDoc';
|
||||
import type { ToolPointerEvent, FullToolContext } from '../src/plugins/types';
|
||||
@@ -348,6 +349,58 @@ describe('A4.5 pilot: hatch tool', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('A4.9 pilot: event tools', () => {
|
||||
it('chair platziert Einzel-Element per Klick', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const ctx = makeCtx({ doc });
|
||||
const chair = eventToolsV2Plugin.tools!.find((t) => t.manifest.id === 'chair')!;
|
||||
|
||||
chair.handlers.down!(pe(100, 200), ctx);
|
||||
const all = doc.getAllElements();
|
||||
expect(all.length).toBe(1);
|
||||
expect(all[0].type).toBe('chair');
|
||||
expect(all[0].x).toBe(100);
|
||||
expect(all[0].y).toBe(200);
|
||||
});
|
||||
|
||||
it('seating-block erzeugt rows×cols Elemente in EINER Transaktion (ein undo = ganzer Block weg)', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const ctx = makeCtx({ doc });
|
||||
const block = eventToolsV2Plugin.tools!.find((t) => t.manifest.id === 'seating-block')!;
|
||||
|
||||
block.handlers.down!(pe(0, 0), ctx); // Legacy-Default: rows=3, cols=8
|
||||
const all = doc.getAllElements();
|
||||
expect(all.length).toBeGreaterThan(1); // Multi-Element-Satz
|
||||
expect(all.every((e) => e.type === 'chair')).toBe(true);
|
||||
|
||||
// BUG-1-Regressionsschutz: alle Reihen im Block haben eigene rowIds
|
||||
const rowIds = new Set(all.map((e) => e.properties.rowId));
|
||||
expect(rowIds.size).toBeGreaterThanOrEqual(3);
|
||||
|
||||
// Kern-Akzeptanz: EIN undo entfernt den GANZEN Block
|
||||
expect(doc.undo()).toBe(true);
|
||||
expect(doc.getAllElements().length).toBe(0);
|
||||
});
|
||||
|
||||
it('seating-row platziert mehrere Stühle mit gemeinsamer rowId; undo entfernt Reihe', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const ctx = makeCtx({ doc });
|
||||
const row = eventToolsV2Plugin.tools!.find((t) => t.manifest.id === 'seating-row')!;
|
||||
|
||||
row.handlers.down!(pe(0, 0), ctx);
|
||||
const all = doc.getAllElements();
|
||||
expect(all.length).toBeGreaterThanOrEqual(2);
|
||||
const rowIds = new Set(all.map((e) => e.properties.rowId));
|
||||
expect(rowIds.size).toBe(1); // eine Reihe → EINE rowId
|
||||
|
||||
expect(doc.undo()).toBe(true);
|
||||
expect(doc.getAllElements().length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('A4.6 pilot: move/copy tools', () => {
|
||||
it('move verschiebt selektierte Elemente in EINER Transaktion (undo entfernt Versatz)', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
|
||||
Reference in New Issue
Block a user