test(web): add Jira live-tool journey

This commit is contained in:
Anish Sarkar 2026-05-08 00:15:53 +05:30
parent ddfbe0b611
commit 1bd7cad495
2 changed files with 100 additions and 0 deletions

View file

@ -0,0 +1,85 @@
import { expect, jiraWithChatTest 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_JIRA_ISSUES } from "../../helpers/canary";
import { openConnectorPopup } from "../../helpers/ui/connector-popup";
/**
* Proves Jira MCP OAuth -> live MCP tool discovery/call -> chat.
*
* Jira is live-tool only: the public indexing route returns
* indexing_started=false and chat should call Jira MCP tools.
*/
test.describe("Jira connector journey", () => {
test("user connects Jira and chats through live MCP tools with indexing disabled", async ({
page,
request,
apiToken,
searchSpace,
jiraConnector,
chatThread,
}) => {
test.setTimeout(90_000); // worker cold-start + live tool chat
expect(jiraConnector.connector_type).toBe("JIRA_CONNECTOR");
expect(jiraConnector.is_indexable).toBe(false);
expect(jiraConnector.config._token_encrypted).toBe(true);
expect(jiraConnector.config.mcp_service).toBe("jira");
expect(jiraConnector.config.server_config).toMatchObject({
transport: "streamable-http",
url: "https://mcp.atlassian.com/v1/mcp",
});
expect(jiraConnector.config.mcp_oauth).toMatchObject({
client_id: "fake-jira-mcp-client-id",
token_endpoint: "https://cf.mcp.atlassian.com/v1/token",
});
expect((jiraConnector.config.mcp_oauth as Record<string, unknown>).access_token).toBeTruthy();
expect(jiraConnector.config.access_token).toBeUndefined();
expect(jiraConnector.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("Jira");
await expect(connectorDialog.getByText("Jira", { exact: true })).toBeVisible();
await expect(connectorDialog.getByText("1 Account")).toBeVisible();
const beforeDocs = await listDocuments(request, apiToken, searchSpace.id);
expect(beforeDocs).toHaveLength(0);
const disabledIndex = await triggerIndexExpectDisabled(
request,
apiToken,
jiraConnector.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 Jira issue titled "${FAKE_JIRA_ISSUES.canary.summary}"?`,
});
expect(
chat.assistantText,
`chat agent should surface Jira canary token from live MCP tools; got: ${chat.assistantText.slice(0, 200)}`
).toContain(CANARY_TOKENS.jiraCanary);
const eventText = JSON.stringify(chat.events);
expect(eventText).toContain("searchJiraIssuesUsingJql");
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
const refreshed = refreshedConnectors.find((c) => c.id === jiraConnector.id);
expect(refreshed?.connector_type).toBe("JIRA_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

@ -22,6 +22,7 @@ export const CANARY_TOKENS = {
calendarCanary: "SURFSENSE_E2E_CANARY_TOKEN_CALENDAR_001",
notionCanary: "SURFSENSE_E2E_CANARY_TOKEN_NOTION_001",
linearCanary: "SURFSENSE_E2E_CANARY_TOKEN_LINEAR_001",
jiraCanary: "SURFSENSE_E2E_CANARY_TOKEN_JIRA_001",
} as const;
/**
@ -113,6 +114,20 @@ export const FAKE_LINEAR_ISSUES = {
},
} as const;
/**
* Fake Jira issue IDs that match what the backend MCP fake returns from
* searchJiraIssuesUsingJql.
*/
export const FAKE_JIRA_ISSUES = {
canary: {
id: "fake-jira-issue-canary-001",
key: "E2E-101",
summary: "E2E Canary Jira Issue",
cloudId: "fake-jira-cloud-001",
siteUrl: "https://surfsense-e2e.atlassian.net",
},
} 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)}`;