From a4aae14301ddc909f2ba08d46b5267f6317a2095 Mon Sep 17 00:00:00 2001 From: gabalafou Date: Wed, 31 Jan 2024 07:28:44 -0500 Subject: [PATCH] TEST - Tests pass (but with console errors and warnings) (#357) * Tests pass (but with console errors and warnings) * do not alias condaStoreTheme to theme --- .../components/AddRequestedPackage.tsx | 1 + test/components/BlockContainerEditMode.test.tsx | 6 ++++-- test/environmentCreate/SpecificationCreate.test.tsx | 10 ++++++---- test/environmentDetails/SpecificationEdit.test.tsx | 12 ++++++------ test/environments/EnvironmentList.test.tsx | 2 +- test/testutils.tsx | 4 ++-- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/features/requestedPackages/components/AddRequestedPackage.tsx b/src/features/requestedPackages/components/AddRequestedPackage.tsx index 2f757b09..f75d2e6d 100644 --- a/src/features/requestedPackages/components/AddRequestedPackage.tsx +++ b/src/features/requestedPackages/components/AddRequestedPackage.tsx @@ -178,6 +178,7 @@ export const AddRequestedPackage = ({ onCancel(false)} data-testid="cancelIcon" + theme={theme} > diff --git a/test/components/BlockContainerEditMode.test.tsx b/test/components/BlockContainerEditMode.test.tsx index 6c62b40b..a72ff1ac 100644 --- a/test/components/BlockContainerEditMode.test.tsx +++ b/test/components/BlockContainerEditMode.test.tsx @@ -16,7 +16,7 @@ describe("", () => { ) ); - expect(container).toHaveTextContent("Switch to YAML Editor"); + expect(container).toHaveTextContent("YAML"); }); it("should call onToggleEditMode when the user switches the view", () => { @@ -32,7 +32,9 @@ describe("", () => { ) ); - const switchButton = component.getByLabelText("Switch to Standard View"); + const switchButton = component.getByLabelText("YAML", { + exact: false + }); fireEvent.click(switchButton); expect(onToggleEditorView).toHaveBeenCalled(); }); diff --git a/test/environmentCreate/SpecificationCreate.test.tsx b/test/environmentCreate/SpecificationCreate.test.tsx index 4ffa7bbc..1e9fefd1 100644 --- a/test/environmentCreate/SpecificationCreate.test.tsx +++ b/test/environmentCreate/SpecificationCreate.test.tsx @@ -30,7 +30,7 @@ describe("", () => { }); it("should switch the view to the yaml editor", () => { - const switchButton = component.getByLabelText("Switch to YAML Editor"); + const switchButton = component.getByLabelText("YAML", { exact: false }); fireEvent.click(switchButton); const vatSelectInput = component.container.querySelector( @@ -45,7 +45,7 @@ describe("", () => { expect(mockOnCreateEnvironment).toHaveBeenCalled(); - const switchButton = component.getByLabelText("Switch to YAML Editor"); + const switchButton = component.getByLabelText("YAML", { exact: false }); fireEvent.click(switchButton); fireEvent.click(createButton); @@ -56,7 +56,7 @@ describe("", () => { }); it("should update channels and dependencies", async () => { - const switchButton = component.getByLabelText("Switch to YAML Editor"); + const switchButton = component.getByLabelText("YAML", { exact: false }); fireEvent.click(switchButton); const code = stringify({ @@ -69,7 +69,9 @@ describe("", () => { }); await waitFor(() => { - expect(screen.getByText("conda-channel")).not.toBeNull(); + expect( + screen.getByText("conda-channel", { exact: false }) + ).not.toBeNull(); }); const emptyCode = stringify({ diff --git a/test/environmentDetails/SpecificationEdit.test.tsx b/test/environmentDetails/SpecificationEdit.test.tsx index 89523477..0182ea8d 100644 --- a/test/environmentDetails/SpecificationEdit.test.tsx +++ b/test/environmentDetails/SpecificationEdit.test.tsx @@ -52,7 +52,7 @@ describe("", () => { ) ); - const switchButton = component.getByLabelText("Switch to YAML Editor"); + const switchButton = component.getByLabelText("YAML", { exact: false }); fireEvent.click(switchButton); act(() => { @@ -60,9 +60,7 @@ describe("", () => { store.dispatch(updateChannels(["conda-store"])); }); - expect( - component.queryByText("Switch to Standard View") - ).toBeInTheDocument(); + expect(component.queryByText("YAML", { exact: false })).toBeInTheDocument(); }); it("should cancel environment edition", () => { @@ -93,7 +91,7 @@ describe("", () => { ) ); - const switchButton = component.getByLabelText("Switch to YAML Editor"); + const switchButton = component.getByLabelText("YAML", { exact: false }); fireEvent.click(switchButton); const code = stringify({ @@ -106,7 +104,9 @@ describe("", () => { }); await waitFor(() => { - expect(screen.getByText("conda-channel")).not.toBeNull(); + expect( + screen.getByText("conda-channel", { exact: false }) + ).not.toBeNull(); }); const emptyCode = stringify({ diff --git a/test/environments/EnvironmentList.test.tsx b/test/environments/EnvironmentList.test.tsx index 056b78ce..b22c5821 100644 --- a/test/environments/EnvironmentList.test.tsx +++ b/test/environments/EnvironmentList.test.tsx @@ -57,7 +57,7 @@ describe("", () => { ) ); - expect(component.container).toHaveTextContent("Shared environments"); + expect(component.container).toHaveTextContent("Shared Environments"); expect(component.container).toHaveTextContent("default"); }); }); diff --git a/test/testutils.tsx b/test/testutils.tsx index f835f448..90630d96 100644 --- a/test/testutils.tsx +++ b/test/testutils.tsx @@ -1,7 +1,7 @@ import { ThemeProvider } from "@mui/material"; import React from "react"; import { CondaSpecification } from "../src/common/models"; -import { theme } from "../src/theme"; +import { condaStoreTheme } from "../src/theme"; export const NAMESPACES = [ { @@ -90,5 +90,5 @@ export const BUILD = { }; export const mockTheme = (children: any) => { - return {children}; + return {children}; };