From 7490c1927ff6b9469524c18e7a596d4fa9f8f661 Mon Sep 17 00:00:00 2001 From: "sp.wack" <83104063+amanape@users.noreply.github.com> Date: Thu, 15 May 2025 18:20:52 +0400 Subject: [PATCH] fix(frontend): Failing tests (#8519) --- .../chat/action-suggestions.test.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/__tests__/components/chat/action-suggestions.test.tsx b/frontend/__tests__/components/chat/action-suggestions.test.tsx index 1a5d885667..e4928ee146 100644 --- a/frontend/__tests__/components/chat/action-suggestions.test.tsx +++ b/frontend/__tests__/components/chat/action-suggestions.test.tsx @@ -4,6 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ActionSuggestions } from "#/components/features/chat/action-suggestions"; import OpenHands from "#/api/open-hands"; import { MOCK_DEFAULT_USER_SETTINGS } from "#/mocks/handlers"; +import { ConversationProvider } from "#/context/conversation-context"; // Mock dependencies vi.mock("posthog-js", () => ({ @@ -38,12 +39,20 @@ vi.mock("react-i18next", () => ({ }), })); +vi.mock("react-router", () => ({ + useParams: () => ({ + conversationId: "test-conversation-id", + }), +})); + const renderActionSuggestions = () => render( {}} />, { wrapper: ({ children }) => ( - - {children} - + + + {children} + + ), }); @@ -65,6 +74,11 @@ describe("ActionSuggestions", () => { }); it("should render both GitHub buttons when GitHub token is set and repository is selected", async () => { + const getConversationSpy = vi.spyOn(OpenHands, "getConversation"); + // @ts-expect-error - only required for testing + getConversationSpy.mockResolvedValue({ + selected_repository: "test-repo", + }); renderActionSuggestions(); // Find all buttons with data-testid="suggestion"