Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

test: fix failing tests and API (#5823)

Aakansha Doshi25ea97d0f9aa
diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx
index 2cf20d01b6..2cefeed569 100644
--- a/src/components/LayerUI.tsx
+++ b/src/components/LayerUI.tsx
@@ -196,6 +196,7 @@ const LayerUI = ({
})}
onClick={() => setIsMenuOpen(!isMenuOpen)}
type="button"
+ data-testid="menu-button"
>
{HamburgerMenuIcon}
</button>
@@ -220,13 +221,15 @@ const LayerUI = ({
{appState.fileHandle &&
actionManager.renderAction("saveToActiveFile")}
{renderJSONExportDialog()}
- <MenuItem
- label={t("buttons.exportImage")}
- icon={ExportImageIcon}
- dataTestId="image-export-button"
- onClick={() => setAppState({ openDialog: "imageExport" })}
- shortcut={getShortcutFromShortcutName("imageExport")}
- />
+ {UIOptions.canvasActions.saveAsImage && (
+ <MenuItem
+ label={t("buttons.exportImage")}
+ icon={ExportImageIcon}
+ dataTestId="image-export-button"
+ onClick={() => setAppState({ openDialog: "imageExport" })}
+ shortcut={getShortcutFromShortcutName("imageExport")}
+ />
+ )}
{onCollabButtonClick && (
<CollabButton
isCollaborating={isCollaborating}
diff --git a/src/components/Sidebar/Sidebar.test.tsx b/src/components/Sidebar/Sidebar.test.tsx
index 542573e156..b79e67f7c8 100644
--- a/src/components/Sidebar/Sidebar.test.tsx
+++ b/src/components/Sidebar/Sidebar.test.tsx
@@ -90,10 +90,10 @@ describe("Sidebar", () => {
const sidebar = container.querySelector<HTMLElement>(".test-sidebar");
expect(sidebar).not.toBe(null);
- const closeButton = queryByTestId(sidebar!, "sidebar-close");
+ const closeButton = queryByTestId(sidebar!, "sidebar-close")!;
expect(closeButton).not.toBe(null);
- fireEvent.click(closeButton!.querySelector("button")!);
+ fireEvent.click(closeButton);
await waitFor(() => {
expect(container.querySelector<HTMLElement>(".test-sidebar")).toBe(null);
expect(onClose).toHaveBeenCalled();
diff --git a/src/setupTests.ts b/src/setupTests.ts
index cb401838e6..698b2d4cee 100644
--- a/src/setupTests.ts
+++ b/src/setupTests.ts
@@ -3,6 +3,8 @@ import "jest-canvas-mock";
import dotenv from "dotenv";
import polyfill from "./polyfill";
+require("fake-indexeddb/auto");
+
polyfill();
// jest doesn't know of .env.development so we need to init it ourselves
dotenv.config({
diff --git a/src/tests/__snapshots__/regressionTests.test.tsx.snap b/src/tests/__snapshots__/regressionTests.test.tsx.snap
index 68ae317877..7cc38fbcd6 100644
--- a/src/tests/__snapshots__/regressionTests.test.tsx.snap
+++ b/src/tests/__snapshots__/regressionTests.test.tsx.snap
@@ -1951,7 +1951,9 @@ Object {
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
- "previousSelectedElementIds": Object {},
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ },
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
@@ -1988,7 +1990,7 @@ Object {
"boundElements": null,
"fillStyle": "hachure",
"groupIds": Array [],
- "height": 15,
+ "height": 10,
"id": "id0",
"isDeleted": false,
"link": null,
@@ -2004,9 +2006,9 @@ Object {
"updated": 1,
"version": 3,
"versionNonce": 453191,
- "width": 15,
- "x": 10,
- "y": 10,
+ "width": 10,
+ "x": 25,
+ "y": 25,
}
`;
@@ -2085,7 +2087,7 @@ Object {
"boundElements": null,
"fillStyle": "hachure",
"groupIds": Array [],
- "height": 15,
+ "height": 10,
"id": "id0",
"isDeleted": false,
"link": null,
@@ -2101,9 +2103,9 @@ Object {
"updated": 1,
"version": 3,
"versionNonce": 453191,
- "width": 15,
- "x": 10,
- "y": 10,
+ "width": 10,
+ "x": 25,
+ "y": 25,
},
],
},
@@ -2682,7 +2684,9 @@ Object {
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
- "previousSelectedElementIds": Object {},
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ },
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
@@ -2720,27 +2724,56 @@ Object {
"fillStyle": "hachure",
"groupIds": Array [],
"height": 10,
- "id": "id0",
+ "id": "id0_copy",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
- "seed": 337897,
+ "seed": 401146281,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"updated": 1,
- "version": 2,
- "versionNonce": 1278240551,
+ "version": 4,
+ "versionNonce": 2019559783,
"width": 10,
"x": 10,
"y": 10,
}
`;
+exports[`regression tests alt-drag duplicates an element: [end of test] element 1 1`] = `
+Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 3,
+ "versionNonce": 453191,
+ "width": 10,
+ "x": 20,
+ "y": 20,
+}
+`;
+
exports[`regression tests alt-drag duplicates an element: [end of test] history 1`] = `
Object {
"recording": false,
@@ -2797,11 +2830,78 @@ Object {
},
],
},
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ },
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0_copy",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 401146281,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 4,
+ "versionNonce": 2019559783,
+ "width": 10,
+ "x": 10,
+ "y": 10,
+ },
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 3,
+ "versionNonce": 453191,
+ "width": 10,
+ "x": 20,
+ "y": 20,
+ },
+ ],
+ },
],
}
`;
-exports[`regression tests alt-drag duplicates an element: [end of test] number of elements 1`] = `1`;
+exports[`regression tests alt-drag duplicates an element: [end of test] number of elements 1`] = `2`;
exports[`regression tests alt-drag duplicates an element: [end of test] number of renders 1`] = `12`;
@@ -3737,6 +3837,230 @@ exports[`regression tests change the properties of a shape: [end of test] number
exports[`regression tests change the properties of a shape: [end of test] number of renders 1`] = `15`;
+exports[`regression tests click on an element and drag it: [dragged] appState 1`] = `
+Object {
+ "activeTool": Object {
+ "customType": null,
+ "lastActiveToolBeforeEraser": null,
+ "locked": false,
+ "type": "selection",
+ },
+ "collaborators": Map {},
+ "currentChartType": "bar",
+ "currentItemBackgroundColor": "transparent",
+ "currentItemEndArrowhead": "arrow",
+ "currentItemFillStyle": "hachure",
+ "currentItemFontFamily": 1,
+ "currentItemFontSize": 20,
+ "currentItemLinearStrokeSharpness": "round",
+ "currentItemOpacity": 100,
+ "currentItemRoughness": 1,
+ "currentItemStartArrowhead": null,
+ "currentItemStrokeColor": "#000000",
+ "currentItemStrokeSharpness": "sharp",
+ "currentItemStrokeStyle": "solid",
+ "currentItemStrokeWidth": 1,
+ "currentItemTextAlign": "left",
+ "cursorButton": "up",
+ "draggingElement": null,
+ "editingElement": null,
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "errorMessage": null,
+ "exportBackground": true,
+ "exportEmbedScene": false,
+ "exportScale": 1,
+ "exportWithDarkMode": false,
+ "fileHandle": null,
+ "gridSize": null,
+ "height": 768,
+ "isBindingEnabled": true,
+ "isLoading": false,
+ "isResizing": false,
+ "isRotating": false,
+ "isSidebarDocked": false,
+ "lastPointerDownWith": "mouse",
+ "multiElement": null,
+ "name": "Untitled-201933152653",
+ "offsetLeft": 0,
+ "offsetTop": 0,
+ "openDialog": null,
+ "openMenu": null,
+ "openPopup": null,
+ "openSidebar": null,
+ "pasteDialog": Object {
+ "data": null,
+ "shown": false,
+ },
+ "penDetected": false,
+ "penMode": false,
+ "pendingImageElementId": null,
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ },
+ "resizingElement": null,
+ "scrollX": 0,
+ "scrollY": 0,
+ "scrolledOutside": false,
+ "selectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ },
+ "selectedGroupIds": Object {},
+ "selectedLinearElement": null,
+ "selectionElement": null,
+ "shouldCacheIgnoreZoom": false,
+ "showHyperlinkPopup": false,
+ "showStats": false,
+ "showWelcomeScreen": true,
+ "startBoundElement": null,
+ "suggestedBindings": Array [],
+ "theme": "light",
+ "toast": null,
+ "viewBackgroundColor": "#ffffff",
+ "viewModeEnabled": false,
+ "width": 1024,
+ "zenModeEnabled": false,
+ "zoom": Object {
+ "value": 1,
+ },
+}
+`;
+
+exports[`regression tests click on an element and drag it: [dragged] element 0 1`] = `
+Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 3,
+ "versionNonce": 453191,
+ "width": 10,
+ "x": 20,
+ "y": 20,
+}
+`;
+
+exports[`regression tests click on an element and drag it: [dragged] history 1`] = `
+Object {
+ "recording": false,
+ "redoStack": Array [],
+ "stateHistory": Array [
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {},
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [],
+ },
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {
+ "id0": true,
+ },
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 2,
+ "versionNonce": 1278240551,
+ "width": 10,
+ "x": 10,
+ "y": 10,
+ },
+ ],
+ },
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ },
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 3,
+ "versionNonce": 453191,
+ "width": 10,
+ "x": 20,
+ "y": 20,
+ },
+ ],
+ },
+ ],
+}
+`;
+
+exports[`regression tests click on an element and drag it: [dragged] number of elements 1`] = `1`;
+
+exports[`regression tests click on an element and drag it: [dragged] number of renders 1`] = `12`;
+
exports[`regression tests click on an element and drag it: [end of test] appState 1`] = `
Object {
"activeTool": Object {
@@ -3795,7 +4119,10 @@ Object {
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
- "previousSelectedElementIds": Object {},
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ },
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
@@ -3803,6 +4130,7 @@ Object {
"selectedElementIds": Object {
"id0": true,
"id1": true,
+ "id2": true,
},
"selectedGroupIds": Object {},
"selectedLinearElement": null,
@@ -3846,8 +4174,8 @@ Object {
"strokeWidth": 1,
"type": "rectangle",
"updated": 1,
- "version": 2,
- "versionNonce": 1278240551,
+ "version": 4,
+ "versionNonce": 2019559783,
"width": 10,
"x": 10,
"y": 10,
@@ -3910,13 +4238,96 @@ Object {
},
],
},
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ },
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 3,
+ "versionNonce": 453191,
+ "width": 10,
+ "x": 20,
+ "y": 20,
+ },
+ ],
+ },
+ Object {
+ "appState": Object {
+ "editingGroupId": null,
+ "editingLinearElement": null,
+ "name": "Untitled-201933152653",
+ "selectedElementIds": Object {
+ "id0": true,
+ "id1": true,
+ "id2": true,
+ },
+ "selectedGroupIds": Object {},
+ "viewBackgroundColor": "#ffffff",
+ },
+ "elements": Array [
+ Object {
+ "angle": 0,
+ "backgroundColor": "transparent",
+ "boundElements": null,
+ "fillStyle": "hachure",
+ "groupIds": Array [],
+ "height": 10,
+ "id": "id0",
+ "isDeleted": false,
+ "link": null,
+ "locked": false,
+ "opacity": 100,
+ "roughness": 1,
+ "seed": 337897,
+ "strokeColor": "#000000",
+ "strokeSharpness": "sharp",
+ "strokeStyle": "solid",
+ "strokeWidth": 1,
+ "type": "rectangle",
+ "updated": 1,
+ "version": 4,
+ "versionNonce": 2019559783,
+ "width": 10,
+ "x": 10,
+ "y": 10,
+ },
+ ],
+ },
],
}
`;
exports[`regression tests click on an element and drag it: [end of test] number of elements 1`] = `1`;
-exports[`regression tests click on an element and drag it: [end of test] number of renders 1`] = `12`;
+exports[`regression tests click on an element and drag it: [end of test] number of renders 1`] = `15`;
exports[`regression tests click to select a shape: [end of test] appState 1`] = `
Object {
@@ -5513,13 +5924,14 @@ Object {
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
- "previousSelectedElementIds": Object {},
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ },
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": Object {
- "id0": true,
"id1": true,
},
"selectedGroupIds": Object {},
@@ -13700,7 +14112,7 @@ Object {
exports[`regression tests rerenders UI on language change: [end of test] number of elements 1`] = `0`;
-exports[`regression tests rerenders UI on language change: [end of test] number of renders 1`] = `6`;
+exports[`regression tests rerenders UI on language change: [end of test] number of renders 1`] = `10`;
exports[`regression tests shift click on selected element should deselect it on pointer up: [end of test] appState 1`] = `
Object {
@@ -13760,13 +14172,15 @@ Object {
"penDetected": false,
"penMode": false,
"pendingImageElementId": null,
- "previousSelectedElementIds": Object {},
+ "previousSelectedElementIds": Object {
+ "id0": true,
+ },
"resizingElement": null,
"scrollX": 0,
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": Object {
- "id0": true,
+ "id0": false,
"id1": true,
},
"selectedGroupIds": Object {},
diff --git a/src/tests/dragCreate.test.tsx b/src/tests/dragCreate.test.tsx
index b39601eb52..4e69f1ab81 100644
--- a/src/tests/dragCreate.test.tsx
+++ b/src/tests/dragCreate.test.tsx
@@ -42,7 +42,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
@@ -73,7 +73,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
@@ -104,7 +104,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
@@ -135,7 +135,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
@@ -170,7 +170,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
@@ -210,7 +210,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(0);
});
@@ -229,7 +229,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(0);
});
@@ -248,7 +248,7 @@ describe("Test dragCreate", () => {
// finish (position does not matter)
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(0);
});
@@ -272,7 +272,7 @@ describe("Test dragCreate", () => {
key: KEYS.ENTER,
});
- expect(renderScene).toHaveBeenCalledTimes(7);
+ expect(renderScene).toHaveBeenCalledTimes(8);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(0);
});
@@ -296,7 +296,7 @@ describe("Test dragCreate", () => {
key: KEYS.ENTER,
});
- expect(renderScene).toHaveBeenCalledTimes(7);
+ expect(renderScene).toHaveBeenCalledTimes(8);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(0);
});
diff --git a/src/tests/library.test.tsx b/src/tests/library.test.tsx
index 1013675d7e..6b3ff5dd77 100644
--- a/src/tests/library.test.tsx
+++ b/src/tests/library.test.tsx
@@ -1,4 +1,6 @@
import { fireEvent, render, waitFor } from "./test-utils";
+import { queryByTestId } from "@testing-library/react";
+
import ExcalidrawApp from "../excalidraw-app";
import { API } from "./helpers/api";
import { MIME_TYPES } from "../constants";
@@ -93,15 +95,11 @@ describe("library menu", () => {
const latestLibrary = await h.app.library.getLatestLibrary();
expect(latestLibrary.length).toBe(0);
- const libraryButton = container.querySelector(".ToolIcon__library");
+ const libraryButton = container.querySelector(".library-button");
fireEvent.click(libraryButton!);
-
- const loadLibraryButton = container.querySelector(
- ".library-actions .library-actions--load",
- );
-
- fireEvent.click(loadLibraryButton!);
+ fireEvent.click(container.querySelector(".Sidebar__dropdown-btn")!);
+ queryByTestId(container, "lib-dropdown--load")!.click();
const libraryItems = parseLibraryJSON(await libraryJSONPromise);
diff --git a/src/tests/move.test.tsx b/src/tests/move.test.tsx
index 7a35dcdbf9..3fbfceee32 100644
--- a/src/tests/move.test.tsx
+++ b/src/tests/move.test.tsx
@@ -38,7 +38,7 @@ describe("move element", () => {
fireEvent.pointerMove(canvas, { clientX: 60, clientY: 70 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
@@ -77,7 +77,7 @@ describe("move element", () => {
// select the second rectangles
new Pointer("mouse").clickOn(rectB);
- expect(renderScene).toHaveBeenCalledTimes(22);
+ expect(renderScene).toHaveBeenCalledTimes(23);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(3);
expect(h.state.selectedElementIds[rectB.id]).toBeTruthy();
@@ -120,7 +120,7 @@ describe("duplicate element on move when ALT is clicked", () => {
fireEvent.pointerMove(canvas, { clientX: 60, clientY: 70 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(8);
+ expect(renderScene).toHaveBeenCalledTimes(9);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
diff --git a/src/tests/multiPointCreate.test.tsx b/src/tests/multiPointCreate.test.tsx
index 7437a1d486..0026041c7d 100644
--- a/src/tests/multiPointCreate.test.tsx
+++ b/src/tests/multiPointCreate.test.tsx
@@ -42,7 +42,7 @@ describe("remove shape in non linear elements", () => {
fireEvent.pointerDown(canvas, { clientX: 30, clientY: 20 });
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.elements.length).toEqual(0);
});
@@ -56,7 +56,7 @@ describe("remove shape in non linear elements", () => {
fireEvent.pointerDown(canvas, { clientX: 30, clientY: 20 });
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.elements.length).toEqual(0);
});
@@ -70,7 +70,7 @@ describe("remove shape in non linear elements", () => {
fireEvent.pointerDown(canvas, { clientX: 30, clientY: 20 });
fireEvent.pointerUp(canvas, { clientX: 30, clientY: 30 });
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.elements.length).toEqual(0);
});
});
@@ -102,7 +102,7 @@ describe("multi point mode in linear elements", () => {
key: KEYS.ENTER,
});
- expect(renderScene).toHaveBeenCalledTimes(14);
+ expect(renderScene).toHaveBeenCalledTimes(15);
expect(h.elements.length).toEqual(1);
const element = h.elements[0] as ExcalidrawLinearElement;
@@ -145,7 +145,7 @@ describe("multi point mode in linear elements", () => {
key: KEYS.ENTER,
});
- expect(renderScene).toHaveBeenCalledTimes(14);
+ expect(renderScene).toHaveBeenCalledTimes(15);
expect(h.elements.length).toEqual(1);
const element = h.elements[0] as ExcalidrawLinearElement;
diff --git a/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap b/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap
index 0d8e27282e..2fbca53454 100644
--- a/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap
+++ b/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap
@@ -11,138 +11,420 @@ exports[`<Excalidraw/> Test UIOptions prop Test canvasActions should not hide an
Canvas actions
</h2>
<div
- class="Stack Stack_vertical zoom-actions"
- style="--gap: 1;"
+ class="Island menu-container"
+ style="--padding: 2; z-index: 1;"
>
- <div
- class="Stack Stack_horizontal"
- style="align-items: center;"
+ <button
+ aria-label="Open"
+ class="menu-item"
+ data-testid="load-button"
+ title="Open"
+ type="button"
>
- <button
- aria-label="Zoom out"
- class="ToolIcon_type_button ToolIcon_size_medium zoom-out-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Zoom out — Ctrl+-"
- type="button"
+ <div
+ class="menu-item__icon"
>
- <div
+ <svg
aria-hidden="true"
- class="ToolIcon__icon"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
>
- <svg
- aria-hidden="true"
- class=""
- fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M5 10h10"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
+ <path
+ d="m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
<div
- class="excalidraw-tooltip-wrapper"
- style="height: 100%;"
+ class="menu-item__text"
>
- <button
- aria-label="Reset zoom"
- class="ToolIcon_type_button ToolIcon_size_medium reset-zoom-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Reset zoom"
- type="button"
+ Open
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Ctrl+O
+ </div>
+ </button>
+ <button
+ aria-label="Save to..."
+ class="menu-item"
+ data-testid="json-export-button"
+ title="Save to..."
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
>
- 100
- %
- </button>
+ <path
+ d="M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"
+ stroke-width="1.25"
+ />
+ </svg>
</div>
- <button
- aria-label="Zoom in"
- class="ToolIcon_type_button ToolIcon_size_medium zoom-in-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Zoom in — Ctrl++"
- type="button"
+ <div
+ class="menu-item__text"
>
- <div
+ Save to...
+ </div>
+ </button>
+ <button
+ aria-label="Export image..."
+ class="menu-item"
+ data-testid="image-export-button"
+ title="Export image..."
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
aria-hidden="true"
- class="ToolIcon__icon"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
>
- <svg
- aria-hidden="true"
- class=""
- fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M10 4.167v11.666M4.167 10h11.666"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
- </div>
- </div>
- <div
- class="undo-redo-buttons zen-mode-transition"
- >
- <div
- class="undo-button-container"
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <path
+ d="M15 8h.01"
+ />
+ <path
+ d="M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"
+ />
+ <path
+ d="M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"
+ />
+ <path
+ d="M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"
+ />
+ <path
+ d="M19 16v6"
+ />
+ <path
+ d="M22 19l-3 3l-3 -3"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Export image...
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Ctrl+Shift+E
+ </div>
+ </button>
+ <button
+ aria-label="Help"
+ class="menu-item"
+ data-testid="help-menu-item"
+ title="Help"
+ type="button"
>
<div
- class="excalidraw-tooltip-wrapper"
+ class="menu-item__icon"
>
- <button
- aria-label="Undo"
- class="ToolIcon_type_button ToolIcon_size_medium ToolIcon_type_button--show ToolIcon"
- type="button"
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
>
- <div
- aria-hidden="true"
- class="ToolIcon__icon"
+ <g
+ stroke-width="1.5"
>
- <svg
- aria-hidden="true"
- class=""
+ <path
+ d="M0 0h24v24H0z"
fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
+ stroke="none"
+ />
+ <circle
+ cx="12"
+ cy="12"
+ r="9"
+ />
+ <line
+ x1="12"
+ x2="12"
+ y1="17"
+ y2="17.01"
+ />
+ <path
+ d="M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"
+ />
+ </g>
+ </svg>
</div>
- </div>
+ <div
+ class="menu-item__text"
+ >
+ Help
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ ?
+ </div>
+ </button>
+ <button
+ aria-label="Reset the canvas"
+ class="menu-item"
+ data-testid="clear-canvas-button"
+ title="Reset the canvas"
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <path
+ d="M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Reset the canvas
+ </div>
+ </button>
<div
- class="redo-button-container"
+ style="height: 1px; margin: .5rem 0px;"
+ />
+ <a
+ class="menu-item"
+ href="https://plus.excalidraw.com/plus?utm_source=excalidraw&utm_medium=app&utm_content=hamburger"
+ rel="noreferrer"
+ target="_blank"
>
<div
- class="excalidraw-tooltip-wrapper"
+ class="menu-item__icon"
>
-
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
+ >
+ <g
+ stroke-width="1.5"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <rect
+ height="4"
+ rx="1"
+ width="18"
+ x="3"
+ y="8"
+ />
+ <line
+ x1="12"
+ x2="12"
+ y1="8"
+ y2="21"
+ />
+ <path
+ d="M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"
+ />
+ <path
+ d="M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Excalidraw+
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://github.com/excalidraw/excalidraw"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <path
+ d="M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ GitHub
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://discord.gg/UexuTaE"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"
+ />
+ <path
+ d="M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Discord
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://twitter.com/excalidraw"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
+ >
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <path
+ d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c-.002 -.249 1.51 -2.772 1.818 -4.013z"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Twitter
+ </div>
+ </a>
+ <div
+ style="height: 1px; margin: .5rem 0px;"
+ />
+ <div
+ style="display: flex; flex-direction: column; row-gap: .5rem;"
+ >
+ <div>
<button
- aria-label="Redo"
- class="ToolIcon_type_button ToolIcon_size_medium ToolIcon_type_button--show ToolIcon"
+ aria-label="Dark mode"
+ class="menu-item"
+ data-testid="toggle-dark-mode"
+ title="Dark mode"
type="button"
>
<div
- aria-hidden="true"
- class="ToolIcon__icon"
+ class="menu-item__icon"
>
<svg
aria-hidden="true"
@@ -156,13 +438,269 @@ exports[`<Excalidraw/> Test UIOptions prop Test canvasActions should not hide an
viewBox="0 0 20 20"
>
<path
- d="M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5"
- stroke-width="1.25"
+ clip-rule="evenodd"
+ d="M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z"
+ stroke="currentColor"
/>
</svg>
</div>
+ <div
+ class="menu-item__text"
+ >
+ Dark mode
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Shift+Alt+D
+ </div>
</button>
</div>
+ <div
+ style="padding: 0px 0.625rem;"
+ >
+ <select
+ aria-label="Select language"
+ class="dropdown-select dropdown-select__language"
+ style="width: 100%;"
+ >
+ <option
+ value="en"
+ >
+ English
+ </option>
+ <option
+ value="id-ID"
+ >
+ Bahasa Indonesia
+ </option>
+ <option
+ value="ca-ES"
+ >
+ Català
+ </option>
+ <option
+ value="de-DE"
+ >
+ Deutsch
+ </option>
+ <option
+ value="en"
+ >
+ English
+ </option>
+ <option
+ value="es-ES"
+ >
+ Español
+ </option>
+ <option
+ value="eu-ES"
+ >
+ Euskara
+ </option>
+ <option
+ value="fr-FR"
+ >
+ Français
+ </option>
+ <option
+ value="it-IT"
+ >
+ Italiano
+ </option>
+ <option
+ value="ku-TR"
+ >
+ Kurdî
+ </option>
+ <option
+ value="lv-LV"
+ >
+ Latviešu
+ </option>
+ <option
+ value="hu-HU"
+ >
+ Magyar
+ </option>
+ <option
+ value="nl-NL"
+ >
+ Nederlands
+ </option>
+ <option
+ value="nb-NO"
+ >
+ Norsk bokmål
+ </option>
+ <option
+ value="nn-NO"
+ >
+ Norsk nynorsk
+ </option>
+ <option
+ value="oc-FR"
+ >
+ Occitan
+ </option>
+ <option
+ value="pl-PL"
+ >
+ Polski
+ </option>
+ <option
+ value="pt-PT"
+ >
+ Português
+ </option>
+ <option
+ value="pt-BR"
+ >
+ Português Brasileiro
+ </option>
+ <option
+ value="ro-RO"
+ >
+ Română
+ </option>
+ <option
+ value="sk-SK"
+ >
+ Slovenčina
+ </option>
+ <option
+ value="sl-SI"
+ >
+ Slovenščina
+ </option>
+ <option
+ value="fi-FI"
+ >
+ Suomi
+ </option>
+ <option
+ value="sv-SE"
+ >
+ Svenska
+ </option>
+ <option
+ value="kab-KAB"
+ >
+ Taqbaylit
+ </option>
+ <option
+ value="tr-TR"
+ >
+ Türkçe
+ </option>
+ <option
+ value="el-GR"
+ >
+ Ελληνικά
+ </option>
+ <option
+ value="ru-RU"
+ >
+ Русский
+ </option>
+ <option
+ value="uk-UA"
+ >
+ Українська
+ </option>
+ <option
+ value="he-IL"
+ >
+ עברית
+ </option>
+ <option
+ value="ar-SA"
+ >
+ العربية
+ </option>
+ <option
+ value="fa-IR"
+ >
+ فارسی
+ </option>
+ <option
+ value="mr-IN"
+ >
+ मराठी
+ </option>
+ <option
+ value="pa-IN"
+ >
+ ਪੰਜਾਬੀ
+ </option>
+ <option
+ value="ja-JP"
+ >
+ 日本語
+ </option>
+ <option
+ value="zh-CN"
+ >
+ 简体中文
+ </option>
+ <option
+ value="zh-TW"
+ >
+ 繁體中文
+ </option>
+ <option
+ value="ko-KR"
+ >
+ 한국어
+ </option>
+ </select>
+ </div>
+ <div>
+ <div
+ style="font-size: .75rem; margin-bottom: .5rem;"
+ >
+ Canvas background
+ </div>
+ <div
+ style="padding: 0px 0.625rem;"
+ >
+ <div
+ style="position: relative;"
+ >
+ <div>
+ <div
+ class="color-picker-control-container"
+ >
+ <div
+ class="color-picker-label-swatch-container"
+ >
+ <button
+ aria-label="Canvas background"
+ class="color-picker-label-swatch"
+ style="--swatch-color: #ffffff;"
+ />
+ </div>
+ <label
+ class="color-input-container"
+ >
+ <div
+ class="color-picker-hash"
+ >
+ #
+ </div>
+ <input
+ aria-label="Canvas background"
+ class="color-picker-input"
+ spellcheck="false"
+ value="ffffff"
+ />
+ </label>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
</div>
</section>
@@ -179,138 +717,420 @@ exports[`<Excalidraw/> Test UIOptions prop should not hide any UI element when t
Canvas actions
</h2>
<div
- class="Stack Stack_vertical zoom-actions"
- style="--gap: 1;"
+ class="Island menu-container"
+ style="--padding: 2; z-index: 1;"
>
- <div
- class="Stack Stack_horizontal"
- style="align-items: center;"
+ <button
+ aria-label="Open"
+ class="menu-item"
+ data-testid="load-button"
+ title="Open"
+ type="button"
>
- <button
- aria-label="Zoom out"
- class="ToolIcon_type_button ToolIcon_size_medium zoom-out-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Zoom out — Ctrl+-"
- type="button"
+ <div
+ class="menu-item__icon"
>
- <div
+ <svg
aria-hidden="true"
- class="ToolIcon__icon"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
>
- <svg
- aria-hidden="true"
- class=""
- fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M5 10h10"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
+ <path
+ d="m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
<div
- class="excalidraw-tooltip-wrapper"
- style="height: 100%;"
+ class="menu-item__text"
>
- <button
- aria-label="Reset zoom"
- class="ToolIcon_type_button ToolIcon_size_medium reset-zoom-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Reset zoom"
- type="button"
+ Open
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Ctrl+O
+ </div>
+ </button>
+ <button
+ aria-label="Save to..."
+ class="menu-item"
+ data-testid="json-export-button"
+ title="Save to..."
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
>
- 100
- %
- </button>
+ <path
+ d="M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"
+ stroke-width="1.25"
+ />
+ </svg>
</div>
- <button
- aria-label="Zoom in"
- class="ToolIcon_type_button ToolIcon_size_medium zoom-in-button zoom-button ToolIcon_type_button--show ToolIcon"
- title="Zoom in — Ctrl++"
- type="button"
+ <div
+ class="menu-item__text"
>
- <div
+ Save to...
+ </div>
+ </button>
+ <button
+ aria-label="Export image..."
+ class="menu-item"
+ data-testid="image-export-button"
+ title="Export image..."
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
aria-hidden="true"
- class="ToolIcon__icon"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
>
- <svg
- aria-hidden="true"
- class=""
- fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M10 4.167v11.666M4.167 10h11.666"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
- </div>
- </div>
- <div
- class="undo-redo-buttons zen-mode-transition"
- >
- <div
- class="undo-button-container"
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <path
+ d="M15 8h.01"
+ />
+ <path
+ d="M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"
+ />
+ <path
+ d="M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"
+ />
+ <path
+ d="M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"
+ />
+ <path
+ d="M19 16v6"
+ />
+ <path
+ d="M22 19l-3 3l-3 -3"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Export image...
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Ctrl+Shift+E
+ </div>
+ </button>
+ <button
+ aria-label="Help"
+ class="menu-item"
+ data-testid="help-menu-item"
+ title="Help"
+ type="button"
>
<div
- class="excalidraw-tooltip-wrapper"
+ class="menu-item__icon"
>
- <button
- aria-label="Undo"
- class="ToolIcon_type_button ToolIcon_size_medium ToolIcon_type_button--show ToolIcon"
- type="button"
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
>
- <div
- aria-hidden="true"
- class="ToolIcon__icon"
+ <g
+ stroke-width="1.5"
>
- <svg
- aria-hidden="true"
- class=""
+ <path
+ d="M0 0h24v24H0z"
fill="none"
- focusable="false"
- role="img"
- stroke="currentColor"
- stroke-linecap="round"
- stroke-linejoin="round"
- viewBox="0 0 20 20"
- >
- <path
- d="M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5"
- stroke-width="1.25"
- />
- </svg>
- </div>
- </button>
+ stroke="none"
+ />
+ <circle
+ cx="12"
+ cy="12"
+ r="9"
+ />
+ <line
+ x1="12"
+ x2="12"
+ y1="17"
+ y2="17.01"
+ />
+ <path
+ d="M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"
+ />
+ </g>
+ </svg>
</div>
- </div>
+ <div
+ class="menu-item__text"
+ >
+ Help
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ ?
+ </div>
+ </button>
+ <button
+ aria-label="Reset the canvas"
+ class="menu-item"
+ data-testid="clear-canvas-button"
+ title="Reset the canvas"
+ type="button"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <path
+ d="M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Reset the canvas
+ </div>
+ </button>
<div
- class="redo-button-container"
+ style="height: 1px; margin: .5rem 0px;"
+ />
+ <a
+ class="menu-item"
+ href="https://plus.excalidraw.com/plus?utm_source=excalidraw&utm_medium=app&utm_content=hamburger"
+ rel="noreferrer"
+ target="_blank"
>
<div
- class="excalidraw-tooltip-wrapper"
+ class="menu-item__icon"
>
-
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
+ >
+ <g
+ stroke-width="1.5"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <rect
+ height="4"
+ rx="1"
+ width="18"
+ x="3"
+ y="8"
+ />
+ <line
+ x1="12"
+ x2="12"
+ y1="8"
+ y2="21"
+ />
+ <path
+ d="M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"
+ />
+ <path
+ d="M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Excalidraw+
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://github.com/excalidraw/excalidraw"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <path
+ d="M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5"
+ stroke-width="1.25"
+ />
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ GitHub
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://discord.gg/UexuTaE"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ viewBox="0 0 20 20"
+ >
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"
+ />
+ <path
+ d="M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Discord
+ </div>
+ </a>
+ <a
+ class="menu-item"
+ href="https://twitter.com/excalidraw"
+ rel="noopener noreferrer"
+ target="_blank"
+ >
+ <div
+ class="menu-item__icon"
+ >
+ <svg
+ aria-hidden="true"
+ class=""
+ fill="none"
+ focusable="false"
+ role="img"
+ stroke="currentColor"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ viewBox="0 0 24 24"
+ >
+ <g
+ stroke-width="1.25"
+ >
+ <path
+ d="M0 0h24v24H0z"
+ fill="none"
+ stroke="none"
+ />
+ <path
+ d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c-.002 -.249 1.51 -2.772 1.818 -4.013z"
+ />
+ </g>
+ </svg>
+ </div>
+ <div
+ class="menu-item__text"
+ >
+ Twitter
+ </div>
+ </a>
+ <div
+ style="height: 1px; margin: .5rem 0px;"
+ />
+ <div
+ style="display: flex; flex-direction: column; row-gap: .5rem;"
+ >
+ <div>
<button
- aria-label="Redo"
- class="ToolIcon_type_button ToolIcon_size_medium ToolIcon_type_button--show ToolIcon"
+ aria-label="Dark mode"
+ class="menu-item"
+ data-testid="toggle-dark-mode"
+ title="Dark mode"
type="button"
>
<div
- aria-hidden="true"
- class="ToolIcon__icon"
+ class="menu-item__icon"
>
<svg
aria-hidden="true"
@@ -324,13 +1144,269 @@ exports[`<Excalidraw/> Test UIOptions prop should not hide any UI element when t
viewBox="0 0 20 20"
>
<path
- d="M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5"
- stroke-width="1.25"
+ clip-rule="evenodd"
+ d="M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z"
+ stroke="currentColor"
/>
</svg>
</div>
+ <div
+ class="menu-item__text"
+ >
+ Dark mode
+ </div>
+ <div
+ class="menu-item__shortcut"
+ >
+ Shift+Alt+D
+ </div>
</button>
</div>
+ <div
+ style="padding: 0px 0.625rem;"
+ >
+ <select
+ aria-label="Select language"
+ class="dropdown-select dropdown-select__language"
+ style="width: 100%;"
+ >
+ <option
+ value="en"
+ >
+ English
+ </option>
+ <option
+ value="id-ID"
+ >
+ Bahasa Indonesia
+ </option>
+ <option
+ value="ca-ES"
+ >
+ Català
+ </option>
+ <option
+ value="de-DE"
+ >
+ Deutsch
+ </option>
+ <option
+ value="en"
+ >
+ English
+ </option>
+ <option
+ value="es-ES"
+ >
+ Español
+ </option>
+ <option
+ value="eu-ES"
+ >
+ Euskara
+ </option>
+ <option
+ value="fr-FR"
+ >
+ Français
+ </option>
+ <option
+ value="it-IT"
+ >
+ Italiano
+ </option>
+ <option
+ value="ku-TR"
+ >
+ Kurdî
+ </option>
+ <option
+ value="lv-LV"
+ >
+ Latviešu
+ </option>
+ <option
+ value="hu-HU"
+ >
+ Magyar
+ </option>
+ <option
+ value="nl-NL"
+ >
+ Nederlands
+ </option>
+ <option
+ value="nb-NO"
+ >
+ Norsk bokmål
+ </option>
+ <option
+ value="nn-NO"
+ >
+ Norsk nynorsk
+ </option>
+ <option
+ value="oc-FR"
+ >
+ Occitan
+ </option>
+ <option
+ value="pl-PL"
+ >
+ Polski
+ </option>
+ <option
+ value="pt-PT"
+ >
+ Português
+ </option>
+ <option
+ value="pt-BR"
+ >
+ Português Brasileiro
+ </option>
+ <option
+ value="ro-RO"
+ >
+ Română
+ </option>
+ <option
+ value="sk-SK"
+ >
+ Slovenčina
+ </option>
+ <option
+ value="sl-SI"
+ >
+ Slovenščina
+ </option>
+ <option
+ value="fi-FI"
+ >
+ Suomi
+ </option>
+ <option
+ value="sv-SE"
+ >
+ Svenska
+ </option>
+ <option
+ value="kab-KAB"
+ >
+ Taqbaylit
+ </option>
+ <option
+ value="tr-TR"
+ >
+ Türkçe
+ </option>
+ <option
+ value="el-GR"
+ >
+ Ελληνικά
+ </option>
+ <option
+ value="ru-RU"
+ >
+ Русский
+ </option>
+ <option
+ value="uk-UA"
+ >
+ Українська
+ </option>
+ <option
+ value="he-IL"
+ >
+ עברית
+ </option>
+ <option
+ value="ar-SA"
+ >
+ العربية
+ </option>
+ <option
+ value="fa-IR"
+ >
+ فارسی
+ </option>
+ <option
+ value="mr-IN"
+ >
+ मराठी
+ </option>
+ <option
+ value="pa-IN"
+ >
+ ਪੰਜਾਬੀ
+ </option>
+ <option
+ value="ja-JP"
+ >
+ 日本語
+ </option>
+ <option
+ value="zh-CN"
+ >
+ 简体中文
+ </option>
+ <option
+ value="zh-TW"
+ >
+ 繁體中文
+ </option>
+ <option
+ value="ko-KR"
+ >
+ 한국어
+ </option>
+ </select>
+ </div>
+ <div>
+ <div
+ style="font-size: .75rem; margin-bottom: .5rem;"
+ >
+ Canvas background
+ </div>
+ <div
+ style="padding: 0px 0.625rem;"
+ >
+ <div
+ style="position: relative;"
+ >
+ <div>
+ <div
+ class="color-picker-control-container"
+ >
+ <div
+ class="color-picker-label-swatch-container"
+ >
+ <button
+ aria-label="Canvas background"
+ class="color-picker-label-swatch"
+ style="--swatch-color: #ffffff;"
+ />
+ </div>
+ <label
+ class="color-input-container"
+ >
+ <div
+ class="color-picker-hash"
+ >
+ #
+ </div>
+ <input
+ aria-label="Canvas background"
+ class="color-picker-input"
+ spellcheck="false"
+ value="ffffff"
+ />
+ </label>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
</div>
</div>
</section>
diff --git a/src/tests/packages/excalidraw.test.tsx b/src/tests/packages/excalidraw.test.tsx
index ef12fcff44..2957fd4762 100644
--- a/src/tests/packages/excalidraw.test.tsx
+++ b/src/tests/packages/excalidraw.test.tsx
@@ -90,7 +90,10 @@ describe("<Excalidraw/>", () => {
describe("Test theme prop", () => {
it("should show the theme toggle by default", async () => {
const { container } = await render(<Excalidraw />);
+
expect(h.state.theme).toBe(THEME.LIGHT);
+
+ queryByTestId(container, "menu-button")!.click();
const darkModeToggle = queryByTestId(container, "toggle-dark-mode");
expect(darkModeToggle).toBeTruthy();
});
diff --git a/src/tests/queries/toolQueries.ts b/src/tests/queries/toolQueries.ts
index 5b0ff937e6..bc1e4928d2 100644
--- a/src/tests/queries/toolQueries.ts
+++ b/src/tests/queries/toolQueries.ts
@@ -10,6 +10,7 @@ const toolMap = {
line: "line",
freedraw: "freedraw",
text: "text",
+ eraser: "eraser",
};
export type ToolName = keyof typeof toolMap;
diff --git a/src/tests/regressionTests.test.tsx b/src/tests/regressionTests.test.tsx
index 7a35e7b3a7..6c1ec82c4d 100644
--- a/src/tests/regressionTests.test.tsx
+++ b/src/tests/regressionTests.test.tsx
@@ -174,7 +174,7 @@ describe("regression tests", () => {
mouse.up(10, 10);
const { x: prevX, y: prevY } = API.getSelectedElement();
- mouse.down(-10, -10);
+ mouse.down(-8, -8);
mouse.up(10, 10);
const { x: nextX, y: nextY } = API.getSelectedElement();
@@ -201,7 +201,7 @@ describe("regression tests", () => {
).toBe(1);
Keyboard.withModifierKeys({ alt: true }, () => {
- mouse.down(-10, -10);
+ mouse.down(-8, -8);
mouse.up(10, 10);
});
@@ -446,6 +446,8 @@ describe("regression tests", () => {
UI.clickTool("rectangle");
// english lang should display `thin` label
expect(screen.queryByTitle(/thin/i)).not.toBeNull();
+ fireEvent.click(document.querySelector(".menu-button")!);
+
fireEvent.change(document.querySelector(".dropdown-select__language")!, {
target: { value: "de-DE" },
});
@@ -672,9 +674,10 @@ describe("regression tests", () => {
mouse.down();
mouse.up(100, 100);
- // hits bounding box without hitting element
- mouse.down();
expect(API.getSelectedElements().length).toBe(1);
+
+ // hits bounding box without hitting element
+ mouse.down(98, 98);
mouse.up();
expect(API.getSelectedElements().length).toBe(0);
});
@@ -744,7 +747,7 @@ describe("regression tests", () => {
// drag element from point on bounding box that doesn't hit element
mouse.reset();
- mouse.down();
+ mouse.down(8, 8);
mouse.up(25, 25);
expect(API.getSelectedElement().x).toEqual(prevX + 25);
@@ -1020,7 +1023,7 @@ describe("regression tests", () => {
// Rectangle is already selected since creating
// it was our last action
Keyboard.withModifierKeys({ shift: true }, () => {
- mouse.down();
+ mouse.down(-8, -8);
});
expect(API.getSelectedElements().length).toBe(1);
diff --git a/src/tests/selection.test.tsx b/src/tests/selection.test.tsx
index 6c6547c77f..7bfd6e9b37 100644
--- a/src/tests/selection.test.tsx
+++ b/src/tests/selection.test.tsx
@@ -154,7 +154,7 @@ describe("selection element", () => {
const canvas = container.querySelector("canvas")!;
fireEvent.pointerDown(canvas, { clientX: 60, clientY: 100 });
- expect(renderScene).toHaveBeenCalledTimes(4);
+ expect(renderScene).toHaveBeenCalledTimes(5);
const selectionElement = h.state.selectionElement!;
expect(selectionElement).not.toBeNull();
expect(selectionElement.type).toEqual("selection");
@@ -175,7 +175,7 @@ describe("selection element", () => {
fireEvent.pointerDown(canvas, { clientX: 60, clientY: 100 });
fireEvent.pointerMove(canvas, { clientX: 150, clientY: 30 });
- expect(renderScene).toHaveBeenCalledTimes(5);
+ expect(renderScene).toHaveBeenCalledTimes(6);
const selectionElement = h.state.selectionElement!;
expect(selectionElement).not.toBeNull();
expect(selectionElement.type).toEqual("selection");
@@ -197,7 +197,7 @@ describe("selection element", () => {
fireEvent.pointerMove(canvas, { clientX: 150, clientY: 30 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(6);
+ expect(renderScene).toHaveBeenCalledTimes(7);
expect(h.state.selectionElement).toBeNull();
});
});
@@ -232,7 +232,7 @@ describe("select single element on the scene", () => {
fireEvent.pointerDown(canvas, { clientX: 45, clientY: 20 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(10);
+ expect(renderScene).toHaveBeenCalledTimes(11);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
@@ -261,7 +261,7 @@ describe("select single element on the scene", () => {
fireEvent.pointerDown(canvas, { clientX: 45, clientY: 20 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(10);
+ expect(renderScene).toHaveBeenCalledTimes(11);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
@@ -290,7 +290,7 @@ describe("select single element on the scene", () => {
fireEvent.pointerDown(canvas, { clientX: 45, clientY: 20 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(10);
+ expect(renderScene).toHaveBeenCalledTimes(11);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
@@ -332,7 +332,7 @@ describe("select single element on the scene", () => {
fireEvent.pointerDown(canvas, { clientX: 40, clientY: 40 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(10);
+ expect(renderScene).toHaveBeenCalledTimes(11);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
@@ -373,7 +373,7 @@ describe("select single element on the scene", () => {
fireEvent.pointerDown(canvas, { clientX: 40, clientY: 40 });
fireEvent.pointerUp(canvas);
- expect(renderScene).toHaveBeenCalledTimes(10);
+ expect(renderScene).toHaveBeenCalledTimes(11);
expect(h.state.selectionElement).toBeNull();
expect(h.elements.length).toEqual(1);
expect(h.state.selectedElementIds[h.elements[0].id]).toBeTruthy();
diff --git a/src/tests/test-utils.ts b/src/tests/test-utils.ts
index 48e6180b66..c7af290483 100644
--- a/src/tests/test-utils.ts
+++ b/src/tests/test-utils.ts
@@ -16,8 +16,6 @@ import { SceneData } from "../types";
import { getSelectedElements } from "../scene/selection";
import { ExcalidrawElement } from "../element/types";
-require("fake-indexeddb/auto");
-
const customQueries = {
...queries,
...toolQueries,