Test fixes

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2024-07-27 21:29:53 +02:00
parent 570022c607
commit 946d88be36
No known key found for this signature in database
7 changed files with 825 additions and 16465 deletions

View File

@ -88,8 +88,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"endBinding": {
"elementId": "ellipse-1",
"fixedPoint": [
12,
139,
0.04,
0.4633333333333333,
],
"focus": -0.008153707962747813,
"gap": 1,
@ -122,8 +122,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"startBinding": {
"elementId": "id47",
"fixedPoint": [
300,
150,
1.0166666666666666,
0.5,
],
"focus": -0.08139534883720931,
"gap": 1,
@ -151,8 +151,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"endBinding": {
"elementId": "ellipse-1",
"fixedPoint": [
-3,
134,
-0.01,
0.44666666666666666,
],
"focus": 0.10666666666666667,
"gap": 3.834326468444573,
@ -185,8 +185,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"startBinding": {
"elementId": "diamond-1",
"fixedPoint": [
131,
50,
0.9357142857142857,
-0.05,
],
"focus": 0,
"gap": 1,
@ -348,8 +348,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"endBinding": {
"elementId": "text-2",
"fixedPoint": [
-205,
12.5,
-2.05,
0.5,
],
"focus": 0,
"gap": 205,
@ -382,8 +382,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"startBinding": {
"elementId": "text-1",
"fixedPoint": [
70,
12.5,
1.0714285714285714,
0.5,
],
"focus": 0,
"gap": 1,
@ -457,8 +457,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"endBinding": {
"elementId": "id40",
"fixedPoint": [
0,
50,
1,
0.5,
],
"focus": 0,
"gap": 1,
@ -491,8 +491,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"startBinding": {
"elementId": "id39",
"fixedPoint": [
100,
50,
1.05,
0.5,
],
"focus": 0,
"gap": 1,
@ -640,8 +640,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"endBinding": {
"elementId": "id44",
"fixedPoint": [
0,
12.5,
-0.05,
0.5,
],
"focus": 0,
"gap": 1,
@ -674,8 +674,8 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"startBinding": {
"elementId": "id43",
"fixedPoint": [
70,
12.5,
1.0714285714285714,
0.5,
],
"focus": 0,
"gap": 1,
@ -1507,8 +1507,8 @@ exports[`Test Transform > should transform the elements correctly when linear el
"endBinding": {
"elementId": "Alice",
"fixedPoint": [
-5.299874999999986,
22,
-0.07115855014454081,
0.5,
],
"focus": 0,
"gap": 5.299874999999986,
@ -1543,8 +1543,8 @@ exports[`Test Transform > should transform the elements correctly when linear el
"startBinding": {
"elementId": "Bob",
"fixedPoint": [
56.49246875,
22,
1.0885078135804176,
0.5,
],
"focus": 0,
"gap": 1,
@ -1577,8 +1577,8 @@ exports[`Test Transform > should transform the elements correctly when linear el
"endBinding": {
"elementId": "B",
"fixedPoint": [
77.017,
79,
-0.030114812723508376,
0.48466257668711654,
],
"focus": 0,
"gap": 1,
@ -1609,8 +1609,8 @@ exports[`Test Transform > should transform the elements correctly when linear el
"startBinding": {
"elementId": "Bob",
"fixedPoint": [
22.247468749999996,
44,
0.39381496335223337,
1.1136363636363635,
],
"focus": 0,
"gap": 1,

View File

@ -773,6 +773,7 @@ describe("Test Transform", () => {
elementId: "rect-1",
focus: 0,
gap: 205,
fixedPoint: [-2.05, 0.5],
});
expect(rect.boundElements).toStrictEqual([
{

File diff suppressed because it is too large Load Diff

View File

@ -173,7 +173,7 @@ exports[`move element > rectangles with binding arrow 6`] = `
"type": "rectangle",
"updated": 1,
"version": 7,
"versionNonce": 2066753033,
"versionNonce": 745419401,
"width": 300,
"x": 201,
"y": 2,
@ -191,8 +191,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
"endBinding": {
"elementId": "id1",
"fixedPoint": [
-10,
130,
"-0.01667",
"0.43333",
],
"focus": "-0.46667",
"gap": 10,
@ -200,7 +200,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": "81.48231",
"height": "81.47368",
"id": "id2",
"index": "a2",
"isDeleted": false,
@ -215,7 +215,7 @@ exports[`move element > rectangles with binding arrow 7`] = `
],
[
81,
"81.48231",
"81.47368",
],
],
"roughness": 1,
@ -227,8 +227,8 @@ exports[`move element > rectangles with binding arrow 7`] = `
"startBinding": {
"elementId": "id0",
"fixedPoint": [
110,
50,
"1.05000",
"0.50000",
],
"focus": "-0.60000",
"gap": 10,
@ -238,10 +238,10 @@ exports[`move element > rectangles with binding arrow 7`] = `
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 17,
"versionNonce": 453187241,
"version": 11,
"versionNonce": 1996028265,
"width": 81,
"x": 110,
"y": "49.98179",
"y": 50,
}
`;

View File

@ -64,6 +64,7 @@ describe("element binding", () => {
elementId: rect.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
// Move the end point to the overlapping binding position
@ -76,11 +77,13 @@ describe("element binding", () => {
elementId: rect.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
expect(arrow.endBinding).toEqual({
elementId: rect.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
});

View File

@ -1337,11 +1337,13 @@ describe("history", () => {
elementId: rect1.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
expect(arrow.endBinding).toEqual({
elementId: rect2.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
expect(rect1.boundElements).toStrictEqual([
{ id: text.id, type: "text" },
@ -1360,11 +1362,13 @@ describe("history", () => {
elementId: rect1.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
expect(arrow.endBinding).toEqual({
elementId: rect2.id,
focus: expect.toBeNonNaNNumber(),
gap: expect.toBeNonNaNNumber(),
fixedPoint: [expect.toBeNonNaNNumber(), expect.toBeNonNaNNumber()],
});
expect(h.elements).toEqual([
expect.objectContaining({

View File

@ -307,7 +307,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`9`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`6`);
const midPointsWithRoundEdge = LinearElementEditor.getEditorMidPoints(
h.elements[0] as ExcalidrawLinearElement,
@ -365,7 +365,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`12`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect([line.x, line.y]).toEqual([
points[0][0] + deltaX,
@ -427,7 +427,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`16`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(line.points.length).toEqual(5);
@ -478,7 +478,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`12`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`6`);
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(
line,
@ -519,7 +519,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`12`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`6`);
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(
line,
@ -567,7 +567,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`18`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
const newMidPoints = LinearElementEditor.getEditorMidPoints(
line,
@ -617,7 +617,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`16`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`8`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(line.points.length).toEqual(5);
expect((h.elements[0] as ExcalidrawLinearElement).points)
@ -715,7 +715,7 @@ describe("Test Linear Elements", () => {
expect(renderInteractiveScene.mock.calls.length).toMatchInlineSnapshot(
`12`,
);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`7`);
expect(renderStaticScene.mock.calls.length).toMatchInlineSnapshot(`6`);
const newPoints = LinearElementEditor.getPointsGlobalCoordinates(
line,
@ -929,8 +929,8 @@ describe("Test Linear Elements", () => {
);
expect(position).toMatchInlineSnapshot(`
{
"x": "85.82202",
"y": "75.63461",
"x": 125,
"y": 110,
}
`);
});
@ -973,8 +973,8 @@ describe("Test Linear Elements", () => {
]);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
collaboration made
"Online whiteboard
collaboration made
easy"
`);
});
@ -1007,8 +1007,8 @@ describe("Test Linear Elements", () => {
]);
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
.toMatchInlineSnapshot(`
"Online whiteboard
collaboration made
"Online whiteboard
collaboration made
easy"
`);
});
@ -1142,8 +1142,8 @@ describe("Test Linear Elements", () => {
}
`);
expect(textElement.text).toMatchInlineSnapshot(`
"Online whiteboard
collaboration made
"Online whiteboard
collaboration made
easy"
`);
const points = LinearElementEditor.getPointsGlobalCoordinates(
@ -1170,7 +1170,7 @@ describe("Test Linear Elements", () => {
}
`);
expect(textElement.text).toMatchInlineSnapshot(`
"Online whiteboard
"Online whiteboard
collaboration made easy"
`);
});
@ -1222,7 +1222,7 @@ describe("Test Linear Elements", () => {
getBoundTextMaxWidth(arrow, null),
),
).toMatchInlineSnapshot(`
"Online whiteboard
"Online whiteboard
collaboration made easy"
`);
const handleBindTextResizeSpy = vi.spyOn(