SurfSense/surfsense_web/tests/connectors/notion/journey.spec.ts
DESKTOP-RTLN3BA\$punk ab747e7a49 feat(agents): consolidate connectors under mcp_discovery; route web search through google_search
MCP consolidation:
- Route all MCP-capable connectors (Slack, Jira, Linear, ClickUp, Airtable,
  Notion, Confluence, interim Gmail/Calendar, custom MCP) through a single
  `mcp_discovery` subagent. Drive/OneDrive/Dropbox stay native to enrich the KB.
- Deprecate Discord/Teams/Luma: no viable official MCP server.

Google-only web search:
- Remove the main-agent `web_search` tool and the SearXNG platform service;
  all public web search now flows through the `google_search` subagent via task().
- Deprecate the Tavily/SearXNG/Linkup/Baidu search connectors (HTTP 410 on
  create, "Deprecated" badge); guide heavy users to the custom MCP connector.
- Remove web search from anonymous chat (pure Q&A).
- Tear SearXNG out of docker compose + install scripts; drop tavily-python
  and linkup-sdk deps and their config/env vars.

Fix:
- metrics._package_version() now swallows any metadata lookup failure. A
  malformed editable-install distribution with no `Version` field raised
  KeyError deep in importlib.metadata, and since it runs on every
  record_subagent_invoke_duration call it was crashing every task()
  delegation. Verified end-to-end against live GPT-5.4.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-04 21:06:04 -07:00

87 lines
3.5 KiB
TypeScript

import { expect, notionWithChatTest 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_NOTION_PAGES } from "../../helpers/canary";
import { openConnectorPopup } from "../../helpers/ui/connector-popup";
/**
* Proves Notion MCP OAuth -> live MCP tool discovery/call -> chat.
*
* Notion migrated from indexed OAuth to the hosted Notion MCP server, so it is
* live-tool only: the public indexing route returns indexing_started=false and
* chat should call Notion MCP tools (`search`) instead of retrieving from the KB.
*/
test.describe("Notion connector journey", () => {
test("user connects Notion and chats through live MCP tools with indexing disabled", async ({
page,
request,
apiToken,
searchSpace,
notionConnector,
chatThread,
}) => {
test.setTimeout(90_000); // worker cold-start + live tool chat
expect(notionConnector.connector_type).toBe("NOTION_CONNECTOR");
expect(notionConnector.is_indexable).toBe(false);
expect(notionConnector.config._token_encrypted).toBe(true);
expect(notionConnector.config.mcp_service).toBe("notion");
expect(notionConnector.config.server_config).toMatchObject({
transport: "streamable-http",
url: "https://mcp.notion.com/mcp",
});
expect(notionConnector.config.mcp_oauth).toMatchObject({
client_id: "fake-notion-mcp-client-id",
token_endpoint: "https://mcp.notion.com/token",
});
expect(
(notionConnector.config.mcp_oauth as Record<string, unknown>).access_token
).toBeTruthy();
expect(notionConnector.config.access_token).toBeUndefined();
expect(notionConnector.config.refresh_token).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 connectorDialog.getByPlaceholder("Search").fill("Notion");
await expect(connectorDialog.getByText("Notion", { exact: true })).toBeVisible();
const beforeDocs = await listDocuments(request, apiToken, searchSpace.id);
expect(beforeDocs).toHaveLength(0);
const disabledIndex = await triggerIndexExpectDisabled(
request,
apiToken,
notionConnector.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 Notion page titled "${FAKE_NOTION_PAGES.canary.title}"?`,
});
expect(
chat.assistantText,
`chat agent should surface Notion canary token from live MCP tools; got: ${chat.assistantText.slice(0, 200)}`
).toContain(CANARY_TOKENS.notionCanary);
const eventText = JSON.stringify(chat.events);
expect(eventText).toContain(FAKE_NOTION_PAGES.canary.id);
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
const refreshed = refreshedConnectors.find((c) => c.id === notionConnector.id);
expect(refreshed?.connector_type).toBe("NOTION_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);
});
});