Fix tests for stats

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-04-04 14:59:46 +02:00
parent eecabccf8d
commit c3924a8f8c
2 changed files with 30 additions and 22 deletions

View file

@ -128,7 +128,7 @@ describe("binding with linear elements", () => {
restoreOriginalGetBoundingClientRect(); restoreOriginalGetBoundingClientRect();
}); });
it("should remain bound to linear element even on small position change", async () => { 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,10 +137,10 @@ 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);
}); });
it("should remain bound to linear element on any angle change", async () => { it("should not remain bound to linear element on any angle change", async () => {
const linear = h.elements[1] as ExcalidrawLinearElement; const linear = h.elements[1] as ExcalidrawLinearElement;
const inputAngle = UI.queryStatsProperty("A")?.querySelector( const inputAngle = UI.queryStatsProperty("A")?.querySelector(
".drag-input", ".drag-input",
@ -148,7 +148,7 @@ describe("binding with linear elements", () => {
expect(linear.startBinding).not.toBe(null); expect(linear.startBinding).not.toBe(null);
UI.updateInput(inputAngle, String("1")); UI.updateInput(inputAngle, String("1"));
expect(linear.startBinding).not.toBe(null); expect(linear.startBinding).toBe(null);
}); });
it("should unbind linear element on large position change", async () => { it("should unbind linear element on large position change", async () => {

View file

@ -295,10 +295,10 @@ History {
"deleted": { "deleted": {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"focus": "0.01026", "focus": "0.01065",
"gap": 5, "gap": 5,
}, },
"height": "0.96335", "height": "1.00000",
"points": [ "points": [
[ [
0, 0,
@ -306,12 +306,12 @@ History {
], ],
[ [
"92.92893", "92.92893",
"-0.96335", "-1.00000",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"focus": "0.03078", "focus": "0.03194",
"gap": 5, "gap": 5,
}, },
"width": "92.92893", "width": "92.92893",
@ -322,7 +322,7 @@ History {
"focus": "-0.02000", "focus": "-0.02000",
"gap": 5, "gap": 5,
}, },
"height": 0, "height": "0.00002",
"points": [ "points": [
[ [
0, 0,
@ -330,7 +330,7 @@ History {
], ],
[ [
"92.92893", "92.92893",
0, "0.00002",
], ],
], ],
"startBinding": { "startBinding": {
@ -404,15 +404,17 @@ History {
], ],
], ],
"startBinding": null, "startBinding": null,
"width": "96.42891",
"x": "3.53553",
"y": 0, "y": 0,
}, },
"inserted": { "inserted": {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"focus": "0.01026", "focus": "0.01065",
"gap": 5, "gap": 5,
}, },
"height": "0.96335", "height": "1.00000",
"points": [ "points": [
[ [
0, 0,
@ -420,15 +422,17 @@ History {
], ],
[ [
"92.92893", "92.92893",
"-0.96335", "-1.00000",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"focus": "0.03078", "focus": "0.03194",
"gap": 5, "gap": 5,
}, },
"y": "1.00000", "width": "92.92893",
"x": "3.53553",
"y": "1.03376",
}, },
}, },
"id175" => Delta { "id175" => Delta {
@ -822,8 +826,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 30, "version": 30,
"width": "0.00000", "width": "96.46447",
"x": "146.46447", "x": 150,
"y": 0, "y": 0,
} }
`; `;
@ -856,11 +860,11 @@ History {
0, 0,
], ],
[ [
"-0.00000", 0,
0, 0,
], ],
], ],
"width": "0.00000", "width": 0,
}, },
"inserted": { "inserted": {
"points": [ "points": [
@ -869,11 +873,11 @@ History {
0, 0,
], ],
[ [
"92.92893", "89.39340",
0, 0,
], ],
], ],
"width": "92.92893", "width": "89.39340",
}, },
}, },
}, },
@ -930,6 +934,8 @@ History {
], ],
], ],
"startBinding": null, "startBinding": null,
"width": "96.46447",
"x": 150,
}, },
"inserted": { "inserted": {
"endBinding": { "endBinding": {
@ -943,7 +949,7 @@ History {
0, 0,
], ],
[ [
"-0.00000", 0,
0, 0,
], ],
], ],
@ -952,6 +958,8 @@ History {
"focus": 0, "focus": 0,
"gap": 5, "gap": 5,
}, },
"width": 0,
"x": "146.46447",
}, },
}, },
}, },