Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests pass (but with console errors and warnings) #357

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export const condaStoreTheme = createTheme(baseTheme, {
}
});

export const theme = condaStoreTheme;
Copy link
Contributor Author

@gabalafou gabalafou Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If preferable I could change the import { theme } lines in the tests to import { condaStoreTheme }, instead of exporting theme in addition to condaStoreTheme

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any fundamental change/impact of one or the other approach aside from a double export?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, me asking the question was really a tell that I shouldn't alias the theme. I pushed a commit that fixes the tests without doing this. It wasn't hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the reason why I think I shouldn't alias it is because it could make it harder to trace where that particular theme is being used across the code base (much easier to search the string "condaStoreTheme" than "theme")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense, thank you


export const themeDecorator = (func: any) => (
<ThemeProvider theme={condaStoreTheme}>{func()}</ThemeProvider>
);
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 });
gabalafou marked this conversation as resolved.
Show resolved Hide resolved
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");
});
});
Loading