refactor(frontend): move conversation APIs to a dedicated service handler (#10957)

This commit is contained in:
Hiep Le
2025-09-16 00:57:15 +07:00
committed by GitHub
parent 10b871f4ab
commit 3f984d878b
45 changed files with 223 additions and 163 deletions

View File

@@ -6,7 +6,7 @@ import { setupStore } from "test-utils";
import { Provider } from "react-redux";
import { createRoutesStub, Outlet } from "react-router";
import SettingsService from "#/settings-service/settings-service.api";
import OpenHands from "#/api/open-hands";
import ConversationService from "#/api/conversation-service/conversation-service.api";
import GitService from "#/api/git-service/git-service.api";
import OptionService from "#/api/option-service/option-service.api";
import { GitRepository } from "#/types/git";
@@ -315,7 +315,10 @@ describe("RepoConnector", () => {
});
it("should create a conversation and redirect with the selected repo when pressing the launch button", async () => {
const createConversationSpy = vi.spyOn(OpenHands, "createConversation");
const createConversationSpy = vi.spyOn(
ConversationService,
"createConversation",
);
createConversationSpy.mockResolvedValue({
conversation_id: "mock-conversation-id",
title: "Test Conversation",
@@ -400,7 +403,10 @@ describe("RepoConnector", () => {
});
it("should change the launch button text to 'Loading...' when creating a conversation", async () => {
const createConversationSpy = vi.spyOn(OpenHands, "createConversation");
const createConversationSpy = vi.spyOn(
ConversationService,
"createConversation",
);
createConversationSpy.mockImplementation(() => new Promise(() => {})); // Never resolves to keep loading state
const retrieveUserGitRepositoriesSpy = vi.spyOn(
GitService,