From 15b942aa39f606c3d9fa72485643ad9a64ee43c0 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 10 May 2023 09:55:46 -0400 Subject: [PATCH] chore: Add unit tests to cover the hovering bug Signed-off-by: Sebastian Malton --- .../hovering-hotbar-menu.test.ts.snap | 583 ++++++++++++++++++ .../hotbar/hovering-hotbar-menu.test.ts | 42 ++ .../components/hotbar/hotbar-selector.tsx | 5 +- 3 files changed, 629 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/features/hotbar/__snapshots__/hovering-hotbar-menu.test.ts.snap create mode 100644 packages/core/src/features/hotbar/hovering-hotbar-menu.test.ts diff --git a/packages/core/src/features/hotbar/__snapshots__/hovering-hotbar-menu.test.ts.snap b/packages/core/src/features/hotbar/__snapshots__/hovering-hotbar-menu.test.ts.snap new file mode 100644 index 0000000000..38bbb6b5e6 --- /dev/null +++ b/packages/core/src/features/hotbar/__snapshots__/hovering-hotbar-menu.test.ts.snap @@ -0,0 +1,583 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`hovering hotbar menu tests renders 1`] = ` + +
+
+
+
+
+ + + home + + +
+
+
+ + + arrow_back + + +
+
+
+ + + arrow_forward + + +
+
+
+
+
+
+
+
+ +
+
+

+ Welcome to some-product-name! +

+

+ To get you started we have auto-detected your clusters in your + + kubeconfig file and added them to the catalog, your centralized + + view for managing all your cloud-native resources. +
+
+ If you have any questions or feedback, please join our + + Lens Forums + + . +

+ +
+
+
+
+
+
+
+
+
+
+
+ Ca +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + arrow_left + + +
+
+ 1 +
+
+ + + arrow_right + + +
+
+
+
+
+
+
+
+
+ +`; + +exports[`hovering hotbar menu tests when hovering over the hotbar menu renders 1`] = ` + +
+
+
+
+
+ + + home + + +
+
+
+ + + arrow_back + + +
+
+
+ + + arrow_forward + + +
+
+
+
+
+
+
+
+ +
+
+

+ Welcome to some-product-name! +

+

+ To get you started we have auto-detected your clusters in your + + kubeconfig file and added them to the catalog, your centralized + + view for managing all your cloud-native resources. +
+
+ If you have any questions or feedback, please join our + + Lens Forums + + . +

+ +
+
+
+
+
+
+
+
+
+
+
+ Ca +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + arrow_left + + +
+
+ 1 +
+
+ + + arrow_right + + +
+
+
+
+
+
+
+
+
+ + +`; diff --git a/packages/core/src/features/hotbar/hovering-hotbar-menu.test.ts b/packages/core/src/features/hotbar/hovering-hotbar-menu.test.ts new file mode 100644 index 0000000000..6009e57018 --- /dev/null +++ b/packages/core/src/features/hotbar/hovering-hotbar-menu.test.ts @@ -0,0 +1,42 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import type { RenderResult } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; +import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; + +describe("hovering hotbar menu tests", () => { + let builder: ApplicationBuilder; + let result: RenderResult; + + beforeEach(async () => { + builder = getApplicationBuilder(); + + result = await builder.render(); + }); + + it("renders", () => { + expect(result.baseElement).toMatchSnapshot(); + }); + + it("should not yet render the hotbar name", () => { + expect(result.queryByText("hotbar-menu-badge-tooltip-for-default")).not.toBeInTheDocument(); + }); + + describe("when hovering over the hotbar menu", () => { + beforeEach(() => { + userEvent.hover(result.getByTestId("hotbar-menu-badge-for-default")); + }); + + it("renders", () => { + expect(result.baseElement).toMatchSnapshot(); + }); + + it("should render the hotbar name", () => { + expect(result.getByTestId("hotbar-menu-badge-tooltip-for-default")).toBeInTheDocument(); + }); + }); +}); diff --git a/packages/core/src/renderer/components/hotbar/hotbar-selector.tsx b/packages/core/src/renderer/components/hotbar/hotbar-selector.tsx index a72428be07..eb91653038 100644 --- a/packages/core/src/renderer/components/hotbar/hotbar-selector.tsx +++ b/packages/core/src/renderer/components/hotbar/hotbar-selector.tsx @@ -72,7 +72,8 @@ const NonInjectedHotbarSelector = observer(({ + onClick={onPrevClick} + />
{hotbar?.name.get()}