From 6ec259a0e71174651bae95d4628138bf6fd68742 Mon Sep 17 00:00:00 2001
From: kj_sh604
Date: Sun, 15 Mar 2026 16:19:35 -0400
Subject: refactor: packages/
---
.../excalidraw/actions/actionElementLock.test.tsx | 69 ++++++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 packages/excalidraw/actions/actionElementLock.test.tsx
(limited to 'packages/excalidraw/actions/actionElementLock.test.tsx')
diff --git a/packages/excalidraw/actions/actionElementLock.test.tsx b/packages/excalidraw/actions/actionElementLock.test.tsx
new file mode 100644
index 0000000..d6dd3f7
--- /dev/null
+++ b/packages/excalidraw/actions/actionElementLock.test.tsx
@@ -0,0 +1,69 @@
+import React from "react";
+import { Excalidraw } from "../index";
+import { queryByTestId, fireEvent } from "@testing-library/react";
+import { render } from "../tests/test-utils";
+import { Pointer, UI } from "../tests/helpers/ui";
+import { API } from "../tests/helpers/api";
+
+const { h } = window;
+const mouse = new Pointer("mouse");
+
+describe("element locking", () => {
+ it("should not show unlockAllElements action in contextMenu if no elements locked", async () => {
+ await render();
+
+ mouse.rightClickAt(0, 0);
+
+ const item = queryByTestId(UI.queryContextMenu()!, "unlockAllElements");
+ expect(item).toBe(null);
+ });
+
+ it("should unlock all elements and select them when using unlockAllElements action in contextMenu", async () => {
+ await render(
+ ,
+ );
+
+ mouse.rightClickAt(0, 0);
+
+ expect(Object.keys(h.state.selectedElementIds).length).toBe(0);
+ expect(h.elements.map((el) => el.locked)).toEqual([true, true, false]);
+
+ const item = queryByTestId(UI.queryContextMenu()!, "unlockAllElements");
+ expect(item).not.toBe(null);
+
+ fireEvent.click(item!.querySelector("button")!);
+
+ expect(h.elements.map((el) => el.locked)).toEqual([false, false, false]);
+ // should select the unlocked elements
+ expect(h.state.selectedElementIds).toEqual({
+ [h.elements[0].id]: true,
+ [h.elements[1].id]: true,
+ });
+ });
+});
--
cgit v1.2.3