Skip to content

Commit

Permalink
refactor(frontend): Remove test todos and fix light warning (#5554)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanape authored Dec 23, 2024
1 parent 4a8bf3d commit d62cf7e
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 90 deletions.
16 changes: 6 additions & 10 deletions frontend/__tests__/components/chat-message.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ describe("ChatMessage", () => {
expect(screen.getByText("'Hello, World!'")).toBeInTheDocument();
});

it.todo("should support markdown content");

it("should render the copy to clipboard button when the user hovers over the message", async () => {
const user = userEvent.setup();
render(<ChatMessage type="user" message="Hello, World!" />);
Expand All @@ -50,15 +48,8 @@ describe("ChatMessage", () => {
expect(navigator.clipboard.readText()).resolves.toBe("Hello, World!");
});

// BUG: vi.useFakeTimers() seems to break the tests
it.todo(
"should display a checkmark for 200ms and disable the button after copying content to clipboard",
);

it("should display an error toast if copying content to clipboard fails", async () => {});

test.todo("push a toast after successfully copying content to clipboard");

it("should render a component passed as a prop", () => {
function Component() {
return <div data-testid="custom-component">Custom Component</div>;
Expand All @@ -72,7 +63,12 @@ describe("ChatMessage", () => {
});

it("should apply correct styles to inline code", () => {
render(<ChatMessage type="assistant" message="Here is some `inline code` text" />);
render(
<ChatMessage
type="assistant"
message="Here is some `inline code` text"
/>,
);
const codeElement = screen.getByText("inline code");

expect(codeElement.tagName.toLowerCase()).toBe("code");
Expand Down
16 changes: 3 additions & 13 deletions frontend/__tests__/components/chat/chat-interface.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { WsClientProviderStatus } from "#/context/ws-client-provider";
import { ChatInterface } from "#/components/features/chat/chat-interface";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const renderChatInterface = (messages: (Message)[]) =>
const renderChatInterface = (messages: Message[]) =>
renderWithProviders(<ChatInterface />);

describe("Empty state", () => {
Expand Down Expand Up @@ -195,7 +195,7 @@ describe.skip("ChatInterface", () => {
expect(screen.getByTestId("chat-input")).toBeInTheDocument();
});

it.todo("should call socket send when submitting a message", async () => {
it("should call socket send when submitting a message", async () => {
const user = userEvent.setup();
const messages: Message[] = [];
renderChatInterface(messages);
Expand Down Expand Up @@ -240,8 +240,6 @@ describe.skip("ChatInterface", () => {
);
});

it.todo("should render confirmation buttons");

it("should render a 'continue' action when there are more than 2 messages and awaiting user input", () => {
const messages: Message[] = [
{
Expand Down Expand Up @@ -278,7 +276,7 @@ describe.skip("ChatInterface", () => {
});

it("should render inline errors", () => {
const messages: (Message)[] = [
const messages: Message[] = [
{
sender: "assistant",
content: "Hello",
Expand Down Expand Up @@ -402,12 +400,4 @@ describe.skip("ChatInterface", () => {

expect(screen.getByTestId("feedback-actions")).toBeInTheDocument();
});

describe("feedback", () => {
it.todo("should open the feedback modal when a feedback action is clicked");
it.todo(
"should submit feedback and hide the actions when feedback is shared",
);
it.todo("should render the actions once more after new messages are added");
});
});
10 changes: 9 additions & 1 deletion frontend/__tests__/components/features/waitlist-modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { render, screen } from "@testing-library/react";
import { it, describe, expect, vi } from "vitest";
import { it, describe, expect, vi, beforeAll, afterAll } from "vitest";
import userEvent from "@testing-library/user-event";
import { WaitlistModal } from "#/components/features/waitlist/waitlist-modal";
import * as CaptureConsent from "#/utils/handle-capture-consent";

describe("WaitlistModal", () => {
beforeAll(() => {
vi.stubGlobal("location", { href: "" });
});

afterAll(() => {
vi.unstubAllGlobals();
});

it("should render a tos checkbox that is unchecked by default", () => {
render(<WaitlistModal ghToken={null} githubAuthUrl={null} />);
const checkbox = screen.getByRole("checkbox");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,4 @@ describe.skip("ExplorerTree", () => {
expect(screen.queryByText("folder-1-2")).toBeInTheDocument();
// TODO: make sure children don't render
});

it.todo("should render all children as collapsed when defaultOpen is false");

it.todo(
"should maintain the expanded state of child folders when closing and opening a parent folder",
);
});
10 changes: 0 additions & 10 deletions frontend/__tests__/components/file-explorer/file-explorer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ describe.skip("FileExplorer", () => {
expect(getFilesSpy).toHaveBeenCalledTimes(1); // once for root
});

it.todo("should render an empty workspace");

it("should refetch the workspace when clicking the refresh button", async () => {
const user = userEvent.setup();
renderFileExplorerWithRunningAgentState();
Expand Down Expand Up @@ -87,14 +85,6 @@ describe.skip("FileExplorer", () => {
expect(getFilesSpy).toHaveBeenCalled();
});

it.todo("should upload files when dragging them to the explorer", () => {
// It will require too much work to mock drag logic, especially for our case
// https://github.com/testing-library/user-event/issues/440#issuecomment-685010755
// TODO: should be tested in an e2e environment such as Cypress/Playwright
});

it.todo("should download a file");

it("should display an error toast if file upload fails", async () => {
(uploadFilesSpy as Mock).mockRejectedValue(new Error());
const user = userEvent.setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,4 @@ describe("ModelSelector", () => {
expect(screen.getByLabelText("LLM Provider")).toHaveValue("Azure");
expect(screen.getByLabelText("LLM Model")).toHaveValue("ada");
});

it.todo("should disable provider if isDisabled is true");

it.todo(
"should display the verified models in the correct order",
async () => {},
);
});

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions frontend/__tests__/components/settings/model-selector.test.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions frontend/__tests__/routes/_oh.app.test.tsx

This file was deleted.

0 comments on commit d62cf7e

Please sign in to comment.