π OpenHands: AI-Driven Development
test: fix the failed unit tests. (#2721)
Leo82ea8b355622
diff --git a/frontend/src/components/chat/ChatInterface.test.tsx b/frontend/src/components/chat/ChatInterface.test.tsxindex fdcdfade52..0bea479428 100644--- a/frontend/src/components/chat/ChatInterface.test.tsx+++ b/frontend/src/components/chat/ChatInterface.test.tsx@@ -3,11 +3,13 @@ import { screen, act, fireEvent } from "@testing-library/react";import { describe, expect, it } from "vitest";import userEvent from "@testing-library/user-event";import { renderWithProviders } from "test-utils";+import { useTranslation } from "react-i18next";import ChatInterface from "./ChatInterface";import Session from "#/services/session";import ActionType from "#/types/ActionType";import { addAssistantMessage } from "#/state/chatSlice";import AgentState from "#/types/AgentState";+import { I18nKey } from "#/i18n/declaration";// avoid typing side-effectvi.mock("#/hooks/useTyping", () => ({@@ -113,7 +115,11 @@ describe("ChatInterface", () => {},});- const submitButton = screen.getByLabelText(/send message/i);+ const { t } = useTranslation();++ const submitButton = screen.getByLabelText(+ t(I18nKey.CHAT_INTERFACE$TOOLTIP_SEND_MESSAGE),+ );expect(submitButton).toBeDisabled();});diff --git a/frontend/src/components/terminal/Terminal.test.tsx b/frontend/src/components/terminal/Terminal.test.tsxindex bff70e50a9..fbf99c8d22 100644--- a/frontend/src/components/terminal/Terminal.test.tsx+++ b/frontend/src/components/terminal/Terminal.test.tsx@@ -13,6 +13,8 @@ const openMock = vi.fn();const writeMock = vi.fn();const writelnMock = vi.fn();const disposeMock = vi.fn();+const onKeyMock = vi.fn();+const attachCustomKeyEventHandlerMock = vi.fn();vi.mock("@xterm/xterm", async (importOriginal) => ({...(await importOriginal<typeof import("@xterm/xterm")>()),@@ -21,6 +23,8 @@ vi.mock("@xterm/xterm", async (importOriginal) => ({write: writeMock,writeln: writelnMock,dispose: disposeMock,+ onKey: onKeyMock,+ attachCustomKeyEventHandler: attachCustomKeyEventHandlerMock,loadAddon: vi.fn(),})),}));@@ -42,7 +46,7 @@ describe("Terminal", () => {it("should render a terminal", () => {renderTerminal();- expect(screen.getByText("Terminal (read-only)")).toBeInTheDocument();+ expect(screen.getByText("Terminal")).toBeInTheDocument();expect(openMock).toHaveBeenCalledTimes(1);expect(writeMock).toHaveBeenCalledWith("$ ");