|
1 | | -import type { TaskThreadMessage } from "@posthog/shared/domain-types"; |
2 | 1 | import { describe, expect, it, vi } from "vitest"; |
3 | 2 | import { PostHogAPIClient } from "./posthog-client"; |
4 | 3 |
|
@@ -1697,66 +1696,3 @@ describe("PostHogAPIClient", () => { |
1697 | 1696 | }); |
1698 | 1697 | }); |
1699 | 1698 | }); |
1700 | | - |
1701 | | -describe("task thread messages", () => { |
1702 | | - function message( |
1703 | | - overrides: Partial<TaskThreadMessage> = {}, |
1704 | | - ): TaskThreadMessage { |
1705 | | - return { |
1706 | | - id: "message-id", |
1707 | | - task: "task-id", |
1708 | | - content: "@agent investigate this", |
1709 | | - created_at: "2026-07-16T00:00:00Z", |
1710 | | - ...overrides, |
1711 | | - }; |
1712 | | - } |
1713 | | - |
1714 | | - it("creates a message before forwarding it to the agent", async () => { |
1715 | | - const client = new PostHogAPIClient( |
1716 | | - "http://localhost:8000", |
1717 | | - async () => "token", |
1718 | | - async () => "token", |
1719 | | - 123, |
1720 | | - ); |
1721 | | - const create = vi |
1722 | | - .spyOn(client, "createTaskThreadMessage") |
1723 | | - .mockResolvedValue(message()); |
1724 | | - const send = vi |
1725 | | - .spyOn(client, "sendTaskThreadMessageToAgent") |
1726 | | - .mockResolvedValue( |
1727 | | - message({ forwarded_to_agent_at: "2026-07-16T00:00:01Z" }), |
1728 | | - ); |
1729 | | - |
1730 | | - await client.createTaskThreadMessageForAgent( |
1731 | | - "task-id", |
1732 | | - "@agent investigate this", |
1733 | | - ); |
1734 | | - |
1735 | | - expect(create).toHaveBeenCalledWith("task-id", "@agent investigate this"); |
1736 | | - expect(send).toHaveBeenCalledWith("task-id", "message-id"); |
1737 | | - expect(create.mock.invocationCallOrder[0]).toBeLessThan( |
1738 | | - send.mock.invocationCallOrder[0], |
1739 | | - ); |
1740 | | - }); |
1741 | | - |
1742 | | - it("returns the created message when forwarding fails", async () => { |
1743 | | - const client = new PostHogAPIClient( |
1744 | | - "http://localhost:8000", |
1745 | | - async () => "token", |
1746 | | - async () => "token", |
1747 | | - 123, |
1748 | | - ); |
1749 | | - const sendError = new Error("No active run"); |
1750 | | - vi.spyOn(client, "createTaskThreadMessage").mockResolvedValue(message()); |
1751 | | - vi.spyOn(client, "sendTaskThreadMessageToAgent").mockRejectedValue( |
1752 | | - sendError, |
1753 | | - ); |
1754 | | - |
1755 | | - await expect( |
1756 | | - client.createTaskThreadMessageForAgent( |
1757 | | - "task-id", |
1758 | | - "@agent investigate this", |
1759 | | - ), |
1760 | | - ).resolves.toEqual({ message: message(), sendError }); |
1761 | | - }); |
1762 | | -}); |
0 commit comments