From d62cf7e7319850ce8c0dc47a3ddab0f4151d2af6 Mon Sep 17 00:00:00 2001 From: "sp.wack" <83104063+amanape@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:43:36 +0400 Subject: [PATCH] refactor(frontend): Remove test todos and fix light warning (#5554) --- .../__tests__/components/chat-message.test.tsx | 16 ++++++---------- .../components/chat/chat-interface.test.tsx | 16 +++------------- .../components/features/waitlist-modal.test.tsx | 10 +++++++++- .../file-explorer/explorer-tree.test.tsx | 6 ------ .../file-explorer/file-explorer.test.tsx | 10 ---------- .../modals/settings/model-selector.test.tsx | 7 ------- .../project-menu/project-menu-card.test.tsx | 8 -------- .../components/settings/ai-config-form.test.tsx | 9 --------- .../components/settings/dropdown-input.test.tsx | 9 --------- .../components/settings/model-selector.test.tsx | 12 ------------ frontend/__tests__/routes/_oh.app.test.tsx | 5 ----- 11 files changed, 18 insertions(+), 90 deletions(-) delete mode 100644 frontend/__tests__/components/project-menu/project-menu-card.test.tsx delete mode 100644 frontend/__tests__/components/settings/ai-config-form.test.tsx delete mode 100644 frontend/__tests__/components/settings/dropdown-input.test.tsx delete mode 100644 frontend/__tests__/components/settings/model-selector.test.tsx delete mode 100644 frontend/__tests__/routes/_oh.app.test.tsx diff --git a/frontend/__tests__/components/chat-message.test.tsx b/frontend/__tests__/components/chat-message.test.tsx index 08fd090551..0edd09d241 100644 --- a/frontend/__tests__/components/chat-message.test.tsx +++ b/frontend/__tests__/components/chat-message.test.tsx @@ -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(); @@ -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
Custom Component
; @@ -72,7 +63,12 @@ describe("ChatMessage", () => { }); it("should apply correct styles to inline code", () => { - render(); + render( + , + ); const codeElement = screen.getByText("inline code"); expect(codeElement.tagName.toLowerCase()).toBe("code"); diff --git a/frontend/__tests__/components/chat/chat-interface.test.tsx b/frontend/__tests__/components/chat/chat-interface.test.tsx index ed8c448831..168715f219 100644 --- a/frontend/__tests__/components/chat/chat-interface.test.tsx +++ b/frontend/__tests__/components/chat/chat-interface.test.tsx @@ -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(); describe("Empty state", () => { @@ -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); @@ -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[] = [ { @@ -278,7 +276,7 @@ describe.skip("ChatInterface", () => { }); it("should render inline errors", () => { - const messages: (Message)[] = [ + const messages: Message[] = [ { sender: "assistant", content: "Hello", @@ -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"); - }); }); diff --git a/frontend/__tests__/components/features/waitlist-modal.test.tsx b/frontend/__tests__/components/features/waitlist-modal.test.tsx index b1f17bd26e..d52ac6e7c9 100644 --- a/frontend/__tests__/components/features/waitlist-modal.test.tsx +++ b/frontend/__tests__/components/features/waitlist-modal.test.tsx @@ -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(); const checkbox = screen.getByRole("checkbox"); diff --git a/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx b/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx index 84c1e911ac..3d04a3753f 100644 --- a/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx +++ b/frontend/__tests__/components/file-explorer/explorer-tree.test.tsx @@ -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", - ); }); diff --git a/frontend/__tests__/components/file-explorer/file-explorer.test.tsx b/frontend/__tests__/components/file-explorer/file-explorer.test.tsx index 1385ce4e53..ca7d1c6f70 100644 --- a/frontend/__tests__/components/file-explorer/file-explorer.test.tsx +++ b/frontend/__tests__/components/file-explorer/file-explorer.test.tsx @@ -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(); @@ -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(); diff --git a/frontend/__tests__/components/modals/settings/model-selector.test.tsx b/frontend/__tests__/components/modals/settings/model-selector.test.tsx index 8da2fec144..f1216cae3a 100644 --- a/frontend/__tests__/components/modals/settings/model-selector.test.tsx +++ b/frontend/__tests__/components/modals/settings/model-selector.test.tsx @@ -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 () => {}, - ); }); diff --git a/frontend/__tests__/components/project-menu/project-menu-card.test.tsx b/frontend/__tests__/components/project-menu/project-menu-card.test.tsx deleted file mode 100644 index 40a98e6be4..0000000000 --- a/frontend/__tests__/components/project-menu/project-menu-card.test.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { describe, it } from "vitest"; - -describe("PlayMenuCard", () => { - it.todo("should render the initial project title"); - it.todo("should be able to edit the project title"); - it.todo("should render the menu list items when clicking the ellipses"); - it.todo("should close the menu list when clicking outside"); -}); diff --git a/frontend/__tests__/components/settings/ai-config-form.test.tsx b/frontend/__tests__/components/settings/ai-config-form.test.tsx deleted file mode 100644 index 24cb95bf91..0000000000 --- a/frontend/__tests__/components/settings/ai-config-form.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { describe, it } from "vitest"; - -describe("AIConfigForm", () => { - it.todo("should render the AI config form"); - it.todo("should toggle the advanced settings when clicked"); - it.todo("should call the onSubmit callback when the form is submitted"); - it.todo("should call the onReset callback when the reset button is clicked"); - it.todo("should call the onClose callback when the close button is clicked"); -}); diff --git a/frontend/__tests__/components/settings/dropdown-input.test.tsx b/frontend/__tests__/components/settings/dropdown-input.test.tsx deleted file mode 100644 index 0ad6455e85..0000000000 --- a/frontend/__tests__/components/settings/dropdown-input.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { describe, it } from "vitest"; - -describe("DropdownInput", () => { - it.todo("should render the input"); - it.todo("should render the placeholder"); - it.todo("should render the dropdown when clicked"); - it.todo("should select an option when clicked"); - it.todo("should filter the options when typing"); -}); diff --git a/frontend/__tests__/components/settings/model-selector.test.tsx b/frontend/__tests__/components/settings/model-selector.test.tsx deleted file mode 100644 index dba8df580b..0000000000 --- a/frontend/__tests__/components/settings/model-selector.test.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { describe, it } from "vitest"; - -describe("ModelSelector", () => { - it.todo("should render the model selector"); - it.todo("should display and select the providers"); - it.todo("should display and select the models"); - it.todo("should disable the models if a provider is not selected"); - it.todo("should disable the inputs if isDisabled is true"); - it.todo( - "should set the selected model and provider if the currentModel prop is set", - ); -}); diff --git a/frontend/__tests__/routes/_oh.app.test.tsx b/frontend/__tests__/routes/_oh.app.test.tsx deleted file mode 100644 index f86630152a..0000000000 --- a/frontend/__tests__/routes/_oh.app.test.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { describe, it } from "vitest"; - -describe("App", () => { - it.todo("should render"); -});