From b6a7f0576132836727eaa90c176e70a9a48ad5c5 Mon Sep 17 00:00:00 2001 From: barnabasmolnar Date: Mon, 24 Jul 2023 14:04:37 +0200 Subject: [PATCH] Attempt to fix tests. --- src/components/LibraryMenuHeaderContent.tsx | 1 + src/components/main-menu/MainMenu.tsx | 1 + src/tests/library.test.tsx | 9 +- .../__snapshots__/excalidraw.test.tsx.snap | 718 ++++++++++-------- src/tests/packages/excalidraw.test.tsx | 43 +- 5 files changed, 431 insertions(+), 341 deletions(-) diff --git a/src/components/LibraryMenuHeaderContent.tsx b/src/components/LibraryMenuHeaderContent.tsx index 56c8fe6d0..dffdb9013 100644 --- a/src/components/LibraryMenuHeaderContent.tsx +++ b/src/components/LibraryMenuHeaderContent.tsx @@ -191,6 +191,7 @@ export const LibraryDropdownMenuButton: React.FC<{ setIsLibraryMenuOpen(!isLibraryMenuOpen)} + aria-label="Library menu" > {DotsIcon} diff --git a/src/components/main-menu/MainMenu.tsx b/src/components/main-menu/MainMenu.tsx index a15916fab..45a48debe 100644 --- a/src/components/main-menu/MainMenu.tsx +++ b/src/components/main-menu/MainMenu.tsx @@ -57,6 +57,7 @@ const MainMenu = Object.assign( }); }} data-testid="main-menu-trigger" + aria-label="Main menu" > {HamburgerMenuIcon} diff --git a/src/tests/library.test.tsx b/src/tests/library.test.tsx index 2a2886354..9defd1af5 100644 --- a/src/tests/library.test.tsx +++ b/src/tests/library.test.tsx @@ -1,4 +1,4 @@ -import { fireEvent, render, waitFor } from "./test-utils"; +import { fireEvent, render, togglePopover, waitFor } from "./test-utils"; import { queryByTestId } from "@testing-library/react"; import ExcalidrawApp from "../excalidraw-app"; @@ -192,12 +192,7 @@ describe("library menu", () => { const libraryButton = container.querySelector(".sidebar-trigger"); fireEvent.click(libraryButton!); - fireEvent.click( - queryByTestId( - container.querySelector(".layer-ui__library")!, - "dropdown-menu-button", - )!, - ); + togglePopover("Library menu"); queryByTestId(container, "lib-dropdown--load")!.click(); const libraryItems = parseLibraryJSON(await libraryJSONPromise); diff --git a/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap b/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap index 4caa6c6dd..99abeb4f9 100644 --- a/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap +++ b/src/tests/packages/__snapshots__/excalidraw.test.tsx.snap @@ -2,26 +2,46 @@ exports[` should render main menu with host menu items if passed from host 1`] = ` + + + + `; exports[` Test UIOptions prop Test canvasActions should render menu with default items when "UIOPtions" is "undefined" 1`] = ` + +
@@ -473,45 +553,53 @@ exports[` Test UIOptions prop Test canvasActions should render menu
- + stroke-linecap="round" + stroke-linejoin="round" + viewBox="0 0 20 20" + > + + +
+ + + +
@@ -587,7 +675,7 @@ exports[` Test UIOptions prop Test canvasActions should render menu style="width: 1px; height: 100%; margin: 0px auto;" />