chore: bump @testing-library/react 12.1.5 -> 16.0.0 (#8322)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
@@ -17,7 +18,7 @@ import { API } from "../tests/helpers/api";
|
||||
import type { Point } from "../types";
|
||||
import { KEYS } from "../keys";
|
||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||
import { queryByTestId, queryByText } from "@testing-library/react";
|
||||
import { act, queryByTestId, queryByText } from "@testing-library/react";
|
||||
import {
|
||||
getBoundTextElementPosition,
|
||||
wrapText,
|
||||
@@ -27,7 +28,6 @@ import * as textElementUtils from "../element/textElement";
|
||||
import { ROUNDNESS, VERTICAL_ALIGN } from "../constants";
|
||||
import { vi } from "vitest";
|
||||
import { arrayToMap } from "../utils";
|
||||
import React from "react";
|
||||
|
||||
const renderInteractiveScene = vi.spyOn(
|
||||
InteractiveCanvas,
|
||||
@@ -80,7 +80,7 @@ describe("Test Linear Elements", () => {
|
||||
],
|
||||
roundness,
|
||||
});
|
||||
h.elements = [line];
|
||||
API.setElements([line]);
|
||||
|
||||
mouse.clickAt(p1[0], p1[1]);
|
||||
return line;
|
||||
@@ -108,7 +108,7 @@ describe("Test Linear Elements", () => {
|
||||
roundness,
|
||||
});
|
||||
mutateElement(line, { points: line.points });
|
||||
h.elements = [line];
|
||||
API.setElements([line]);
|
||||
mouse.clickAt(p1[0], p1[1]);
|
||||
return line;
|
||||
};
|
||||
@@ -786,7 +786,7 @@ describe("Test Linear Elements", () => {
|
||||
it("in-editor dragging a line point covered by another element", () => {
|
||||
createTwoPointerLinearElement("line");
|
||||
const line = h.elements[0] as ExcalidrawLinearElement;
|
||||
h.elements = [
|
||||
API.setElements([
|
||||
line,
|
||||
API.createElement({
|
||||
type: "rectangle",
|
||||
@@ -797,7 +797,7 @@ describe("Test Linear Elements", () => {
|
||||
backgroundColor: "red",
|
||||
fillStyle: "solid",
|
||||
}),
|
||||
];
|
||||
]);
|
||||
const dragEndPositionOffset = [100, 100] as const;
|
||||
API.setSelectedElements([line]);
|
||||
enterLineEditingMode(line, true);
|
||||
@@ -854,7 +854,7 @@ describe("Test Linear Elements", () => {
|
||||
}
|
||||
});
|
||||
const updatedTextElement = { ...textElement, originalText: text };
|
||||
h.elements = [...elements, updatedTextElement];
|
||||
API.setElements([...elements, updatedTextElement]);
|
||||
return { textElement: updatedTextElement, container };
|
||||
};
|
||||
|
||||
@@ -968,17 +968,13 @@ describe("Test Linear Elements", () => {
|
||||
target: { value: DEFAULT_TEXT },
|
||||
});
|
||||
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
editor.blur();
|
||||
Keyboard.exitTextEditor(editor);
|
||||
expect(arrow.boundElements).toStrictEqual([
|
||||
{ id: text.id, type: "text" },
|
||||
]);
|
||||
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
|
||||
.toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made
|
||||
easy"
|
||||
`);
|
||||
expect(
|
||||
(h.elements[1] as ExcalidrawTextElementWithContainer).text,
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should bind text to arrow when clicked on arrow and enter pressed", async () => {
|
||||
@@ -998,21 +994,16 @@ describe("Test Linear Elements", () => {
|
||||
".excalidraw-textEditorContainer > textarea",
|
||||
) as HTMLTextAreaElement;
|
||||
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
|
||||
fireEvent.change(editor, {
|
||||
target: { value: DEFAULT_TEXT },
|
||||
});
|
||||
editor.blur();
|
||||
Keyboard.exitTextEditor(editor);
|
||||
expect(arrow.boundElements).toStrictEqual([
|
||||
{ id: textElement.id, type: "text" },
|
||||
]);
|
||||
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
|
||||
.toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made
|
||||
easy"
|
||||
`);
|
||||
expect(
|
||||
(h.elements[1] as ExcalidrawTextElementWithContainer).text,
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should not bind text to line when double clicked", async () => {
|
||||
@@ -1059,11 +1050,7 @@ describe("Test Linear Elements", () => {
|
||||
"y": 60,
|
||||
}
|
||||
`);
|
||||
expect(textElement.text).toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made
|
||||
easy"
|
||||
`);
|
||||
expect(textElement.text).toMatchSnapshot();
|
||||
expect(
|
||||
LinearElementEditor.getElementAbsoluteCoords(
|
||||
container,
|
||||
@@ -1103,11 +1090,9 @@ describe("Test Linear Elements", () => {
|
||||
"y": 45,
|
||||
}
|
||||
`);
|
||||
expect((h.elements[1] as ExcalidrawTextElementWithContainer).text)
|
||||
.toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made easy"
|
||||
`);
|
||||
expect(
|
||||
(h.elements[1] as ExcalidrawTextElementWithContainer).text,
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
LinearElementEditor.getElementAbsoluteCoords(
|
||||
container,
|
||||
@@ -1143,11 +1128,7 @@ describe("Test Linear Elements", () => {
|
||||
"y": 10,
|
||||
}
|
||||
`);
|
||||
expect(textElement.text).toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made
|
||||
easy"
|
||||
`);
|
||||
expect(textElement.text).toMatchSnapshot();
|
||||
const points = LinearElementEditor.getPointsGlobalCoordinates(
|
||||
container,
|
||||
elementsMap,
|
||||
@@ -1171,10 +1152,7 @@ describe("Test Linear Elements", () => {
|
||||
"y": -5,
|
||||
}
|
||||
`);
|
||||
expect(textElement.text).toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made easy"
|
||||
`);
|
||||
expect(textElement.text).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should not render vertical align tool when element selected", () => {
|
||||
@@ -1207,9 +1185,8 @@ describe("Test Linear Elements", () => {
|
||||
const editor = document.querySelector(
|
||||
".excalidraw-textEditorContainer > textarea",
|
||||
) as HTMLTextAreaElement;
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
fireEvent.change(editor, { target: { value: DEFAULT_TEXT } });
|
||||
editor.blur();
|
||||
Keyboard.exitTextEditor(editor);
|
||||
|
||||
const textElement = h.elements[2] as ExcalidrawTextElementWithContainer;
|
||||
|
||||
@@ -1223,10 +1200,7 @@ describe("Test Linear Elements", () => {
|
||||
font,
|
||||
getBoundTextMaxWidth(arrow, null),
|
||||
),
|
||||
).toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made easy"
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
const handleBindTextResizeSpy = vi.spyOn(
|
||||
textElementUtils,
|
||||
"handleBindTextResize",
|
||||
@@ -1252,11 +1226,7 @@ describe("Test Linear Elements", () => {
|
||||
font,
|
||||
getBoundTextMaxWidth(arrow, null),
|
||||
),
|
||||
).toMatchInlineSnapshot(`
|
||||
"Online whiteboard
|
||||
collaboration made
|
||||
easy"
|
||||
`);
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should not render horizontal align tool when element selected", () => {
|
||||
@@ -1280,7 +1250,7 @@ describe("Test Linear Elements", () => {
|
||||
expect(text.x).toBe(0);
|
||||
expect(text.y).toBe(0);
|
||||
|
||||
h.elements = [h.elements[0], text];
|
||||
API.setElements([h.elements[0], text]);
|
||||
|
||||
const container = h.elements[0];
|
||||
API.setSelectedElements([container, text]);
|
||||
@@ -1358,20 +1328,25 @@ describe("Test Linear Elements", () => {
|
||||
const line = createThreePointerLinearElement("arrow");
|
||||
const [origStartX, origStartY] = [line.x, line.y];
|
||||
|
||||
LinearElementEditor.movePoints(
|
||||
line,
|
||||
[
|
||||
{ index: 0, point: [line.points[0][0] + 10, line.points[0][1] + 10] },
|
||||
{
|
||||
index: line.points.length - 1,
|
||||
point: [
|
||||
line.points[line.points.length - 1][0] - 10,
|
||||
line.points[line.points.length - 1][1] - 10,
|
||||
],
|
||||
},
|
||||
],
|
||||
h.scene,
|
||||
);
|
||||
act(() => {
|
||||
LinearElementEditor.movePoints(
|
||||
line,
|
||||
[
|
||||
{
|
||||
index: 0,
|
||||
point: [line.points[0][0] + 10, line.points[0][1] + 10],
|
||||
},
|
||||
{
|
||||
index: line.points.length - 1,
|
||||
point: [
|
||||
line.points[line.points.length - 1][0] - 10,
|
||||
line.points[line.points.length - 1][1] - 10,
|
||||
],
|
||||
},
|
||||
],
|
||||
h.scene,
|
||||
);
|
||||
});
|
||||
expect(line.x).toBe(origStartX + 10);
|
||||
expect(line.y).toBe(origStartY + 10);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user