From 3fd13805e8b302333c32892ab89c6de5f9df250f Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Thu, 3 Apr 2025 16:32:36 +0200 Subject: [PATCH] Add alt-drag bound arrow test Signed-off-by: Mark Tolmacs --- packages/element/tests/duplicate.test.tsx | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/element/tests/duplicate.test.tsx b/packages/element/tests/duplicate.test.tsx index d3b5cee96..7492bcc58 100644 --- a/packages/element/tests/duplicate.test.tsx +++ b/packages/element/tests/duplicate.test.tsx @@ -14,7 +14,7 @@ import { actionDuplicateSelection } from "@excalidraw/excalidraw/actions"; import { API } from "@excalidraw/excalidraw/tests/helpers/api"; -import { Keyboard, Pointer } from "@excalidraw/excalidraw/tests/helpers/ui"; +import { UI, Keyboard, Pointer } from "@excalidraw/excalidraw/tests/helpers/ui"; import { act, @@ -699,4 +699,34 @@ describe("duplication z-order", () => { { id: text.id, containerId: arrow.id, selected: true }, ]); }); + + it("reverse-duplicating bindable element with bound arrow should keep the arrow on the duplicate", () => { + const rect = UI.createElement("rectangle", { + x: 0, + y: 0, + width: 100, + height: 100, + }); + + const arrow = UI.createElement("arrow", { + x: -100, + y: 50, + width: 95, + height: 0, + }); + + expect(arrow.endBinding?.elementId).toBe(rect.id); + + Keyboard.withModifierKeys({ alt: true }, () => { + mouse.down(5, 5); + mouse.up(15, 15); + }); + + expect(window.h.elements).toHaveLength(3); + + const newRect = window.h.elements[0]; + + expect(arrow.endBinding?.elementId).toBe(newRect.id); + expect(newRect.boundElements?.[0]?.id).toBe(arrow.id); + }); });