Download __tests__/api/cloud/conversation-delete.test.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.67 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/__tests__/api/cloud/conversation-delete.test.ts
- Command line
-
hf download hf://SaylorTwift/openhands/__tests__/api/cloud/conversation-delete.test.ts
-
curl -L -o conversation-delete.test.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/__tests__/api/cloud/conversation-delete.test.ts
1.67 kB
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | |
| import { | |
| __resetActiveStoreForTests, | |
| setActiveSelection, | |
| setRegisteredBackends, | |
| } from "#/api/backend-registry/active-store"; | |
| import type { Backend } from "#/api/backend-registry/types"; | |
| import AgentServerConversationService from "#/api/conversation-service/agent-server-conversation-service.api"; | |
| import { getFetchCall, mockJsonResponse } from "./fetch-test-utils"; | |
| const cloudBackend: Backend = { | |
| id: "prod", | |
| name: "Production", | |
| host: "https://app.all-hands.dev", | |
| apiKey: "bearer-token", | |
| kind: "cloud", | |
| }; | |
| const originalFetch = global.fetch; | |
| const fetchMock = vi.fn(); | |
| beforeEach(() => { | |
| window.localStorage.clear(); | |
| __resetActiveStoreForTests(); | |
| setRegisteredBackends([cloudBackend]); | |
| setActiveSelection({ backendId: cloudBackend.id }); | |
| fetchMock.mockReset(); | |
| fetchMock.mockResolvedValue(mockJsonResponse({ success: true })); | |
| global.fetch = fetchMock as typeof fetch; | |
| }); | |
| afterEach(() => { | |
| window.localStorage.clear(); | |
| __resetActiveStoreForTests(); | |
| fetchMock.mockReset(); | |
| global.fetch = originalFetch; | |
| }); | |
| describe("AgentServerConversationService.deleteConversation cloud branch", () => { | |
| it("calls the cloud DELETE app-conversations endpoint directly", async () => { | |
| await AgentServerConversationService.deleteConversation("conv-abc"); | |
| expect(fetchMock).toHaveBeenCalledOnce(); | |
| const [url, init] = getFetchCall(fetchMock); | |
| expect(url).toBe(`${cloudBackend.host}/api/v1/app-conversations/conv-abc`); | |
| expect(init).toMatchObject({ | |
| method: "DELETE", | |
| headers: { Authorization: "Bearer bearer-token" }, | |
| }); | |
| }); | |
| }); | |