Skip to content

Commit

Permalink
TEST - Tests pass (but with console errors and warnings) (#357)
Browse files Browse the repository at this point in the history
* Tests pass (but with console errors and warnings)

* do not alias condaStoreTheme to theme
  • Loading branch information
gabalafou authored Jan 31, 2024
1 parent 91e6ff2 commit a4aae14
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export const AddRequestedPackage = ({
<StyledIconButton
onClick={() => onCancel(false)}
data-testid="cancelIcon"
theme={theme}
>
<DeleteIconAlt />
</StyledIconButton>
Expand Down
6 changes: 4 additions & 2 deletions test/components/BlockContainerEditMode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("<BlockContainerEditMode />", () => {
</BlockContainerEditMode>
)
);
expect(container).toHaveTextContent("Switch to YAML Editor");
expect(container).toHaveTextContent("YAML");
});

it("should call onToggleEditMode when the user switches the view", () => {
Expand All @@ -32,7 +32,9 @@ describe("<BlockContainerEditMode />", () => {
</BlockContainerEditMode>
)
);
const switchButton = component.getByLabelText("Switch to Standard View");
const switchButton = component.getByLabelText("YAML", {
exact: false
});
fireEvent.click(switchButton);
expect(onToggleEditorView).toHaveBeenCalled();
});
Expand Down
10 changes: 6 additions & 4 deletions test/environmentCreate/SpecificationCreate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("<SpecificationCreate />", () => {
});

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(
Expand All @@ -45,7 +45,7 @@ describe("<SpecificationCreate />", () => {

expect(mockOnCreateEnvironment).toHaveBeenCalled();

const switchButton = component.getByLabelText("Switch to YAML Editor");
const switchButton = component.getByLabelText("YAML", { exact: false });
fireEvent.click(switchButton);

fireEvent.click(createButton);
Expand All @@ -56,7 +56,7 @@ describe("<SpecificationCreate />", () => {
});

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({
Expand All @@ -69,7 +69,9 @@ describe("<SpecificationCreate />", () => {
});

await waitFor(() => {
expect(screen.getByText("conda-channel")).not.toBeNull();
expect(
screen.getByText("conda-channel", { exact: false })
).not.toBeNull();
});

const emptyCode = stringify({
Expand Down
12 changes: 6 additions & 6 deletions test/environmentDetails/SpecificationEdit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ describe("<SpecificationEdit />", () => {
</Provider>
)
);
const switchButton = component.getByLabelText("Switch to YAML Editor");
const switchButton = component.getByLabelText("YAML", { exact: false });
fireEvent.click(switchButton);

act(() => {
store.dispatch(updatePackages(["numpy"]));
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", () => {
Expand Down Expand Up @@ -93,7 +91,7 @@ describe("<SpecificationEdit />", () => {
</Provider>
)
);
const switchButton = component.getByLabelText("Switch to YAML Editor");
const switchButton = component.getByLabelText("YAML", { exact: false });
fireEvent.click(switchButton);

const code = stringify({
Expand All @@ -106,7 +104,9 @@ describe("<SpecificationEdit />", () => {
});

await waitFor(() => {
expect(screen.getByText("conda-channel")).not.toBeNull();
expect(
screen.getByText("conda-channel", { exact: false })
).not.toBeNull();
});

const emptyCode = stringify({
Expand Down
2 changes: 1 addition & 1 deletion test/environments/EnvironmentList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("<EnvironmentsList />", () => {
)
);

expect(component.container).toHaveTextContent("Shared environments");
expect(component.container).toHaveTextContent("Shared Environments");
expect(component.container).toHaveTextContent("default");
});
});
4 changes: 2 additions & 2 deletions test/testutils.tsx
Original file line number Diff line number Diff line change
@@ -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 = [
{
Expand Down Expand Up @@ -90,5 +90,5 @@ export const BUILD = {
};

export const mockTheme = (children: any) => {
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
return <ThemeProvider theme={condaStoreTheme}>{children}</ThemeProvider>;
};

0 comments on commit a4aae14

Please sign in to comment.