task(A4.2): migrate rect tool to v2 plugin
This commit is contained in:
@@ -80,6 +80,46 @@ describe('A3 pilot: line tool', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('A4.2 pilot: rect tool', () => {
|
||||
it('erzeugt Rechteck mit BBox-Konvention; ein undo entfernt es', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const ctx = makeCtx({ doc });
|
||||
const rect = coreDrawingPlugin.tools?.find((t) => t.manifest.id === 'rect');
|
||||
expect(rect).toBeDefined();
|
||||
|
||||
rect!.handlers.down!(pe(10, 10), ctx);
|
||||
rect!.handlers.move!(pe(110, 60), ctx);
|
||||
expect(ctx.previews.length).toBe(1); // Live-Vorschau
|
||||
rect!.handlers.up!(pe(110, 60), ctx);
|
||||
|
||||
const all = doc.getAllElements();
|
||||
expect(all.length).toBe(1);
|
||||
expect(all[0].type).toBe('rect');
|
||||
// Legacy-BBox-Konvention: Zentrum zwischen beiden Ecken
|
||||
expect(all[0].x).toBe(60);
|
||||
expect(all[0].y).toBe(35);
|
||||
expect(all[0].width).toBe(100);
|
||||
expect(all[0].height).toBe(50);
|
||||
|
||||
expect(doc.undo()).toBe(true);
|
||||
expect(doc.getAllElements().length).toBe(0);
|
||||
});
|
||||
|
||||
it('cancel verwirft das laufende Rechteck', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const ctx = makeCtx({ doc });
|
||||
const rect = coreDrawingPlugin.tools!.find((t) => t.manifest.id === 'rect')!;
|
||||
|
||||
rect.handlers.down!(pe(5, 5), ctx);
|
||||
rect.handlers.cancel!(ctx);
|
||||
rect.handlers.up!(pe(50, 50), ctx);
|
||||
|
||||
expect(doc.getAllElements().length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('A3 pilot: select tool', () => {
|
||||
function makeBridge(elements: CADElement[]) {
|
||||
let ids: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user