mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 17:22:38 +02:00
74 lines
3 KiB
TypeScript
74 lines
3 KiB
TypeScript
import { expect, nativeGmailWithChatTest as test } from "../../../fixtures";
|
|
import { streamChatToCompletion } from "../../../helpers/api/chat";
|
|
import { listConnectors, triggerIndexExpectDisabled } from "../../../helpers/api/connectors";
|
|
import { listDocuments } from "../../../helpers/api/documents";
|
|
import { CANARY_TOKENS, FAKE_GMAIL_MESSAGES } from "../../../helpers/canary";
|
|
import { openConnectorPopup } from "../../../helpers/ui/connector-popup";
|
|
|
|
/**
|
|
* Proves the native Gmail wiring from Google OAuth fixture -> live Gmail
|
|
* tools -> chat.
|
|
*
|
|
* Native Gmail is currently live-tool only: the public indexing route
|
|
* returns indexing_started=false and chat should call Gmail tools.
|
|
*/
|
|
test.describe("Native Google Gmail journey", () => {
|
|
test("user connects native Gmail and chats through live Gmail tools with indexing disabled", async ({
|
|
page,
|
|
request,
|
|
apiToken,
|
|
searchSpace,
|
|
nativeGmailConnector,
|
|
chatThread,
|
|
}) => {
|
|
test.setTimeout(90_000); // worker cold-start + live tool chat
|
|
|
|
expect(nativeGmailConnector.connector_type).toBe("GOOGLE_GMAIL_CONNECTOR");
|
|
expect(nativeGmailConnector.is_indexable).toBe(false);
|
|
expect(nativeGmailConnector.config._token_encrypted).toBe(true);
|
|
expect(nativeGmailConnector.config.composio_connected_account_id).toBeUndefined();
|
|
|
|
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
|
waitUntil: "domcontentloaded",
|
|
});
|
|
await openConnectorPopup(page);
|
|
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
|
await expect(connectorDialog).toBeVisible();
|
|
await expect(connectorDialog.getByRole("button", { name: "Manage" })).toBeVisible();
|
|
|
|
const beforeDocs = await listDocuments(request, apiToken, searchSpace.id);
|
|
expect(beforeDocs).toHaveLength(0);
|
|
|
|
const disabledIndex = await triggerIndexExpectDisabled(
|
|
request,
|
|
apiToken,
|
|
nativeGmailConnector.id,
|
|
searchSpace.id
|
|
);
|
|
expect(disabledIndex.message ?? "").toContain("real-time agent tools");
|
|
expect(disabledIndex.message ?? "").toContain("background indexing is disabled");
|
|
|
|
const chat = await streamChatToCompletion(request, apiToken, {
|
|
searchSpaceId: searchSpace.id,
|
|
threadId: chatThread.id,
|
|
query: `What is in my Gmail message titled "${FAKE_GMAIL_MESSAGES.canary.subject}"?`,
|
|
});
|
|
expect(
|
|
chat.assistantText,
|
|
`chat agent should surface native Gmail canary token from live tools; got: ${chat.assistantText.slice(0, 200)}`
|
|
).toContain(CANARY_TOKENS.gmailCanary);
|
|
|
|
const eventText = JSON.stringify(chat.events);
|
|
expect(eventText).toContain("search_gmail");
|
|
expect(eventText).toContain("read_gmail_email");
|
|
|
|
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
|
const refreshed = refreshedConnectors.find((c) => c.id === nativeGmailConnector.id);
|
|
expect(refreshed?.connector_type).toBe("GOOGLE_GMAIL_CONNECTOR");
|
|
expect(refreshed?.is_indexable).toBe(false);
|
|
expect(refreshed?.last_indexed_at).toBeNull();
|
|
|
|
const afterDocs = await listDocuments(request, apiToken, searchSpace.id);
|
|
expect(afterDocs).toHaveLength(0);
|
|
});
|
|
});
|