From 001359c3acd9f18d0c2803959da75c9a28e7b3c6 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Thu, 14 Aug 2025 20:43:26 +0200 Subject: [PATCH] fix: history tests --- .../tests/__snapshots__/history.test.tsx.snap | 605 ++++++++++++++---- packages/excalidraw/tests/history.test.tsx | 153 +++-- 2 files changed, 569 insertions(+), 189 deletions(-) diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap index c1549cc2fd..c43ef5fe92 100644 --- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap +++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap @@ -277,7 +277,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of elements 1`] = `3`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of renders 1`] = `10`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] number of renders 1`] = `12`; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and the arrow got bound to a different element in the meantime > [end of test] redo stack 1`] = `[]`; @@ -1016,7 +1016,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of elements 1`] = `3`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of renders 1`] = `12`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] number of renders 1`] = `14`; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind bindings when both are updated through the history and there are no conflicting updates in the meantime > [end of test] redo stack 1`] = `[]`; @@ -1737,7 +1737,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": "31.25668", + "height": "30.01725", "id": "id4", "index": "Zz", "isDeleted": false, @@ -1752,8 +1752,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - "90.00000", - "31.25668", + 90, + "30.01725", ], ], "roughness": 1, @@ -1772,10 +1772,10 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 7, - "width": "90.00000", + "version": 11, + "width": 90, "x": 5, - "y": "1.67603", + "y": "1.67622", } `; @@ -1807,7 +1807,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 5, + "version": 7, "width": 100, "x": -100, "y": -50, @@ -1842,7 +1842,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 5, + "version": 7, "width": 100, "x": 100, "y": -50, @@ -1851,7 +1851,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added arrow when it's bindable elements are added through the history > [end of test] number of elements 1`] = `3`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added arrow when it's bindable elements are added through the history > [end of test] number of renders 1`] = `7`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added arrow when it's bindable elements are added through the history > [end of test] number of renders 1`] = `9`; exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added arrow when it's bindable elements are added through the history > [end of test] redo stack 1`] = `[]`; @@ -1888,14 +1888,14 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeStyle": "solid", "strokeWidth": 2, "type": "rectangle", - "version": 5, + "version": 7, "width": 100, "x": -100, "y": -50, }, "inserted": { "isDeleted": true, - "version": 4, + "version": 6, }, }, "id1": { @@ -1919,14 +1919,14 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeStyle": "solid", "strokeWidth": 2, "type": "rectangle", - "version": 5, + "version": 7, "width": 100, "x": 100, "y": -50, }, "inserted": { "isDeleted": true, - "version": 4, + "version": 6, }, }, }, @@ -1949,17 +1949,17 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl ], "mode": "orbit", }, - "version": 7, + "version": 11, }, "inserted": { "endBinding": null, "startBinding": null, - "version": 4, + "version": 8, }, }, }, }, - "id": "id6", + "id": "id8", }, ] `; @@ -2097,13 +2097,14 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": 100, + "height": "15.64048", "id": "id5", "index": "a0", - "isDeleted": true, + "isDeleted": false, "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -2111,8 +2112,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - 100, - 100, + 90, + "-15.64048", ], ], "roughness": 1, @@ -2131,10 +2132,10 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 4, - "width": 100, - "x": 0, - "y": 0, + "version": 11, + "width": 90, + "x": 5, + "y": "37.37707", } `; @@ -2142,7 +2143,12 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [], + "boundElements": [ + { + "id": "id5", + "type": "arrow", + }, + ], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -2161,7 +2167,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 5, + "version": 12, "width": 100, "x": -100, "y": -50, @@ -2172,7 +2178,12 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl { "angle": 0, "backgroundColor": "transparent", - "boundElements": [], + "boundElements": [ + { + "id": "id5", + "type": "arrow", + }, + ], "customData": undefined, "fillStyle": "solid", "frameId": null, @@ -2191,7 +2202,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 11, "width": 100, "x": 100, "y": -50, @@ -2200,9 +2211,11 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] number of elements 1`] = `3`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] number of renders 1`] = `8`; +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] number of renders 1`] = `11`; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] redo stack 1`] = ` +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] redo stack 1`] = `[]`; + +exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] undo stack 1`] = ` [ { "appState": AppStateDelta { @@ -2212,13 +2225,10 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl }, }, "elements": { - "added": { + "added": {}, + "removed": { "id5": { "deleted": { - "isDeleted": true, - "version": 4, - }, - "inserted": { "angle": 0, "backgroundColor": "transparent", "boundElements": null, @@ -2236,7 +2246,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "fillStyle": "solid", "frameId": null, "groupIds": [], - "height": 100, + "height": "15.64048", "index": "a0", "isDeleted": false, "lastCommittedPoint": null, @@ -2249,8 +2259,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl 0, ], [ - 100, - 100, + 90, + "-15.64048", ], ], "roughness": 1, @@ -2268,54 +2278,55 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", - "version": 3, - "width": 100, - "x": 0, - "y": 0, + "version": 11, + "width": 90, + "x": 5, + "y": "37.37707", + }, + "inserted": { + "isDeleted": true, + "version": 8, }, }, }, - "removed": {}, "updated": { "id0": { "deleted": { - "boundElements": [], - "version": 5, - }, - "inserted": { "boundElements": [ { "id": "id5", "type": "arrow", }, ], - "version": 4, + "version": 12, + }, + "inserted": { + "boundElements": [], + "version": 9, }, }, "id1": { "deleted": { - "boundElements": [], - "version": 4, - }, - "inserted": { "boundElements": [ { "id": "id5", "type": "arrow", }, ], - "version": 3, + "version": 11, + }, + "inserted": { + "boundElements": [], + "version": 8, }, }, }, }, - "id": "id8", + "id": "id11", }, ] `; -exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should rebind remotely added bindable elements when it's arrow is added through the history > [end of test] undo stack 1`] = `[]`; - exports[`history > multiplayer undo/redo > conflicts in arrows and their bindable elements > should unbind remotely deleted bindable elements from arrow when the arrow is added through the history > [end of test] appState 1`] = ` { "activeEmbeddable": null, @@ -16458,7 +16469,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 8, "width": 100, "x": -100, "y": -50, @@ -16496,7 +16507,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "textAlign": "center", "type": "text", "updated": 1, - "version": 4, + "version": 6, "verticalAlign": "middle", "width": 30, "x": -65, @@ -16532,7 +16543,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 3, + "version": 7, "width": 100, "x": 100, "y": -50, @@ -16565,6 +16576,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -16594,7 +16606,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", @@ -16603,9 +16615,111 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] number of elements 1`] = `4`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] number of renders 1`] = `10`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] number of renders 1`] = `12`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] redo stack 1`] = `[]`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] redo stack 1`] = ` +[ + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id13": true, + }, + "selectedLinearElement": { + "elementId": "id13", + "isEditing": false, + }, + }, + "inserted": { + "selectedElementIds": {}, + "selectedLinearElement": null, + }, + }, + }, + "elements": { + "added": {}, + "removed": { + "id13": { + "deleted": { + "endBinding": { + "elementId": "id2", + "fixedPoint": [ + 0, + "0.50010", + ], + "mode": "orbit", + }, + "isDeleted": false, + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + 1, + "0.50010", + ], + "mode": "orbit", + }, + "version": 12, + }, + "inserted": { + "endBinding": { + "elementId": "id2", + "fixedPoint": [ + 0, + "0.50010", + ], + "mode": "orbit", + }, + "isDeleted": true, + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + 1, + "0.50010", + ], + "mode": "orbit", + }, + "version": 10, + }, + }, + }, + "updated": { + "id0": { + "deleted": { + "boundElements": [ + { + "id": "id13", + "type": "arrow", + }, + ], + "version": 8, + }, + "inserted": { + "boundElements": [], + "version": 5, + }, + }, + "id2": { + "deleted": { + "boundElements": [ + { + "id": "id13", + "type": "arrow", + }, + ], + "version": 7, + }, + "inserted": { + "boundElements": [], + "version": 4, + }, + }, + }, + }, + "id": "id18", + }, +] +`; exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on deletion and rebind on undo > [end of test] undo stack 1`] = ` [ @@ -17096,7 +17210,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 8, "width": 100, "x": -100, "y": -50, @@ -17134,7 +17248,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "textAlign": "center", "type": "text", "updated": 1, - "version": 4, + "version": 8, "verticalAlign": "middle", "width": 30, "x": -65, @@ -17170,7 +17284,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 3, + "version": 7, "width": 100, "x": 100, "y": -50, @@ -17203,6 +17317,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -17232,7 +17347,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", @@ -17241,7 +17356,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on undo and rebind on redo > [end of test] number of elements 1`] = `4`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on undo and rebind on redo > [end of test] number of renders 1`] = `10`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on undo and rebind on redo > [end of test] number of renders 1`] = `12`; exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind arrow from non deleted bindable elements on undo and rebind on redo > [end of test] redo stack 1`] = `[]`; @@ -17538,14 +17653,14 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", }, "inserted": { "isDeleted": true, - "version": 8, + "version": 10, }, }, }, @@ -17558,11 +17673,11 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", }, ], - "version": 4, + "version": 8, }, "inserted": { "boundElements": [], - "version": 3, + "version": 5, }, }, "id1": { @@ -17581,16 +17696,16 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", }, ], - "version": 3, + "version": 7, }, "inserted": { "boundElements": [], - "version": 2, + "version": 4, }, }, }, }, - "id": "id15", + "id": "id17", }, ] `; @@ -17742,7 +17857,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 12, "width": 100, "x": -100, "y": -50, @@ -17780,7 +17895,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "textAlign": "center", "type": "text", "updated": 1, - "version": 4, + "version": 12, "verticalAlign": "middle", "width": 30, "x": -65, @@ -17816,7 +17931,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 3, + "version": 9, "width": 100, "x": 100, "y": -50, @@ -17849,6 +17964,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -17878,7 +17994,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", @@ -17887,7 +18003,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind everything from non deleted elements when iterating through the whole undo stack and vice versa rebind everything on redo > [end of test] number of elements 1`] = `4`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind everything from non deleted elements when iterating through the whole undo stack and vice versa rebind everything on redo > [end of test] number of renders 1`] = `10`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind everything from non deleted elements when iterating through the whole undo stack and vice versa rebind everything on redo > [end of test] number of renders 1`] = `20`; exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind everything from non deleted elements when iterating through the whole undo stack and vice versa rebind everything on redo > [end of test] redo stack 1`] = `[]`; @@ -17924,14 +18040,14 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeStyle": "solid", "strokeWidth": 2, "type": "rectangle", - "version": 2, + "version": 8, "width": 100, "x": -100, "y": -50, }, "inserted": { "isDeleted": true, - "version": 1, + "version": 7, }, }, "id1": { @@ -17963,7 +18079,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "text": "ola", "textAlign": "left", "type": "text", - "version": 2, + "version": 9, "verticalAlign": "top", "width": 100, "x": -200, @@ -17971,7 +18087,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding }, "inserted": { "isDeleted": true, - "version": 1, + "version": 8, }, }, "id2": { @@ -17995,20 +18111,20 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeStyle": "solid", "strokeWidth": 2, "type": "rectangle", - "version": 2, + "version": 6, "width": 100, "x": 100, "y": -50, }, "inserted": { "isDeleted": true, - "version": 1, + "version": 5, }, }, }, "updated": {}, }, - "id": "id4", + "id": "id21", }, { "appState": AppStateDelta { @@ -18028,7 +18144,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "removed": {}, "updated": {}, }, - "id": "id7", + "id": "id22", }, { "appState": AppStateDelta { @@ -18048,7 +18164,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "removed": {}, "updated": {}, }, - "id": "id10", + "id": "id23", }, { "appState": AppStateDelta { @@ -18075,11 +18191,11 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "text", }, ], - "version": 3, + "version": 9, }, "inserted": { "boundElements": [], - "version": 2, + "version": 8, }, }, "id1": { @@ -18087,7 +18203,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "containerId": "id0", "height": 25, "textAlign": "center", - "version": 4, + "version": 10, "verticalAlign": "middle", "width": 30, "x": -65, @@ -18097,7 +18213,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "containerId": null, "height": 100, "textAlign": "left", - "version": 2, + "version": 9, "verticalAlign": "top", "width": 100, "x": -200, @@ -18106,7 +18222,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding }, }, }, - "id": "id12", + "id": "id24", }, { "appState": AppStateDelta { @@ -18184,14 +18300,14 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeStyle": "solid", "strokeWidth": 2, "type": "arrow", - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", }, "inserted": { "isDeleted": true, - "version": 8, + "version": 10, }, }, }, @@ -18204,11 +18320,11 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", }, ], - "version": 4, + "version": 12, }, "inserted": { "boundElements": [], - "version": 3, + "version": 9, }, }, "id1": { @@ -18227,16 +18343,16 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "type": "arrow", }, ], - "version": 3, + "version": 9, }, "inserted": { "boundElements": [], - "version": 2, + "version": 6, }, }, }, }, - "id": "id15", + "id": "id25", }, ] `; @@ -18320,15 +18436,13 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding }, "penDetected": false, "penMode": false, - "previousSelectedElementIds": { - "id0": true, - }, + "previousSelectedElementIds": {}, "resizingElement": null, "scrollX": 0, "scrollY": 0, "searchMatches": null, "selectedElementIds": { - "id13": true, + "id0": true, }, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -18361,14 +18475,14 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "angle": 0, "backgroundColor": "transparent", "boundElements": [ - { - "id": "id1", - "type": "text", - }, { "id": "id13", "type": "arrow", }, + { + "id": "id1", + "type": "text", + }, ], "customData": undefined, "fillStyle": "solid", @@ -18388,7 +18502,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 8, "width": 100, "x": -100, "y": -50, @@ -18426,7 +18540,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "textAlign": "center", "type": "text", "updated": 1, - "version": 4, + "version": 8, "verticalAlign": "middle", "width": 30, "x": -65, @@ -18462,7 +18576,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 3, + "version": 5, "width": 100, "x": 100, "y": -50, @@ -18495,6 +18609,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -18524,7 +18639,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 9, + "version": 12, "width": 90, "x": 5, "y": "0.01000", @@ -18533,9 +18648,87 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] number of elements 1`] = `4`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] number of renders 1`] = `10`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] number of renders 1`] = `14`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] redo stack 1`] = `[]`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] redo stack 1`] = ` +[ + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id0": true, + }, + }, + "inserted": { + "selectedElementIds": {}, + }, + }, + }, + "elements": { + "added": {}, + "removed": { + "id0": { + "deleted": { + "isDeleted": false, + "version": 8, + }, + "inserted": { + "isDeleted": true, + "version": 5, + }, + }, + "id1": { + "deleted": { + "isDeleted": false, + "version": 8, + }, + "inserted": { + "isDeleted": true, + "version": 5, + }, + }, + }, + "updated": { + "id13": { + "deleted": { + "endBinding": { + "elementId": "id2", + "fixedPoint": [ + 0, + "0.50010", + ], + "mode": "orbit", + }, + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + 1, + "0.50010", + ], + "mode": "orbit", + }, + "version": 12, + }, + "inserted": { + "endBinding": { + "elementId": "id2", + "fixedPoint": [ + 0, + "0.50010", + ], + "mode": "orbit", + }, + "startBinding": null, + "version": 10, + }, + }, + }, + }, + "id": "id21", + }, +] +`; exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangle from arrow on deletion and rebind on undo > [end of test] undo stack 1`] = ` [ @@ -18876,6 +19069,33 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding }, "id": "id15", }, + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id0": true, + }, + "selectedLinearElement": null, + }, + "inserted": { + "selectedElementIds": { + "id13": true, + }, + "selectedLinearElement": { + "elementId": "id13", + "isEditing": false, + }, + }, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": {}, + }, + "id": "id18", + }, ] `; @@ -18966,7 +19186,8 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "scrollY": 0, "searchMatches": null, "selectedElementIds": { - "id13": true, + "id0": true, + "id2": true, }, "selectedElementsAreBeingDragged": false, "selectedGroupIds": {}, @@ -18999,14 +19220,14 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "angle": 0, "backgroundColor": "transparent", "boundElements": [ - { - "id": "id1", - "type": "text", - }, { "id": "id13", "type": "arrow", }, + { + "id": "id1", + "type": "text", + }, ], "customData": undefined, "fillStyle": "solid", @@ -19026,7 +19247,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 4, + "version": 8, "width": 100, "x": -100, "y": -50, @@ -19064,7 +19285,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "textAlign": "center", "type": "text", "updated": 1, - "version": 4, + "version": 8, "verticalAlign": "middle", "width": 30, "x": -65, @@ -19100,7 +19321,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "rectangle", "updated": 1, - "version": 3, + "version": 5, "width": 100, "x": 100, "y": -50, @@ -19133,6 +19354,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "lastCommittedPoint": null, "link": null, "locked": false, + "moveMidPointsWithElement": false, "opacity": 100, "points": [ [ @@ -19162,7 +19384,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding "strokeWidth": 2, "type": "arrow", "updated": 1, - "version": 9, + "version": 13, "width": 90, "x": 5, "y": "0.01000", @@ -19171,9 +19393,91 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] number of elements 1`] = `4`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] number of renders 1`] = `10`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] number of renders 1`] = `15`; -exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] redo stack 1`] = `[]`; +exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] redo stack 1`] = ` +[ + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id0": true, + "id2": true, + }, + }, + "inserted": { + "selectedElementIds": {}, + }, + }, + }, + "elements": { + "added": {}, + "removed": { + "id0": { + "deleted": { + "isDeleted": false, + "version": 8, + }, + "inserted": { + "isDeleted": true, + "version": 5, + }, + }, + "id1": { + "deleted": { + "isDeleted": false, + "version": 8, + }, + "inserted": { + "isDeleted": true, + "version": 5, + }, + }, + "id2": { + "deleted": { + "isDeleted": false, + "version": 5, + }, + "inserted": { + "isDeleted": true, + "version": 4, + }, + }, + }, + "updated": { + "id13": { + "deleted": { + "endBinding": { + "elementId": "id2", + "fixedPoint": [ + 0, + "0.50010", + ], + "mode": "orbit", + }, + "startBinding": { + "elementId": "id0", + "fixedPoint": [ + 1, + "0.50010", + ], + "mode": "orbit", + }, + "version": 13, + }, + "inserted": { + "endBinding": null, + "startBinding": null, + "version": 11, + }, + }, + }, + }, + "id": "id24", + }, +] +`; exports[`history > singleplayer undo/redo > should support bidirectional bindings > should unbind rectangles from arrow on deletion and rebind on undo > [end of test] undo stack 1`] = ` [ @@ -19514,6 +19818,53 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding }, "id": "id15", }, + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id0": true, + }, + "selectedLinearElement": null, + }, + "inserted": { + "selectedElementIds": { + "id13": true, + }, + "selectedLinearElement": { + "elementId": "id13", + "isEditing": false, + }, + }, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": {}, + }, + "id": "id18", + }, + { + "appState": AppStateDelta { + "delta": Delta { + "deleted": { + "selectedElementIds": { + "id2": true, + }, + }, + "inserted": { + "selectedElementIds": {}, + }, + }, + }, + "elements": { + "added": {}, + "removed": {}, + "updated": {}, + }, + "id": "id21", + }, ] `; diff --git a/packages/excalidraw/tests/history.test.tsx b/packages/excalidraw/tests/history.test.tsx index 5575f9c5cf..124a17fb24 100644 --- a/packages/excalidraw/tests/history.test.tsx +++ b/packages/excalidraw/tests/history.test.tsx @@ -1639,14 +1639,12 @@ describe("history", () => { expect(arrow.startBinding).toEqual({ elementId: rect1.id, fixedPoint: expect.arrayContaining([1, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(arrow.endBinding).toEqual({ elementId: rect2.id, fixedPoint: expect.arrayContaining([0, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(rect1.boundElements).toStrictEqual([ { id: text.id, type: "text" }, @@ -1664,14 +1662,12 @@ describe("history", () => { expect(arrow.startBinding).toEqual({ elementId: rect1.id, fixedPoint: expect.arrayContaining([1, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(arrow.endBinding).toEqual({ elementId: rect2.id, fixedPoint: expect.arrayContaining([0, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(h.elements).toEqual([ expect.objectContaining({ @@ -1689,14 +1685,12 @@ describe("history", () => { expect(arrow.startBinding).toEqual({ elementId: rect1.id, fixedPoint: expect.arrayContaining([1, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(arrow.endBinding).toEqual({ elementId: rect2.id, fixedPoint: expect.arrayContaining([0, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(h.elements).toEqual([ expect.objectContaining({ @@ -1722,14 +1716,12 @@ describe("history", () => { expect(arrow.startBinding).toEqual({ elementId: rect1.id, fixedPoint: expect.arrayContaining([1, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(arrow.endBinding).toEqual({ elementId: rect2.id, fixedPoint: expect.arrayContaining([0, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(h.elements).toEqual([ expect.objectContaining({ @@ -1747,14 +1739,12 @@ describe("history", () => { expect(arrow.startBinding).toEqual({ elementId: rect1.id, fixedPoint: expect.arrayContaining([1, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(arrow.endBinding).toEqual({ elementId: rect2.id, fixedPoint: expect.arrayContaining([0, 0.5001]), - focus: 0, - gap: 0, + mode: "orbit", }); expect(h.elements).toEqual([ expect.objectContaining({ @@ -1803,13 +1793,19 @@ describe("history", () => { id: arrow.id, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: true, }), @@ -1848,13 +1844,19 @@ describe("history", () => { id: arrow.id, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: false, }), @@ -1892,8 +1894,11 @@ describe("history", () => { startBinding: null, endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: false, }), @@ -1927,13 +1932,19 @@ describe("history", () => { id: arrow.id, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: false, }), @@ -2000,13 +2011,19 @@ describe("history", () => { id: arrow.id, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: false, }), @@ -4581,13 +4598,19 @@ describe("history", () => { id: arrowId, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), }), ]), @@ -4715,13 +4738,19 @@ describe("history", () => { id: arrowId, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), }), ]), @@ -4907,8 +4936,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }), endBinding: expect.objectContaining({ // now we are back in the previous state! @@ -4917,8 +4945,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }), }), expect.objectContaining({ @@ -4987,8 +5014,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, @@ -4996,8 +5022,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }), isDeleted: true, }), @@ -5027,8 +5052,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }, endBinding: expect.objectContaining({ elementId: rect2.id, @@ -5036,8 +5060,7 @@ describe("history", () => { expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber(), ], - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + mode: "orbit", }), isDeleted: false, }), @@ -5126,13 +5149,19 @@ describe("history", () => { id: arrowId, startBinding: expect.objectContaining({ elementId: rect1.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), endBinding: expect.objectContaining({ elementId: rect2.id, - focus: expect.toBeNonNaNNumber(), - gap: expect.toBeNonNaNNumber(), + fixedPoint: expect.arrayContaining([ + expect.toBeNonNaNNumber(), + expect.toBeNonNaNNumber(), + ]), + mode: "orbit", }), isDeleted: false, }),