Browse Source

FIx tests

Mark Tolmacs 5 months ago
parent
commit
3fa818b0ce

+ 12 - 11
packages/element/tests/elbowArrow.test.tsx

@@ -78,8 +78,8 @@ describe("elbow arrow segment move", () => {
     expect(arrow.points).toCloselyEqualPoints([
       [0, 0],
       [110, 0],
-      [110, 195.01],
-      [190, 195.01],
+      [110, 200],
+      [190, 200],
     ]);
 
     mouse.reset();
@@ -89,8 +89,8 @@ describe("elbow arrow segment move", () => {
     expect(arrow.points).toCloselyEqualPoints([
       [0, 0],
       [110, 0],
-      [110, 195.01],
-      [190, 195.01],
+      [110, 200],
+      [190, 200],
     ]);
   });
 
@@ -201,8 +201,8 @@ describe("elbow arrow routing", () => {
     expect(arrow.points).toCloselyEqualPoints([
       [0, 0],
       [45, 0],
-      [45, 199.07],
-      [90.07, 199.07],
+      [45, 206.55],
+      [90, 206.55],
     ]);
   });
 });
@@ -255,8 +255,8 @@ describe("elbow arrow ui", () => {
     expect(arrow.points).toCloselyEqualPoints([
       [0, 0],
       [45, 0],
-      [45, 195.01],
-      [90, 195.01],
+      [45, 200],
+      [90, 200],
     ]);
   });
 
@@ -293,11 +293,12 @@ describe("elbow arrow ui", () => {
       ".drag-input",
     ) as HTMLInputElement;
     UI.updateInput(inputAngle, String("40"));
-console.log(JSON.stringify(h.elements))
+
     expect(arrow.points.map((point) => point.map(Math.round))).toEqual([
       [0, 0],
-      [109, 0],
-      [109, 152],
+      [35, 0],
+      [35, 183],
+      [96, 183],
     ]);
   });
 

+ 3 - 3
packages/element/tests/resize.test.tsx

@@ -511,12 +511,12 @@ describe("arrow element", () => {
     )[0] as ExcalidrawElbowArrowElement;
 
     expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
-    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.78);
+    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
 
     UI.resize(rectangle, "se", [-200, -150]);
 
     expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
-    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.78);
+    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
   });
 
   it("flips the fixed point binding on negative resize for group selection", () => {
@@ -539,7 +539,7 @@ describe("arrow element", () => {
     )[0] as ExcalidrawElbowArrowElement;
 
     expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
-    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.78);
+    expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.79);
 
     UI.resize([rectangle, arrow], "nw", [300, 350]);
     expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(0);

+ 30 - 18
packages/excalidraw/tests/__snapshots__/history.test.tsx.snap

@@ -197,7 +197,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
   "fillStyle": "solid",
   "frameId": null,
   "groupIds": [],
-  "height": "99.23572",
+  "height": "99.58947",
   "id": "id172",
   "index": "a2",
   "isDeleted": false,
@@ -211,8 +211,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
       0,
     ],
     [
-      "96.42891",
-      "99.23572",
+      "99.58947",
+      "99.58947",
     ],
   ],
   "roughness": 1,
@@ -227,8 +227,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
   "type": "arrow",
   "updated": 1,
   "version": 40,
-  "width": "96.42891",
-  "x": "3.53553",
+  "width": "99.58947",
+  "x": 0,
   "y": 0,
 }
 `;
@@ -297,7 +297,7 @@ History {
                 "focus": "0.00990",
                 "gap": 5,
               },
-              "height": "0.92998",
+              "height": "0.92900",
               "points": [
                 [
                   0,
@@ -305,7 +305,7 @@ History {
                 ],
                 [
                   "92.92893",
-                  "-0.92998",
+                  "-0.92900",
                 ],
               ],
               "startBinding": {
@@ -313,14 +313,15 @@ History {
                 "focus": "0.02970",
                 "gap": 5,
               },
+              "width": "92.92893",
             },
             "inserted": {
               "endBinding": {
                 "elementId": "id171",
-                "focus": "-0.02000",
+                "focus": "-0.02052",
                 "gap": 5,
               },
-              "height": "0.00611",
+              "height": "0.04625",
               "points": [
                 [
                   0,
@@ -328,14 +329,15 @@ History {
                 ],
                 [
                   "92.92893",
-                  "0.00611",
+                  "0.04625",
                 ],
               ],
               "startBinding": {
                 "elementId": "id170",
-                "focus": "0.02000",
+                "focus": "0.01841",
                 "gap": 5,
               },
+              "width": "92.92893",
             },
           },
         },
@@ -389,18 +391,20 @@ History {
                 "focus": 0,
                 "gap": 1,
               },
-              "height": "99.23572",
+              "height": "99.58947",
               "points": [
                 [
                   0,
                   0,
                 ],
                 [
-                  "96.42891",
-                  "99.23572",
+                  "99.58947",
+                  "99.58947",
                 ],
               ],
               "startBinding": null,
+              "width": "99.58947",
+              "x": 0,
               "y": 0,
             },
             "inserted": {
@@ -409,7 +413,7 @@ History {
                 "focus": "0.00990",
                 "gap": 5,
               },
-              "height": "0.93503",
+              "height": "0.92678",
               "points": [
                 [
                   0,
@@ -417,7 +421,7 @@ History {
                 ],
                 [
                   "92.92893",
-                  "-0.93503",
+                  "-0.92678",
                 ],
               ],
               "startBinding": {
@@ -425,7 +429,9 @@ History {
                 "focus": "0.02970",
                 "gap": 5,
               },
-              "y": "0.97365",
+              "width": "92.92893",
+              "x": "3.53553",
+              "y": "0.96071",
             },
           },
           "id175" => Delta {
@@ -856,6 +862,7 @@ History {
                   0,
                 ],
               ],
+              "width": 0,
             },
             "inserted": {
               "points": [
@@ -864,10 +871,11 @@ History {
                   0,
                 ],
                 [
-                  100,
+                  90,
                   0,
                 ],
               ],
+              "width": 90,
             },
           },
         },
@@ -924,6 +932,8 @@ History {
                 ],
               ],
               "startBinding": null,
+              "width": 100,
+              "x": 150,
             },
             "inserted": {
               "endBinding": {
@@ -946,6 +956,8 @@ History {
                 "focus": 0,
                 "gap": 5,
               },
+              "width": 0,
+              "x": "146.46447",
             },
           },
         },