test(web): add Linear live-tool journey

This commit is contained in:
Anish Sarkar 2026-05-07 23:16:04 +05:30
parent a60ff02b93
commit 64ed33d25d
2 changed files with 98 additions and 0 deletions

View file

@ -0,0 +1,83 @@
import { expect, linearWithChatTest 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_LINEAR_ISSUES } from "../../helpers/canary";
import { openConnectorPopup } from "../../helpers/ui/connector-popup";
/**
* Proves Linear MCP OAuth -> live MCP tool discovery/call -> chat.
*
* Linear is live-tool only: the public indexing route returns
* indexing_started=false and chat should call Linear MCP tools.
*/
test.describe("Linear connector journey", () => {
test("user connects Linear and chats through live MCP tools with indexing disabled", async ({
page,
request,
apiToken,
searchSpace,
linearConnector,
chatThread,
}) => {
test.setTimeout(90_000); // worker cold-start + live tool chat
expect(linearConnector.connector_type).toBe("LINEAR_CONNECTOR");
expect(linearConnector.is_indexable).toBe(false);
expect(linearConnector.config._token_encrypted).toBe(true);
expect(linearConnector.config.mcp_service).toBe("linear");
expect(linearConnector.config.server_config).toMatchObject({
transport: "streamable-http",
url: "https://mcp.linear.app/mcp",
});
expect(linearConnector.config.mcp_oauth).toMatchObject({
client_id: "fake-linear-mcp-client-id",
token_endpoint: "https://mcp.linear.app/token",
});
expect((linearConnector.config.mcp_oauth as Record<string, unknown>).access_token).toBeTruthy();
expect(linearConnector.config.access_token).toBeUndefined();
expect(linearConnector.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 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,
linearConnector.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 Linear issue titled "${FAKE_LINEAR_ISSUES.canary.title}"?`,
});
expect(
chat.assistantText,
`chat agent should surface Linear canary token from live MCP tools; got: ${chat.assistantText.slice(0, 200)}`
).toContain(CANARY_TOKENS.linearCanary);
const eventText = JSON.stringify(chat.events);
expect(eventText).toContain("list_issues");
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
const refreshed = refreshedConnectors.find((c) => c.id === linearConnector.id);
expect(refreshed?.connector_type).toBe("LINEAR_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);
});
});

View file

@ -21,6 +21,7 @@ export const CANARY_TOKENS = {
gmailCanary: "SURFSENSE_E2E_CANARY_TOKEN_GMAIL_001",
calendarCanary: "SURFSENSE_E2E_CANARY_TOKEN_CALENDAR_001",
notionCanary: "SURFSENSE_E2E_CANARY_TOKEN_NOTION_001",
linearCanary: "SURFSENSE_E2E_CANARY_TOKEN_LINEAR_001",
} as const;
/**
@ -98,6 +99,20 @@ export const FAKE_NOTION_PAGES = {
},
} as const;
/**
* Fake Linear issue IDs that match what the backend MCP fake returns from
* list_issues / get_issue.
*/
export const FAKE_LINEAR_ISSUES = {
canary: {
id: "fake-linear-issue-canary-001",
identifier: "E2E-101",
title: "E2E Canary Linear Issue",
organizationName: "SurfSense E2E Linear Org",
organizationUrlKey: "surfsense-e2e",
},
} as const;
/** Generate a unique-per-run search space name. Keeps parallel tests isolated. */
export function uniqueSearchSpaceName(prefix = "e2e"): string {
return `${prefix}-${randomUUID().slice(0, 8)}`;