Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix: flaky snapshot tests with floating point precision issues (#8049)

Marcel Mraz661d6a4a7523
diff --git a/packages/excalidraw/element/textWysiwyg.test.tsx b/packages/excalidraw/element/textWysiwyg.test.tsx
index 5691874fb4..204e1a6905 100644
--- a/packages/excalidraw/element/textWysiwyg.test.tsx
+++ b/packages/excalidraw/element/textWysiwyg.test.tsx
@@ -1064,7 +1064,7 @@ describe("textWysiwyg", () => {
expect([h.elements[1].x, h.elements[1].y]).toMatchInlineSnapshot(`
[
85,
- 4.999999999999986,
+ "5.00000",
]
`);
@@ -1109,8 +1109,8 @@ describe("textWysiwyg", () => {
UI.resize(rectangle, "ne", [rectangle.x + 100, rectangle.y - 100]);
expect([h.elements[1].x, h.elements[1].y]).toMatchInlineSnapshot(`
[
- 374.99999999999994,
- -535.0000000000001,
+ "375.00000",
+ "-535.00000",
]
`);
});
diff --git a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap
index 712bf1a711..b03780dcef 100644
--- a/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap
+++ b/packages/excalidraw/tests/__snapshots__/contextmenu.test.tsx.snap
@@ -27,7 +27,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -130,7 +130,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -182,7 +182,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -248,7 +248,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -288,7 +288,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -406,7 +406,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -453,7 +453,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -505,7 +505,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -554,7 +554,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -603,7 +603,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -643,7 +643,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4448,7 +4448,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4551,7 +4551,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4603,7 +4603,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4669,7 +4669,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4709,7 +4709,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -4827,7 +4827,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4874,7 +4874,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4926,7 +4926,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -4975,7 +4975,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -5024,7 +5024,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5064,7 +5064,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5567,7 +5567,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5670,7 +5670,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5722,7 +5722,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5788,7 +5788,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5828,7 +5828,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -5946,7 +5946,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -5993,7 +5993,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -6045,7 +6045,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -6094,7 +6094,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -6143,7 +6143,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6183,7 +6183,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6741,7 +6741,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -6793,7 +6793,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7005,7 +7005,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7061,7 +7061,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7105,7 +7105,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7158,7 +7158,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
<g
fill="none"
stroke="currentColor"
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7200,7 +7200,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7393,7 +7393,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7496,7 +7496,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7548,7 +7548,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7614,7 +7614,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7654,7 +7654,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -7772,7 +7772,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7819,7 +7819,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7871,7 +7871,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7920,7 +7920,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -7969,7 +7969,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8009,7 +8009,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8279,7 +8279,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8382,7 +8382,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8434,7 +8434,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8500,7 +8500,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8540,7 +8540,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8658,7 +8658,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8705,7 +8705,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8757,7 +8757,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8806,7 +8806,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.5}
+ strokeWidth={"1.50000"}
>
<path
d="M0 0h24v24H0z"
@@ -8855,7 +8855,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
@@ -8895,7 +8895,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap
viewBox="0 0 24 24"
>
<g
- strokeWidth={1.25}
+ strokeWidth={"1.25000"}
>
<path
d="M0 0h24v24H0z"
diff --git a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap
index 89e937151c..178785ee90 100644
--- a/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap
+++ b/packages/excalidraw/tests/__snapshots__/history.test.tsx.snap
@@ -181,7 +181,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 99.19725525211979,
+ "height": "99.19726",
"id": "id163",
"index": "a2",
"isDeleted": false,
@@ -195,8 +195,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0,
],
[
- 98.40367721010284,
- 99.19725525211979,
+ "98.40368",
+ "99.19726",
],
],
"roughness": 1,
@@ -211,7 +211,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow",
"updated": 1,
"version": 54,
- "width": 98.40367721010284,
+ "width": "98.40368",
"x": 1,
"y": 0,
}
@@ -278,10 +278,10 @@ History {
"deleted": {
"endBinding": {
"elementId": "id162",
- "focus": 0.009900990099009901,
+ "focus": "0.00990",
"gap": 1,
},
- "height": 0.9800031696987099,
+ "height": "0.98000",
"points": [
[
0,
@@ -289,22 +289,22 @@ History {
],
[
98,
- -0.9800031696987099,
+ "-0.98000",
],
],
"startBinding": {
"elementId": "id161",
- "focus": 0.0297029702970297,
+ "focus": "0.02970",
"gap": 1,
},
},
"inserted": {
"endBinding": {
"elementId": "id162",
- "focus": -0.02,
+ "focus": "-0.02000",
"gap": 1,
},
- "height": 0.0002487679019458344,
+ "height": "0.00025",
"points": [
[
0,
@@ -312,12 +312,12 @@ History {
],
[
98,
- 0.0002487679019458344,
+ "0.00025",
],
],
"startBinding": {
"elementId": "id161",
- "focus": 0.02,
+ "focus": "0.02000",
"gap": 1,
},
},
@@ -369,15 +369,15 @@ History {
"focus": 0,
"gap": 1,
},
- "height": 99.19725525211979,
+ "height": "99.19726",
"points": [
[
0,
0,
],
[
- 98.40367721010284,
- 99.19725525211979,
+ "98.40368",
+ "99.19726",
],
],
"startBinding": null,
@@ -386,10 +386,10 @@ History {
"inserted": {
"endBinding": {
"elementId": "id162",
- "focus": 0.009900990099009901,
+ "focus": "0.00990",
"gap": 1,
},
- "height": 0.9802432787444684,
+ "height": "0.98024",
"points": [
[
0,
@@ -397,15 +397,15 @@ History {
],
[
98,
- -0.9802432787444684,
+ "-0.98024",
],
],
"startBinding": {
"elementId": "id161",
- "focus": 0.0297029702970297,
+ "focus": "0.02970",
"gap": 1,
},
- "y": 0.9903686540602428,
+ "y": "0.99037",
},
},
"id166" => Delta {
@@ -1188,7 +1188,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 0.03596020595764898,
+ "height": "0.03596",
"id": "id169",
"index": "Zz",
"isDeleted": false,
@@ -1203,7 +1203,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
],
[
98,
- -0.03596020595764898,
+ "-0.03596",
],
],
"roughness": 1,
@@ -1224,7 +1224,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"version": 15,
"width": 98,
"x": 1,
- "y": 0.05467419069071122,
+ "y": "0.05467",
}
`;
@@ -1531,7 +1531,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 0.03596020595764898,
+ "height": "0.03596",
"id": "id172",
"index": "a0",
"isDeleted": false,
@@ -1546,7 +1546,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
],
[
98,
- -0.03596020595764898,
+ "-0.03596",
],
],
"roughness": 1,
@@ -1567,7 +1567,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"version": 15,
"width": 98,
"x": 1,
- "y": 0.05467419069071122,
+ "y": "0.05467",
}
`;
@@ -1680,7 +1680,7 @@ History {
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 2.6199110083015196,
+ "height": "2.61991",
"index": "a0",
"isDeleted": false,
"lastCommittedPoint": null,
@@ -1694,7 +1694,7 @@ History {
],
[
98,
- -2.6199110083015196,
+ "-2.61991",
],
],
"roughness": 1,
@@ -1713,7 +1713,7 @@ History {
"type": "arrow",
"width": 98,
"x": 1,
- "y": 3.98333408405027,
+ "y": "3.98333",
},
"inserted": {
"isDeleted": true,
@@ -2206,7 +2206,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 373.7994222717614,
+ "height": "373.79942",
"id": "id177",
"index": "a2",
"isDeleted": false,
@@ -2221,7 +2221,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
],
[
498,
- -373.7994222717614,
+ "-373.79942",
],
],
"roughness": 1,
@@ -2242,7 +2242,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"version": 12,
"width": 498,
"x": 1,
- "y": -37.91991400161248,
+ "y": "-37.91991",
}
`;
@@ -2598,7 +2598,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id143",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -2639,7 +2639,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id144",
"index": "a2",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -2889,7 +2889,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id146",
"index": "a0",
"isDeleted": true,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -2930,7 +2930,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id147",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -3165,7 +3165,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id134",
"index": "a0V",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -3206,7 +3206,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id133",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -3483,7 +3483,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id136",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -3724,7 +3724,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id131",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -3956,7 +3956,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id139",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -4207,7 +4207,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id141",
"index": "a0",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -4267,7 +4267,7 @@ History {
"height": 25,
"index": "a0",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -4472,7 +4472,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id155",
"index": "a0",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -4695,7 +4695,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id153",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -4913,7 +4913,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id149",
"index": "a1",
"isDeleted": true,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -5139,7 +5139,7 @@ exports[`history > multiplayer undo/redo > conflicts in bound text elements and
"id": "id151",
"index": "a0",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -13995,7 +13995,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"id": "id51",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -14015,7 +14015,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
}
`;
@@ -14254,7 +14254,7 @@ History {
"height": 100,
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -14389,7 +14389,7 @@ History {
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
},
"inserted": {
"containerId": null,
@@ -14677,7 +14677,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"id": "id45",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -14697,7 +14697,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
}
`;
@@ -14860,7 +14860,7 @@ History {
"height": 100,
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -14995,7 +14995,7 @@ History {
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
},
"inserted": {
"containerId": null,
@@ -15283,7 +15283,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"id": "id57",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -15303,7 +15303,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
}
`;
@@ -15466,7 +15466,7 @@ History {
"height": 100,
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -15601,7 +15601,7 @@ History {
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
},
"inserted": {
"containerId": null,
@@ -15887,7 +15887,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"id": "id63",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -15907,7 +15907,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
}
`;
@@ -16140,7 +16140,7 @@ History {
"height": 100,
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -16275,7 +16275,7 @@ History {
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
},
"inserted": {
"containerId": null,
@@ -16587,7 +16587,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"id": "id70",
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -16607,7 +16607,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
}
`;
@@ -16855,7 +16855,7 @@ History {
"height": 100,
"index": "a1",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -16990,7 +16990,7 @@ History {
"verticalAlign": "middle",
"width": 30,
"x": -65,
- "y": -12.5,
+ "y": "-12.50000",
},
"inserted": {
"containerId": null,
diff --git a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap
index 9734378c19..958a8c88cc 100644
--- a/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap
+++ b/packages/excalidraw/tests/__snapshots__/move.test.tsx.snap
@@ -189,13 +189,13 @@ exports[`move element > rectangles with binding arrow 7`] = `
"endArrowhead": "arrow",
"endBinding": {
"elementId": "id1",
- "focus": -0.46666666666666673,
+ "focus": "-0.46667",
"gap": 10,
},
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
- "height": 81.48231043525051,
+ "height": "81.48231",
"id": "id2",
"index": "a2",
"isDeleted": false,
@@ -210,7 +210,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
],
[
81,
- 81.48231043525051,
+ "81.48231",
],
],
"roughness": 1,
@@ -221,7 +221,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"startArrowhead": null,
"startBinding": {
"elementId": "id0",
- "focus": -0.6000000000000001,
+ "focus": "-0.60000",
"gap": 10,
},
"strokeColor": "#1e1e1e",
@@ -233,6 +233,6 @@ exports[`move element > rectangles with binding arrow 7`] = `
"versionNonce": 2066753033,
"width": 81,
"x": 110,
- "y": 49.981789081137734,
+ "y": "49.98179",
}
`;
diff --git a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap
index 611d7c559c..cc5afc98da 100644
--- a/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap
+++ b/packages/excalidraw/tests/__snapshots__/regressionTests.test.tsx.snap
@@ -10758,7 +10758,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = `
"pendingImageElementId": null,
"previousSelectedElementIds": {},
"resizingElement": null,
- "scrollX": -6.2500000000000036,
+ "scrollX": "-6.25000",
"scrollY": 0,
"scrolledOutside": false,
"selectedElementIds": {},
@@ -13697,7 +13697,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`]
"previousSelectedElementIds": {},
"resizingElement": null,
"scrollX": 20,
- "scrollY": -18.535533905932738,
+ "scrollY": "-18.53553",
"scrolledOutside": false,
"selectedElementIds": {},
"selectedElementsAreBeingDragged": false,
diff --git a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap
index 459b95da45..945a99ea2c 100644
--- a/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap
+++ b/packages/excalidraw/tests/data/__snapshots__/restore.test.ts.snap
@@ -316,7 +316,7 @@ exports[`restoreElements > should restore text element correctly passing value f
"id": "id-text01",
"index": "a0",
"isDeleted": false,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
@@ -338,7 +338,7 @@ exports[`restoreElements > should restore text element correctly passing value f
"verticalAlign": "middle",
"width": 100,
"x": -20,
- "y": -8.75,
+ "y": "-8.75000",
}
`;
@@ -359,7 +359,7 @@ exports[`restoreElements > should restore text element correctly with unknown fo
"id": "id-text01",
"index": "a0",
"isDeleted": true,
- "lineHeight": 1.25,
+ "lineHeight": "1.25000",
"link": null,
"locked": false,
"opacity": 100,
diff --git a/packages/excalidraw/tests/linearElementEditor.test.tsx b/packages/excalidraw/tests/linearElementEditor.test.tsx
index 0e1eed10ee..547c527553 100644
--- a/packages/excalidraw/tests/linearElementEditor.test.tsx
+++ b/packages/excalidraw/tests/linearElementEditor.test.tsx
@@ -319,12 +319,12 @@ describe("Test Linear Elements", () => {
expect(midPointsWithRoundEdge).toMatchInlineSnapshot(`
[
[
- 55.9697848965255,
- 47.442326230998205,
+ "55.96978",
+ "47.44233",
],
[
- 76.08587175006699,
- 43.294165939653226,
+ "76.08587",
+ "43.29417",
],
]
`);
@@ -381,12 +381,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
- 105.96978489652551,
- 67.4423262309982,
+ "105.96978",
+ "67.44233",
],
[
- 126.08587175006699,
- 63.294165939653226,
+ "126.08587",
+ "63.29417",
],
]
`);
@@ -627,16 +627,16 @@ describe("Test Linear Elements", () => {
0,
],
[
- 85.96978489652551,
- 77.4423262309982,
+ "85.96978",
+ "77.44233",
],
[
70,
50,
],
[
- 106.08587175006699,
- 73.29416593965323,
+ "106.08587",
+ "73.29417",
],
[
40,
@@ -683,12 +683,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
- 31.884084517616053,
- 23.13275505472383,
+ "31.88408",
+ "23.13276",
],
[
- 77.74792546875662,
- 44.57840982272327,
+ "77.74793",
+ "44.57841",
],
]
`);
@@ -769,12 +769,12 @@ describe("Test Linear Elements", () => {
expect(newMidPoints).toMatchInlineSnapshot(`
[
[
- 55.9697848965255,
- 47.442326230998205,
+ "55.96978",
+ "47.44233",
],
[
- 76.08587175006699,
- 43.294165939653226,
+ "76.08587",
+ "43.29417",
],
]
`);
@@ -928,8 +928,8 @@ describe("Test Linear Elements", () => {
);
expect(position).toMatchInlineSnapshot(`
{
- "x": 85.82201843191861,
- "y": 75.63461309860818,
+ "x": "85.82202",
+ "y": "75.63461",
}
`);
});
@@ -1068,15 +1068,15 @@ describe("Test Linear Elements", () => {
true,
),
).toMatchInlineSnapshot(`
- [
- 20,
- 20,
- 105,
- 80,
- 55.45893770831013,
- 45,
- ]
- `);
+ [
+ 20,
+ 20,
+ 105,
+ 80,
+ "55.45894",
+ 45,
+ ]
+ `);
UI.resize(container, "ne", [300, 200]);
@@ -1084,7 +1084,7 @@ describe("Test Linear Elements", () => {
.toMatchInlineSnapshot(`
{
"height": 130,
- "width": 366.11716195150507,
+ "width": "366.11716",
}
`);
@@ -1095,11 +1095,11 @@ describe("Test Linear Elements", () => {
arrayToMap(h.elements),
),
).toMatchInlineSnapshot(`
- {
- "x": 271.11716195150507,
- "y": 45,
- }
- `);
+ {
+ "x": "271.11716",
+ "y": 45,
+ }
+ `);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
@@ -1112,15 +1112,15 @@ describe("Test Linear Elements", () => {
true,
),
).toMatchInlineSnapshot(`
- [
- 20,
- 35,
- 501.11716195150507,
- 95,
- 205.4589377083102,
- 52.5,
- ]
- `);
+ [
+ 20,
+ 35,
+ "501.11716",
+ 95,
+ "205.45894",
+ "52.50000",
+ ]
+ `);
});
it("should resize and position the bound text correctly when 2 pointer linear element resized", () => {
diff --git a/packages/excalidraw/tests/test-utils.ts b/packages/excalidraw/tests/test-utils.ts
index c1e8af40f5..607b5c35a9 100644
--- a/packages/excalidraw/tests/test-utils.ts
+++ b/packages/excalidraw/tests/test-utils.ts
@@ -242,3 +242,20 @@ expect.extend({
};
},
});
+
+/**
+ * Serializer for IEE754 float pointing numbers to avoid random failures due to tiny precision differences
+ */
+expect.addSnapshotSerializer({
+ serialize(val, config, indentation, depth, refs, printer) {
+ return printer(val.toFixed(5), config, indentation, depth, refs);
+ },
+ test(val) {
+ return (
+ typeof val === "number" &&
+ Number.isFinite(val) &&
+ !Number.isNaN(val) &&
+ !Number.isInteger(val)
+ );
+ },
+});