Adapting tests to a more precise tracking

feat/remove-ga
Mark Tolmacs 3 weeks ago
parent 3e1439ad86
commit da6a39834d
No known key found for this signature in database

@ -89,8 +89,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"endBinding": { "endBinding": {
"elementId": "ellipse-1", "elementId": "ellipse-1",
"fixedPoint": null, "fixedPoint": null,
"focus": -0.008153707962747813, "focus": -0.008835048729392623,
"gap": 1, "gap": 11.562288374879595,
}, },
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
@ -120,7 +120,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"startBinding": { "startBinding": {
"elementId": "id49", "elementId": "id49",
"fixedPoint": null, "fixedPoint": null,
"focus": -0.08139534883720931, "focus": -0.08860759493670874,
"gap": 1, "gap": 1,
}, },
"strokeColor": "#1864ab", "strokeColor": "#1864ab",
@ -147,8 +147,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"endBinding": { "endBinding": {
"elementId": "ellipse-1", "elementId": "ellipse-1",
"fixedPoint": null, "fixedPoint": null,
"focus": 0.10666666666666667, "focus": 0.1045751633986928,
"gap": 3.834326468444573, "gap": 3.8343264684446097,
}, },
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
@ -179,7 +179,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"elementId": "diamond-1", "elementId": "diamond-1",
"fixedPoint": null, "fixedPoint": null,
"focus": 0, "focus": 0,
"gap": 1, "gap": 4.545343408287929,
}, },
"strokeColor": "#e67700", "strokeColor": "#e67700",
"strokeStyle": "solid", "strokeStyle": "solid",
@ -1485,7 +1485,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
"endBinding": { "endBinding": {
"elementId": "Alice", "elementId": "Alice",
"fixedPoint": null, "fixedPoint": null,
"focus": 0, "focus": 1.7573472843231123e-16,
"gap": 5.299874999999986, "gap": 5.299874999999986,
}, },
"fillStyle": "solid", "fillStyle": "solid",
@ -1551,7 +1551,7 @@ exports[`Test Transform > should transform the elements correctly when linear el
"elementId": "B", "elementId": "B",
"fixedPoint": null, "fixedPoint": null,
"focus": 0, "focus": 0,
"gap": 1, "gap": 14,
}, },
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,

@ -197,7 +197,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": 99, "height": "102.03384",
"id": "id172", "id": "id172",
"index": "a2", "index": "a2",
"isDeleted": false, "isDeleted": false,
@ -211,8 +211,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0, 0,
], ],
[ [
"98.20800", "101.21757",
99, "102.03384",
], ],
], ],
"roughness": 1, "roughness": 1,
@ -227,7 +227,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 40, "version": 40,
"width": "98.20800", "width": "101.21757",
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -295,24 +295,24 @@ History {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"fixedPoint": null, "fixedPoint": null,
"focus": "0.00990", "focus": "0.01000",
"gap": 1, "gap": 1,
}, },
"height": "0.98017", "height": "1.38641",
"points": [ "points": [
[ [
0, 0,
0, 0,
], ],
[ [
98, "98.00000",
"-0.98017", "-1.38641",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"fixedPoint": null, "fixedPoint": null,
"focus": "0.02970", "focus": "0.03001",
"gap": 1, "gap": 1,
}, },
}, },
@ -323,7 +323,7 @@ History {
"focus": "-0.02000", "focus": "-0.02000",
"gap": 1, "gap": 1,
}, },
"height": "0.00169", "height": "0.00233",
"points": [ "points": [
[ [
0, 0,
@ -331,7 +331,7 @@ History {
], ],
[ [
98, 98,
"0.00169", "0.00233",
], ],
], ],
"startBinding": { "startBinding": {
@ -393,15 +393,15 @@ History {
"focus": 0, "focus": 0,
"gap": 1, "gap": 1,
}, },
"height": 99, "height": "102.03384",
"points": [ "points": [
[ [
0, 0,
0, 0,
], ],
[ [
"98.20800", "101.21757",
99, "102.03384",
], ],
], ],
"startBinding": null, "startBinding": null,
@ -411,10 +411,10 @@ History {
"endBinding": { "endBinding": {
"elementId": "id171", "elementId": "id171",
"fixedPoint": null, "fixedPoint": null,
"focus": "0.00990", "focus": "0.01000",
"gap": 1, "gap": 1,
}, },
"height": "0.98161", "height": "1.38842",
"points": [ "points": [
[ [
0, 0,
@ -422,16 +422,16 @@ History {
], ],
[ [
98, 98,
"-0.98161", "-1.38842",
], ],
], ],
"startBinding": { "startBinding": {
"elementId": "id170", "elementId": "id170",
"fixedPoint": null, "fixedPoint": null,
"focus": "0.02970", "focus": "0.03001",
"gap": 1, "gap": 1,
}, },
"y": "0.99245", "y": "1.40379",
}, },
}, },
"id175" => Delta { "id175" => Delta {
@ -824,8 +824,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, "width": 100,
"x": 200, "x": 150,
"y": 0, "y": 0,
} }
`; `;
@ -858,7 +858,7 @@ History {
0, 0,
], ],
[ [
0, 100,
0, 0,
], ],
], ],
@ -944,7 +944,7 @@ History {
0, 0,
], ],
[ [
0, 100,
0, 0,
], ],
], ],
@ -1246,7 +1246,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": "2.61991", "height": "2.57347",
"id": "id178", "id": "id178",
"index": "Zz", "index": "Zz",
"isDeleted": false, "isDeleted": false,
@ -1260,8 +1260,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0, 0,
], ],
[ [
"98.00000", 98,
"-2.61991", "-2.57347",
], ],
], ],
"roughness": 1, "roughness": 1,
@ -1284,9 +1284,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 11, "version": 11,
"width": "98.00000", "width": 98,
"x": "1.00000", "x": 1,
"y": "3.98333", "y": "3.91272",
} }
`; `;
@ -1617,7 +1617,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": "2.61991", "height": "2.57347",
"id": "id181", "id": "id181",
"index": "a0", "index": "a0",
"isDeleted": false, "isDeleted": false,
@ -1631,8 +1631,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0, 0,
], ],
[ [
"98.00000", 98,
"-2.61991", "-2.57347",
], ],
], ],
"roughness": 1, "roughness": 1,
@ -1655,9 +1655,9 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 11, "version": 11,
"width": "98.00000", "width": 98,
"x": "1.00000", "x": 1,
"y": "3.98333", "y": "3.91272",
} }
`; `;
@ -1775,7 +1775,7 @@ History {
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": "22.36242", "height": "22.11765",
"index": "a0", "index": "a0",
"isDeleted": false, "isDeleted": false,
"lastCommittedPoint": null, "lastCommittedPoint": null,
@ -1788,8 +1788,8 @@ History {
0, 0,
], ],
[ [
"98.00000", "98.67659",
"-22.36242", "-22.11765",
], ],
], ],
"roughness": 1, "roughness": 1,
@ -1810,9 +1810,9 @@ History {
"strokeStyle": "solid", "strokeStyle": "solid",
"strokeWidth": 2, "strokeWidth": 2,
"type": "arrow", "type": "arrow",
"width": "98.00000", "width": "98.67659",
"x": 1, "x": "0.32341",
"y": 34, "y": "33.54894",
}, },
"inserted": { "inserted": {
"isDeleted": true, "isDeleted": true,
@ -2329,7 +2329,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": "408.19672", "height": 0,
"id": "id186", "id": "id186",
"index": "a2", "index": "a2",
"isDeleted": false, "isDeleted": false,
@ -2343,8 +2343,8 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
0, 0,
], ],
[ [
498, 99,
"-408.19672", 0,
], ],
], ],
"roughness": 1, "roughness": 1,
@ -2364,7 +2364,7 @@ exports[`history > multiplayer undo/redo > conflicts in arrows and their bindabl
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 10, "version": 10,
"width": 498, "width": 99,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -15143,7 +15143,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
0, 0,
], ],
[ [
"98.00000", 98,
0, 0,
], ],
], ],
@ -15164,7 +15164,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 10, "version": 10,
"width": "98.00000", "width": 98,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -15842,7 +15842,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
0, 0,
], ],
[ [
"98.00000", 98,
0, 0,
], ],
], ],
@ -15863,7 +15863,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 10, "version": 10,
"width": "98.00000", "width": 98,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -16465,7 +16465,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
0, 0,
], ],
[ [
"98.00000", 98,
0, 0,
], ],
], ],
@ -16486,7 +16486,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 10, "version": 10,
"width": "98.00000", "width": 98,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -17086,7 +17086,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
0, 0,
], ],
[ [
"98.00000", 98,
0, 0,
], ],
], ],
@ -17107,7 +17107,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 10, "version": 10,
"width": "98.00000", "width": 98,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }
@ -17804,7 +17804,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
0, 0,
], ],
[ [
"98.00000", 98,
0, 0,
], ],
], ],
@ -17825,7 +17825,7 @@ exports[`history > singleplayer undo/redo > should support bidirectional binding
"type": "arrow", "type": "arrow",
"updated": 1, "updated": 1,
"version": 11, "version": 11,
"width": "98.00000", "width": 98,
"x": 1, "x": 1,
"y": 0, "y": 0,
} }

@ -191,13 +191,13 @@ exports[`move element > rectangles with binding arrow 7`] = `
"endBinding": { "endBinding": {
"elementId": "id1", "elementId": "id1",
"fixedPoint": null, "fixedPoint": null,
"focus": "-0.46667", "focus": "-0.77778",
"gap": 10, "gap": 10,
}, },
"fillStyle": "solid", "fillStyle": "solid",
"frameId": null, "frameId": null,
"groupIds": [], "groupIds": [],
"height": "81.47368", "height": "106.56082",
"id": "id2", "id": "id2",
"index": "a2", "index": "a2",
"isDeleted": false, "isDeleted": false,
@ -211,8 +211,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
0, 0,
], ],
[ [
81, "81.00000",
"81.47368", "106.56082",
], ],
], ],
"roughness": 1, "roughness": 1,
@ -224,7 +224,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"startBinding": { "startBinding": {
"elementId": "id0", "elementId": "id0",
"fixedPoint": null, "fixedPoint": null,
"focus": "-0.60000", "focus": "-1.00000",
"gap": 10, "gap": 10,
}, },
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -234,7 +234,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"updated": 1, "updated": 1,
"version": 11, "version": 11,
"versionNonce": 1051383431, "versionNonce": 1051383431,
"width": 81, "width": "81.00000",
"x": 110, "x": 110,
"y": 50, "y": 50,
} }

@ -9,7 +9,7 @@ import {
togglePopover, togglePopover,
getCloneByOrigId, getCloneByOrigId,
} from "./test-utils"; } from "./test-utils";
import "../utils/test-utils"; import "../../utils/test-utils";
import { Excalidraw } from "../index"; import { Excalidraw } from "../index";
import { Keyboard, Pointer, UI } from "./helpers/ui"; import { Keyboard, Pointer, UI } from "./helpers/ui";
import { API } from "./helpers/api"; import { API } from "./helpers/api";

@ -125,7 +125,7 @@ describe("move element", () => {
expect([rectB.x, rectB.y]).toEqual([201, 2]); expect([rectB.x, rectB.y]).toEqual([201, 2]);
expect([Math.round(arrow.x), Math.round(arrow.y)]).toEqual([110, 50]); expect([Math.round(arrow.x), Math.round(arrow.y)]).toEqual([110, 50]);
expect([Math.round(arrow.width), Math.round(arrow.height)]).toEqual([ expect([Math.round(arrow.width), Math.round(arrow.height)]).toEqual([
81, 81, 81, 107,
]); ]);
h.elements.forEach((element) => expect(element).toMatchSnapshot()); h.elements.forEach((element) => expect(element).toMatchSnapshot());

@ -502,12 +502,12 @@ describe("arrow element", () => {
h.state, h.state,
)[0] as ExcalidrawElbowArrowElement; )[0] as ExcalidrawElbowArrowElement;
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
UI.resize(rectangle, "se", [-200, -150]); UI.resize(rectangle, "se", [-200, -150]);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
}); });
@ -530,12 +530,12 @@ describe("arrow element", () => {
h.state, h.state,
)[0] as ExcalidrawElbowArrowElement; )[0] as ExcalidrawElbowArrowElement;
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05); expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
UI.resize([rectangle, arrow], "nw", [300, 350]); UI.resize([rectangle, arrow], "nw", [300, 350]);
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(-0.144); expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(0);
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25); expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25);
}); });
}); });
@ -1047,7 +1047,9 @@ describe("multiple selection", () => {
expect(rightBoundArrow.endBinding?.elementId).toBe( expect(rightBoundArrow.endBinding?.elementId).toBe(
rightArrowBinding.elementId, rightArrowBinding.elementId,
); );
expect(rightBoundArrow.endBinding?.focus).toBe(rightArrowBinding.focus); expect(rightBoundArrow.endBinding?.focus).toBeCloseTo(
rightArrowBinding.focus!,
);
}); });
it("resizes with labeled arrows", async () => { it("resizes with labeled arrows", async () => {

@ -70,13 +70,13 @@ test("unselected bound arrows update when rotating their target elements", async
expect(ellipseArrow.x).toEqual(0); expect(ellipseArrow.x).toEqual(0);
expect(ellipseArrow.y).toEqual(0); expect(ellipseArrow.y).toEqual(0);
expect(ellipseArrow.points[0]).toEqual([0, 0]); expect(ellipseArrow.points[0]).toEqual([0, 0]);
expect(ellipseArrow.points[1][0]).toBeCloseTo(48.5, 1); expect(ellipseArrow.points[1][0]).toBeCloseTo(56.1, 1);
expect(ellipseArrow.points[1][1]).toBeCloseTo(126.5, 1); expect(ellipseArrow.points[1][1]).toBeCloseTo(116.85, 1);
expect(textArrow.endBinding?.elementId).toEqual(text.id); expect(textArrow.endBinding?.elementId).toEqual(text.id);
expect(textArrow.x).toEqual(360); expect(textArrow.x).toEqual(360);
expect(textArrow.y).toEqual(300); expect(textArrow.y).toEqual(300);
expect(textArrow.points[0]).toEqual([0, 0]); expect(textArrow.points[0]).toEqual([0, 0]);
expect(textArrow.points[1][0]).toBeCloseTo(-94, 0); expect(textArrow.points[1][0]).toBeCloseTo(-89, 0);
expect(textArrow.points[1][1]).toBeCloseTo(-116.1, 0); expect(textArrow.points[1][1]).toBeCloseTo(-120.39, 0);
}); });

@ -31,7 +31,7 @@ describe("Math curve", () => {
); );
const l = line(pointFrom(0, 0), pointFrom(200, 200)); const l = line(pointFrom(0, 0), pointFrom(200, 200));
expect(curveIntersectLine(c, l)).toCloselyEqualPoints([[72.5, 72.5]]); expect(curveIntersectLine(c, l)).toCloselyEqualPoints([[73.65, 73.65]]);
}); });
it("points are found when curve is sliced at 3 points", () => { it("points are found when curve is sliced at 3 points", () => {

Loading…
Cancel
Save