From b63e285f935ed95039e443e6a70bb1b6dc199c06 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Wed, 14 May 2025 21:33:20 +0200 Subject: [PATCH] Fix tests --- packages/element/src/Shape.ts | 4 + .../tests/linearElementEditor.test.tsx | 2 +- packages/element/tests/resize.test.tsx | 12 +- .../data/__snapshots__/transform.test.ts.snap | 2 +- .../__snapshots__/contextmenu.test.tsx.snap | 959 ++++++++++++------ .../tests/__snapshots__/history.test.tsx.snap | 110 +- .../tests/__snapshots__/move.test.tsx.snap | 12 +- .../excalidraw/tests/contextmenu.test.tsx | 5 +- packages/excalidraw/tests/move.test.tsx | 4 +- packages/excalidraw/tests/rotate.test.tsx | 2 +- .../excalidraw/wysiwyg/textWysiwyg.test.tsx | 6 +- 11 files changed, 728 insertions(+), 390 deletions(-) diff --git a/packages/element/src/Shape.ts b/packages/element/src/Shape.ts index 5164ae34a..0ab0b0fb7 100644 --- a/packages/element/src/Shape.ts +++ b/packages/element/src/Shape.ts @@ -419,6 +419,10 @@ export const generateLinearCollisionShape = ( }); } case "freedraw": { + if (element.points.length < 2) { + return []; + } + const simplifiedPoints = simplify( element.points as Mutable, 0.75, diff --git a/packages/element/tests/linearElementEditor.test.tsx b/packages/element/tests/linearElementEditor.test.tsx index 77b99fa7f..4e6553c55 100644 --- a/packages/element/tests/linearElementEditor.test.tsx +++ b/packages/element/tests/linearElementEditor.test.tsx @@ -1262,7 +1262,7 @@ describe("Test Linear Elements", () => { mouse.downAt(rect.x, rect.y); mouse.moveTo(200, 0); mouse.upAt(200, 0); - expect(arrow.width).toBeCloseTo(204, 0); + expect(arrow.width).toBeCloseTo(200, 0); expect(rect.x).toBe(200); expect(rect.y).toBe(0); expect(handleBindTextResizeSpy).toHaveBeenCalledWith( diff --git a/packages/element/tests/resize.test.tsx b/packages/element/tests/resize.test.tsx index 98fbf2a9a..1d0b6ac0b 100644 --- a/packages/element/tests/resize.test.tsx +++ b/packages/element/tests/resize.test.tsx @@ -510,12 +510,12 @@ describe("arrow element", () => { h.state, )[0] as ExcalidrawElbowArrowElement; - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); UI.resize(rectangle, "se", [-200, -150]); - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); }); @@ -538,11 +538,11 @@ describe("arrow element", () => { h.state, )[0] as ExcalidrawElbowArrowElement; - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); UI.resize([rectangle, arrow], "nw", [300, 350]); - expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(0); + expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(-0.05); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25); }); }); @@ -819,7 +819,7 @@ describe("image element", () => { UI.resize(image, "ne", [40, 0]); - expect(arrow.width + arrow.endBinding!.gap).toBeCloseTo(31, 0); + expect(arrow.width + arrow.endBinding!.gap).toBeCloseTo(30, 0); const imageWidth = image.width; const scale = 20 / image.height; @@ -1033,7 +1033,7 @@ describe("multiple selection", () => { expect(leftBoundArrow.x).toBeCloseTo(-110); expect(leftBoundArrow.y).toBeCloseTo(50); - expect(leftBoundArrow.width).toBeCloseTo(143, 0); + expect(leftBoundArrow.width).toBeCloseTo(140, 0); expect(leftBoundArrow.height).toBeCloseTo(7, 0); expect(leftBoundArrow.angle).toEqual(0); expect(leftBoundArrow.startBinding).toBeNull(); diff --git a/packages/excalidraw/data/__snapshots__/transform.test.ts.snap b/packages/excalidraw/data/__snapshots__/transform.test.ts.snap index 70f8daa31..7ffcb1c2b 100644 --- a/packages/excalidraw/data/__snapshots__/transform.test.ts.snap +++ b/packages/excalidraw/data/__snapshots__/transform.test.ts.snap @@ -175,7 +175,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s "startBinding": { "elementId": "diamond-1", "focus": 0, - "gap": 4.545343408287929, + "gap": 4.535423522449215, }, "strokeColor": "#e67700", "strokeStyle": "solid", diff --git a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap index 32e5f6d07..66beb0386 100644 --- a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap @@ -7769,6 +7769,82 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap "collaborators": Map {}, "contextMenu": { "items": [ + "separator", + { + "icon": , + "keyTest": [Function], + "label": "labels.cut", + "name": "cut", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "icon": , + "keyTest": undefined, + "label": "labels.copy", + "name": "copy", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, { "keyTest": undefined, "label": "labels.paste", @@ -7779,6 +7855,78 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap }, }, "separator", + { + "label": "labels.selectAllElementsInFrame", + "name": "selectAllElementsInFrame", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "canvas", + }, + }, + { + "label": "labels.removeAllElementsFromFrame", + "name": "removeAllElementsFromFrame", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "history", + }, + }, + { + "label": "labels.wrapSelectionInFrame", + "name": "wrapSelectionInFrame", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "PanelComponent": [Function], + "icon": , + "keywords": [ + "image", + "crop", + ], + "label": "helpDialog.cropStart", + "name": "cropEditor", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "menu", + }, + "viewMode": true, + }, + "separator", { "icon": , "keyTest": [Function], - "label": "labels.selectAll", - "name": "selectAll", + "label": "labels.copyStyles", + "name": "copyStyles", "perform": [Function], "trackEvent": { - "category": "canvas", + "category": "element", }, - "viewMode": false, }, { + "icon": , + "keyTest": [Function], + "label": "labels.pasteStyles", + "name": "pasteStyles", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "PanelComponent": [Function], + "icon": [Function], + "keyTest": [Function], + "label": "labels.group", + "name": "group", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "icon": null, + "label": "labels.autoResize", + "name": "autoResize", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "label": "labels.unbindText", + "name": "unbindText", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "label": "labels.bindText", + "name": "bindText", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "label": "labels.createContainerFromText", + "name": "wrapTextInContainer", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "PanelComponent": [Function], + "icon": [Function], + "keyTest": [Function], + "label": "labels.ungroup", + "name": "ungroup", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "label": "labels.addToLibrary", + "name": "addToLibrary", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "PanelComponent": [Function], + "icon": , + "keyPriority": 40, + "keyTest": [Function], + "keywords": [ + "move down", + "zindex", + "layer", + ], + "label": "labels.sendBackward", + "name": "sendBackward", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "PanelComponent": [Function], + "icon": , + "keyPriority": 40, + "keyTest": [Function], + "keywords": [ + "move up", + "zindex", + "layer", + ], + "label": "labels.bringForward", + "name": "bringForward", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "PanelComponent": [Function], + "icon": , + "keyTest": [Function], + "keywords": [ + "move down", + "zindex", + "layer", + ], + "label": "labels.sendToBack", + "name": "sendToBack", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "PanelComponent": [Function], + "icon": , + "keyTest": [Function], + "keywords": [ + "move up", + "zindex", + "layer", + ], + "label": "labels.bringToFront", + "name": "bringToFront", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "icon": , + "keyTest": [Function], + "label": "labels.flipHorizontal", + "name": "flipHorizontal", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "icon": , + "keyTest": [Function], + "label": "labels.flipVertical", + "name": "flipVertical", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "PanelComponent": [Function], + "category": "Elements", + "keywords": [ + "line", + ], + "label": [Function], + "name": "toggleLinearEditor", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", + }, + }, + "separator", + { + "PanelComponent": [Function], "icon": , - "label": "labels.elementLock.unlockAll", - "name": "unlockAllElements", + "keyTest": [Function], + "label": [Function], + "name": "hyperlink", "perform": [Function], "predicate": [Function], "trackEvent": { - "category": "canvas", + "action": "click", + "category": "hyperlink", + }, + }, + { + "icon": , + "label": "labels.copyElementLink", + "name": "copyElementLink", + "perform": [Function], + "predicate": [Function], + "trackEvent": { + "category": "element", }, - "viewMode": false, }, "separator", { - "checked": [Function], + "PanelComponent": [Function], "icon": , "keyTest": [Function], - "keywords": [ - "snap", - ], - "label": "labels.toggleGrid", - "name": "gridMode", + "label": "labels.duplicateSelection", + "name": "duplicateSelection", + "perform": [Function], + "trackEvent": { + "category": "element", + }, + }, + { + "icon": [Function], + "keyTest": [Function], + "label": [Function], + "name": "toggleElementLock", "perform": [Function], "predicate": [Function], "trackEvent": { - "category": "canvas", - "predicate": [Function], + "category": "element", }, - "viewMode": true, }, + "separator", { - "checked": [Function], + "PanelComponent": [Function], "icon": , "keyTest": [Function], - "label": "buttons.objectsSnapMode", - "name": "objectsSnapMode", - "perform": [Function], - "predicate": [Function], - "trackEvent": { - "category": "canvas", - "predicate": [Function], - }, - "viewMode": false, - }, - { - "checked": [Function], - "icon": , - "keyTest": [Function], - "label": "buttons.zenMode", - "name": "zenMode", - "perform": [Function], - "predicate": [Function], - "trackEvent": { - "category": "canvas", - "predicate": [Function], - }, - "viewMode": true, - }, - { - "checked": [Function], - "icon": , - "keyTest": [Function], - "label": "labels.viewMode", - "name": "viewMode", - "perform": [Function], - "predicate": [Function], - "trackEvent": { - "category": "canvas", - "predicate": [Function], - }, - "viewMode": true, - }, - { - "checked": [Function], - "icon": , - "keyTest": [Function], - "keywords": [ - "edit", - "attributes", - "customize", - ], - "label": "stats.fullTitle", - "name": "stats", + "label": "labels.delete", + "name": "deleteSelectedElements", "perform": [Function], "trackEvent": { - "category": "menu", + "action": "delete", + "category": "element", }, - "viewMode": true, }, ], - "left": -17, - "top": -7, + "left": 10, + "top": 20, }, "croppingElementId": null, "currentChartType": "bar", diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index 5e3f00c31..855090d47 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -198,7 +198,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "102.45605", + "height": "102.44561", "id": "id691", "index": "a2", "isDeleted": false, @@ -212,8 +212,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "102.80179", - "102.45605", + "102.69685", + "102.44561", ], ], "roughness": 1, @@ -228,8 +228,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": "arrow", "updated": 1, "version": 37, - "width": "102.80179", - "x": "-0.42182", + "width": "102.69685", + "x": "-0.30656", "y": 0, } `; @@ -312,15 +312,15 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "focus": 0, "gap": 1, }, - "height": "70.45017", + "height": "70.31130", "points": [ [ 0, 0, ], [ - "100.70774", - "70.45017", + "100.51087", + "70.31130", ], ], "startBinding": { @@ -335,15 +335,15 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "focus": "-0.02000", "gap": 1, }, - "height": "0.09250", + "height": "0.10543", "points": [ [ 0, 0, ], [ - "98.58579", - "0.09250", + "98.00000", + "0.10543", ], ], "startBinding": { @@ -396,30 +396,30 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl }, "id691": { "deleted": { - "height": "102.45584", + "height": "102.44538", "points": [ [ 0, 0, ], [ - "102.79971", - "102.45584", + "102.69463", + "102.44538", ], ], "startBinding": null, "y": 0, }, "inserted": { - "height": "70.33521", + "height": "70.20818", "points": [ [ 0, 0, ], [ - "100.78887", - "70.33521", + "100.62538", + "70.20818", ], ], "startBinding": { @@ -427,7 +427,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "focus": "0.02970", "gap": 1, }, - "y": "35.20327", + "y": "35.26761", }, }, }, @@ -810,7 +810,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "updated": 1, "version": 33, "width": 100, - "x": "149.29289", + "x": 149, "y": 0, } `; @@ -1229,7 +1229,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "1.30038", + "height": "1.33342", "id": "id715", "index": "Zz", "isDeleted": false, @@ -1243,8 +1243,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "98.58579", - "1.30038", + 98, + "1.33342", ], ], "roughness": 1, @@ -1267,8 +1267,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": "arrow", "updated": 1, "version": 11, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -1595,7 +1595,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "1.30038", + "height": "1.33342", "id": "id725", "index": "a0", "isDeleted": false, @@ -1609,8 +1609,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "98.58579", - "1.30038", + 98, + "1.33342", ], ], "roughness": 1, @@ -1633,8 +1633,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": "arrow", "updated": 1, "version": 11, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -1751,7 +1751,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "11.27227", + "height": "11.38145", "index": "a0", "isDeleted": false, "lastCommittedPoint": null, @@ -1764,8 +1764,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "98.58579", - "11.27227", + "98.00000", + "11.38145", ], ], "roughness": 1, @@ -1786,8 +1786,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", - "width": "98.58579", - "x": "0.70711", + "width": "98.00000", + "x": 1, "y": 0, }, "inserted": { @@ -2296,7 +2296,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "374.05754", + "height": "373.94428", "id": "id740", "index": "a2", "isDeleted": false, @@ -2310,8 +2310,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "502.78936", - "-374.05754", + "502.66843", + "-373.94428", ], ], "roughness": 1, @@ -2330,9 +2330,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "type": "arrow", "updated": 1, "version": 10, - "width": "502.78936", - "x": "-0.83465", - "y": "-36.58211", + "width": "502.66843", + "x": "-0.74818", + "y": "-36.64616", } `; @@ -14933,7 +14933,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding 0, ], [ - "98.58579", + 98, 0, ], ], @@ -14953,8 +14953,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", "updated": 1, "version": 10, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -15632,7 +15632,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding 0, ], [ - "98.58579", + 98, 0, ], ], @@ -15652,8 +15652,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", "updated": 1, "version": 10, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -16250,7 +16250,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding 0, ], [ - "98.58579", + 98, 0, ], ], @@ -16270,8 +16270,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", "updated": 1, "version": 10, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -16866,7 +16866,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding 0, ], [ - "98.58579", + 98, 0, ], ], @@ -16886,8 +16886,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", "updated": 1, "version": 10, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; @@ -17582,7 +17582,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding 0, ], [ - "98.58579", + 98, 0, ], ], @@ -17602,8 +17602,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", "updated": 1, "version": 11, - "width": "98.58579", - "x": "0.70711", + "width": 98, + "x": 1, "y": 0, } `; diff --git a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap index 0ee4ea46a..3628ea2f6 100644 --- a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap @@ -196,7 +196,7 @@ exports[`move element > rectangles with binding arrow 7`] = ` "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "87.29887", + "height": "81.40630", "id": "id6", "index": "a2", "isDeleted": false, @@ -210,8 +210,8 @@ exports[`move element > rectangles with binding arrow 7`] = ` 0, ], [ - "86.85786", - "87.29887", + "81.00000", + "81.40630", ], ], "roughness": 1, @@ -232,8 +232,8 @@ exports[`move element > rectangles with binding arrow 7`] = ` "updated": 1, "version": 11, "versionNonce": 1051383431, - "width": "86.85786", - "x": "107.07107", - "y": "47.07107", + "width": "81.00000", + "x": "110.00000", + "y": 50, } `; diff --git a/packages/excalidraw/tests/contextmenu.test.tsx b/packages/excalidraw/tests/contextmenu.test.tsx index 21f7a6a79..11afde532 100644 --- a/packages/excalidraw/tests/contextmenu.test.tsx +++ b/packages/excalidraw/tests/contextmenu.test.tsx @@ -115,9 +115,10 @@ describe("contextMenu element", () => { fireEvent.contextMenu(GlobalTestState.interactiveCanvas, { button: 2, - clientX: 3, - clientY: 3, + clientX: 30, + clientY: 30, }); + const contextMenu = UI.queryContextMenu(); const contextMenuOptions = contextMenu?.querySelectorAll(".context-menu li"); diff --git a/packages/excalidraw/tests/move.test.tsx b/packages/excalidraw/tests/move.test.tsx index 1a02ba1db..095db38a0 100644 --- a/packages/excalidraw/tests/move.test.tsx +++ b/packages/excalidraw/tests/move.test.tsx @@ -124,8 +124,8 @@ describe("move element", () => { expect(h.state.selectedElementIds[rectB.id]).toBeTruthy(); expect([rectA.x, rectA.y]).toEqual([0, 0]); expect([rectB.x, rectB.y]).toEqual([201, 2]); - expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[107.07, 47.07]]); - expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[86.86, 87.3]]); + expect([[arrow.x, arrow.y]]).toCloselyEqualPoints([[110, 50]]); + expect([[arrow.width, arrow.height]]).toCloselyEqualPoints([[81, 81.4]]); h.elements.forEach((element) => expect(element).toMatchSnapshot()); }); diff --git a/packages/excalidraw/tests/rotate.test.tsx b/packages/excalidraw/tests/rotate.test.tsx index 9687b08f2..38079db8f 100644 --- a/packages/excalidraw/tests/rotate.test.tsx +++ b/packages/excalidraw/tests/rotate.test.tsx @@ -35,7 +35,7 @@ test("unselected bound arrow updates when rotating its target element", async () expect(arrow.endBinding?.elementId).toEqual(rectangle.id); expect(arrow.x).toBeCloseTo(-80); expect(arrow.y).toBeCloseTo(50); - expect(arrow.width).toBeCloseTo(116.7, 1); + expect(arrow.width).toBeCloseTo(110.7, 1); expect(arrow.height).toBeCloseTo(0); }); diff --git a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx index 86fa94837..955833a50 100644 --- a/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx +++ b/packages/excalidraw/wysiwyg/textWysiwyg.test.tsx @@ -682,7 +682,7 @@ describe("textWysiwyg", () => { expect(diamond.height).toBe(70); }); - it("should bind text to container when double clicked on center of transparent container", async () => { + it("should bind text to container when double clicked inside of the transparent container", async () => { const rectangle = API.createElement({ type: "rectangle", x: 10, @@ -693,7 +693,7 @@ describe("textWysiwyg", () => { }); API.setElements([rectangle]); - mouse.doubleClickAt(rectangle.x + 10, rectangle.y + 10); + mouse.doubleClickAt(rectangle.x + 20, rectangle.y + 20); expect(h.elements.length).toBe(2); let text = h.elements[1] as ExcalidrawTextElementWithContainer; expect(text.type).toBe("text"); @@ -790,7 +790,7 @@ describe("textWysiwyg", () => { freedraw.x + freedraw.width / 2, freedraw.y + freedraw.height / 2, ); - console.log(JSON.stringify(h.elements)); + const editor = await getTextEditor(textEditorSelector, true); updateTextEditor(editor, "Hello World!"); Keyboard.exitTextEditor(editor);