test: fix failing tests and API (#5823)

* tests: fix failing tests

* fix selection.test.tsx

* fix excalidraw.test.tsx and don't show image export when SaveAsImage is false in UIOptions.canvasActions

* more fixes

* require fake index db in setUp test to fix the tests

* fix regression
This commit is contained in:
Aakansha Doshi
2022-11-04 18:22:21 +05:30
committed by GitHub
parent 8d5d68e589
commit 25ea97d0f9
14 changed files with 1798 additions and 300 deletions

View File

@ -174,7 +174,7 @@ describe("regression tests", () => {
mouse.up(10, 10);
const { x: prevX, y: prevY } = API.getSelectedElement();
mouse.down(-10, -10);
mouse.down(-8, -8);
mouse.up(10, 10);
const { x: nextX, y: nextY } = API.getSelectedElement();
@ -201,7 +201,7 @@ describe("regression tests", () => {
).toBe(1);
Keyboard.withModifierKeys({ alt: true }, () => {
mouse.down(-10, -10);
mouse.down(-8, -8);
mouse.up(10, 10);
});
@ -446,6 +446,8 @@ describe("regression tests", () => {
UI.clickTool("rectangle");
// english lang should display `thin` label
expect(screen.queryByTitle(/thin/i)).not.toBeNull();
fireEvent.click(document.querySelector(".menu-button")!);
fireEvent.change(document.querySelector(".dropdown-select__language")!, {
target: { value: "de-DE" },
});
@ -672,9 +674,10 @@ describe("regression tests", () => {
mouse.down();
mouse.up(100, 100);
// hits bounding box without hitting element
mouse.down();
expect(API.getSelectedElements().length).toBe(1);
// hits bounding box without hitting element
mouse.down(98, 98);
mouse.up();
expect(API.getSelectedElements().length).toBe(0);
});
@ -744,7 +747,7 @@ describe("regression tests", () => {
// drag element from point on bounding box that doesn't hit element
mouse.reset();
mouse.down();
mouse.down(8, 8);
mouse.up(25, 25);
expect(API.getSelectedElement().x).toEqual(prevX + 25);
@ -1020,7 +1023,7 @@ describe("regression tests", () => {
// Rectangle is already selected since creating
// it was our last action
Keyboard.withModifierKeys({ shift: true }, () => {
mouse.down();
mouse.down(-8, -8);
});
expect(API.getSelectedElements().length).toBe(1);