mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: duplication tests pointer state leaking between tests
This commit is contained in:
parent
a5d6939826
commit
2114a799af
5 changed files with 14 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
|||
import React from "react";
|
||||
import { pointFrom } from "@excalidraw/math";
|
||||
|
||||
import {
|
||||
|
@ -472,7 +471,7 @@ describe("group-related duplication", () => {
|
|||
expect(h.state.editingGroupId).toBe("group1");
|
||||
});
|
||||
|
||||
it.skip("alt-duplicating within group away outside frame", () => {
|
||||
it("alt-duplicating within group away outside frame", () => {
|
||||
const frame = API.createElement({
|
||||
type: "frame",
|
||||
x: 0,
|
||||
|
|
|
@ -444,7 +444,6 @@ export class API {
|
|||
|
||||
const text = API.createElement({
|
||||
type: "text",
|
||||
id: "text2",
|
||||
width: 50,
|
||||
height: 20,
|
||||
containerId: arrow.id,
|
||||
|
|
|
@ -180,10 +180,17 @@ export class Pointer {
|
|||
public clientX = 0;
|
||||
public clientY = 0;
|
||||
|
||||
static activePointers: Pointer[] = [];
|
||||
static resetAll() {
|
||||
Pointer.activePointers.forEach((pointer) => pointer.reset());
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly pointerType: "mouse" | "touch" | "pen",
|
||||
private readonly pointerId = 1,
|
||||
) {}
|
||||
) {
|
||||
Pointer.activePointers.push(this);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.clientX = 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ import type { AllPossibleKeys } from "@excalidraw/common/utility-types";
|
|||
|
||||
import { STORAGE_KEYS } from "../../../excalidraw-app/app_constants";
|
||||
|
||||
import { UI } from "./helpers/ui";
|
||||
import { Pointer, UI } from "./helpers/ui";
|
||||
import * as toolQueries from "./queries/toolQueries";
|
||||
|
||||
import type { RenderResult, RenderOptions } from "@testing-library/react";
|
||||
|
@ -42,6 +42,10 @@ type TestRenderFn = (
|
|||
) => Promise<RenderResult<typeof customQueries>>;
|
||||
|
||||
const renderApp: TestRenderFn = async (ui, options) => {
|
||||
// when tests reuse Pointer instances let's reset the last
|
||||
// pointer poisitions so there's no leak between tests
|
||||
Pointer.resetAll();
|
||||
|
||||
if (options?.localStorageData) {
|
||||
initLocalStorage(options.localStorageData);
|
||||
delete options.localStorageData;
|
||||
|
|
|
@ -94,11 +94,6 @@ vi.mock(
|
|||
},
|
||||
);
|
||||
|
||||
vi.mock("nanoid", () => {
|
||||
return {
|
||||
nanoid: vi.fn(() => "test-id"),
|
||||
};
|
||||
});
|
||||
// ReactDOM is located inside index.tsx file
|
||||
// as a result, we need a place for it to render into
|
||||
const element = document.createElement("div");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue