SurfSense/surfsense_web/tests/connectors/confluence/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

90 lines
3.8 KiB
TypeScript

import { expect, confluenceWithChatTest 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_CONFLUENCE_PAGES } from "../../helpers/canary";
import { openConnectorPopup } from "../../helpers/ui/connector-popup";
/**
* Proves Confluence MCP OAuth -> live MCP tool discovery/call -> chat.
*
* Confluence migrated to the hosted Atlassian Rovo MCP server (shared with
* Jira), so it is live-tool only: the public indexing route returns
* indexing_started=false and chat should call Confluence MCP tools
* (`searchConfluenceUsingCql`) instead of retrieving from the KB.
*/
test.describe("Confluence connector journey", () => {
test("user connects Confluence and chats through live MCP tools with indexing disabled", async ({
page,
request,
apiToken,
searchSpace,
confluenceConnector,
chatThread,
}) => {
test.setTimeout(90_000); // worker cold-start + live tool chat
expect(confluenceConnector.connector_type).toBe("CONFLUENCE_CONNECTOR");
expect(confluenceConnector.is_indexable).toBe(false);
expect(confluenceConnector.config._token_encrypted).toBe(true);
expect(confluenceConnector.config.mcp_service).toBe("confluence");
expect(confluenceConnector.config.server_config).toMatchObject({
transport: "streamable-http",
url: "https://mcp.atlassian.com/v1/mcp",
});
// Shared Atlassian server issues the token via the same cf.mcp endpoint
// as Jira; assert the endpoint + a live token rather than the (Jira-named)
// shared client id.
expect(confluenceConnector.config.mcp_oauth).toMatchObject({
token_endpoint: "https://cf.mcp.atlassian.com/v1/token",
});
expect(
(confluenceConnector.config.mcp_oauth as Record<string, unknown>).access_token
).toBeTruthy();
expect(confluenceConnector.config.access_token).toBeUndefined();
expect(confluenceConnector.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("Confluence");
await expect(connectorDialog.getByText("Confluence", { exact: true })).toBeVisible();
const beforeDocs = await listDocuments(request, apiToken, searchSpace.id);
expect(beforeDocs).toHaveLength(0);
const disabledIndex = await triggerIndexExpectDisabled(
request,
apiToken,
confluenceConnector.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 Confluence page titled "${FAKE_CONFLUENCE_PAGES.canary.title}"?`,
});
expect(
chat.assistantText,
`chat agent should surface Confluence canary token from live MCP tools; got: ${chat.assistantText.slice(0, 200)}`
).toContain(CANARY_TOKENS.confluenceCanary);
const eventText = JSON.stringify(chat.events);
expect(eventText).toContain("searchConfluenceUsingCql");
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
const refreshed = refreshedConnectors.find((c) => c.id === confluenceConnector.id);
expect(refreshed?.connector_type).toBe("CONFLUENCE_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);
});
});