[skip ci] Test updates

This commit is contained in:
Mark Tolmacs 2025-03-29 17:04:58 +01:00
parent bcbd418154
commit a79eb06939
3 changed files with 58 additions and 48 deletions

View file

@ -73,12 +73,12 @@ describe("flipping re-centers selection", () => {
API.executeAction(actionFlipHorizontal); API.executeAction(actionFlipHorizontal);
const rec1 = h.elements.find((el) => el.id === "rec1")!; const rec1 = h.elements.find((el) => el.id === "rec1")!;
expect(rec1.x).toBeCloseTo(100, 0); expect(Math.floor(rec1.x)).toBeCloseTo(100, 0);
expect(rec1.y).toBeCloseTo(100, 0); expect(Math.floor(rec1.y)).toBeCloseTo(100, 0);
const rec2 = h.elements.find((el) => el.id === "rec2")!; const rec2 = h.elements.find((el) => el.id === "rec2")!;
expect(rec2.x).toBeCloseTo(220, 0); expect(Math.floor(rec2.x)).toBeCloseTo(220, 0);
expect(rec2.y).toBeCloseTo(250, 0); expect(Math.floor(rec2.y)).toBeCloseTo(250, 0);
}); });
}); });

View file

@ -128,7 +128,12 @@ describe("binding with linear elements", () => {
restoreOriginalGetBoundingClientRect(); restoreOriginalGetBoundingClientRect();
}); });
it("should remain bound to linear element on small position change", async () => { // UX RATIONALE: Since we force a fixed distance from elements angle changes
// would result in a "jump" the moment the bound object is moved
it(
"should not remain bound to linear element even" +
" on small position change",
async () => {
const linear = h.elements[1] as ExcalidrawLinearElement; const linear = h.elements[1] as ExcalidrawLinearElement;
const inputX = UI.queryStatsProperty("X")?.querySelector( const inputX = UI.queryStatsProperty("X")?.querySelector(
".drag-input", ".drag-input",
@ -137,8 +142,9 @@ describe("binding with linear elements", () => {
expect(linear.startBinding).not.toBe(null); expect(linear.startBinding).not.toBe(null);
expect(inputX).not.toBeNull(); expect(inputX).not.toBeNull();
UI.updateInput(inputX, String("204")); UI.updateInput(inputX, String("204"));
expect(linear.startBinding).not.toBe(null); expect(linear.startBinding).toBe(null);
}); },
);
// UX RATIONALE: Since we force a fixed distance from elements angle changes // UX RATIONALE: Since we force a fixed distance from elements angle changes
// would result in a "jump" the moment the bound object is moved // would result in a "jump" the moment the bound object is moved

View file

@ -295,10 +295,10 @@ History {
"deleted": { "deleted": {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"focus": "0.01140", "focus": "0.01026",
"gap": 5, "gap": 5,
}, },
"height": "1.00000", "height": "0.96335",
"points": [ "points": [
[ [
0, 0,
@ -306,14 +306,15 @@ History {
], ],
[ [
"92.92893", "92.92893",
"-1.00000", "-0.96335",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"focus": "0.03119", "focus": "0.03078",
"gap": 5, "gap": 5,
}, },
"width": "92.92893",
}, },
"inserted": { "inserted": {
"endBinding": { "endBinding": {
@ -337,6 +338,7 @@ History {
"focus": "0.02000", "focus": "0.02000",
"gap": 5, "gap": 5,
}, },
"width": "92.92893",
}, },
}, },
}, },
@ -407,10 +409,10 @@ History {
"inserted": { "inserted": {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"focus": "0.01140", "focus": "0.01026",
"gap": 5, "gap": 5,
}, },
"height": "1.00000", "height": "0.96335",
"points": [ "points": [
[ [
0, 0,
@ -418,12 +420,12 @@ History {
], ],
[ [
"92.92893", "92.92893",
"-1.00000", "-0.96335",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"focus": "0.03119", "focus": "0.03078",
"gap": 5, "gap": 5,
}, },
"y": "1.00000", "y": "1.00000",
@ -566,7 +568,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -580,7 +582,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -804,7 +806,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -854,10 +856,11 @@ History {
0, 0,
], ],
[ [
"0.00000", "-0.00000",
0, 0,
], ],
], ],
"width": "0.00000",
}, },
"inserted": { "inserted": {
"points": [ "points": [
@ -870,6 +873,7 @@ History {
0, 0,
], ],
], ],
"width": "92.92893",
}, },
}, },
}, },
@ -921,7 +925,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -939,7 +943,7 @@ History {
0, 0,
], ],
[ [
"0.00000", "-0.00000",
0, 0,
], ],
], ],
@ -1074,7 +1078,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -1088,7 +1092,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -2499,7 +2503,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -2517,7 +2521,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -15242,7 +15246,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -15255,7 +15259,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -15550,7 +15554,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -15568,7 +15572,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -16170,7 +16174,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -16188,7 +16192,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -16790,7 +16794,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -16808,7 +16812,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -17193,7 +17197,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -17210,7 +17214,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -17478,7 +17482,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -17496,7 +17500,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },
@ -17921,7 +17925,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -17939,7 +17943,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -18207,7 +18211,7 @@ History {
0, 0,
], ],
[ [
"92.92893", "96.46447",
0, 0,
], ],
], ],
@ -18225,7 +18229,7 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "92.92893", "width": "96.46447",
"x": "3.53553", "x": "3.53553",
"y": 0, "y": 0,
}, },