mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 01:02:39 +02:00
test(web): add Confluence connector journey
This commit is contained in:
parent
e5889053c2
commit
08fdd0a328
3 changed files with 112 additions and 1 deletions
97
surfsense_web/tests/connectors/confluence/journey.spec.ts
Normal file
97
surfsense_web/tests/connectors/confluence/journey.spec.ts
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
import { expect, confluenceWithChatTest as test } from "../../fixtures";
|
||||
import { streamChatToCompletion } from "../../helpers/api/chat";
|
||||
import { listConnectors, triggerIndex } from "../../helpers/api/connectors";
|
||||
import { getEditorContent, listDocuments } from "../../helpers/api/documents";
|
||||
import { CANARY_TOKENS, FAKE_CONFLUENCE_PAGES } from "../../helpers/canary";
|
||||
import { openConnectorPopup } from "../../helpers/ui/connector-popup";
|
||||
import { waitForDocumentByTitle, waitForIndexingComplete } from "../../helpers/waits/indexing";
|
||||
|
||||
/**
|
||||
* Proves Confluence OAuth -> indexed Confluence pages -> stored source_markdown -> chat.
|
||||
*
|
||||
* The external Atlassian provider is faked at the OAuth token/resource and
|
||||
* Confluence page-fetch boundaries; SurfSense's own add/callback routes,
|
||||
* encrypted config storage, indexing endpoint, indexing pipeline, and chat
|
||||
* retrieval remain real.
|
||||
*/
|
||||
test.describe("Confluence connector journey", () => {
|
||||
test("user connects Confluence through OAuth, indexes a page, and chats with the canary token", async ({
|
||||
page,
|
||||
request,
|
||||
apiToken,
|
||||
searchSpace,
|
||||
confluenceConnector,
|
||||
chatThread,
|
||||
}) => {
|
||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
||||
|
||||
expect(confluenceConnector.connector_type).toBe("CONFLUENCE_CONNECTOR");
|
||||
expect(confluenceConnector.is_indexable).toBe(true);
|
||||
expect(confluenceConnector.config._token_encrypted).toBe(true);
|
||||
expect(confluenceConnector.config.cloud_id).toBe(FAKE_CONFLUENCE_PAGES.canary.cloudId);
|
||||
expect(confluenceConnector.config.base_url).toBe(FAKE_CONFLUENCE_PAGES.canary.baseUrl);
|
||||
expect(confluenceConnector.config.access_token).toBeTruthy();
|
||||
expect(confluenceConnector.config.CONFLUENCE_BASE_URL).toBeUndefined();
|
||||
expect(confluenceConnector.config.CONFLUENCE_EMAIL).toBeUndefined();
|
||||
expect(confluenceConnector.config.CONFLUENCE_API_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();
|
||||
|
||||
await triggerIndex(request, apiToken, confluenceConnector.id, searchSpace.id, {});
|
||||
|
||||
await waitForIndexingComplete(request, apiToken, confluenceConnector.id, searchSpace.id, {
|
||||
timeoutMs: 150_000,
|
||||
intervalMs: 1_500,
|
||||
minDocuments: 1,
|
||||
});
|
||||
|
||||
await waitForDocumentByTitle(
|
||||
request,
|
||||
apiToken,
|
||||
searchSpace.id,
|
||||
FAKE_CONFLUENCE_PAGES.canary.title,
|
||||
{
|
||||
timeoutMs: 30_000,
|
||||
}
|
||||
);
|
||||
|
||||
const docs = await listDocuments(request, apiToken, searchSpace.id);
|
||||
const canaryDoc = docs.find((d) => d.title === FAKE_CONFLUENCE_PAGES.canary.title);
|
||||
|
||||
expect(canaryDoc, "Confluence canary document must exist after indexing").toBeDefined();
|
||||
if (!canaryDoc) throw new Error("unreachable: canaryDoc asserted defined above");
|
||||
expect(canaryDoc.document_type).toBe("CONFLUENCE_CONNECTOR");
|
||||
|
||||
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
||||
expect(
|
||||
editor.source_markdown,
|
||||
`canary token ${CANARY_TOKENS.confluenceCanary} should appear in editor source_markdown; ` +
|
||||
`got first 200 chars: ${editor.source_markdown.slice(0, 200)}`
|
||||
).toContain(CANARY_TOKENS.confluenceCanary);
|
||||
expect(editor.document_type).toBe("CONFLUENCE_CONNECTOR");
|
||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||
|
||||
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(true);
|
||||
expect(refreshed?.last_indexed_at).not.toBeNull();
|
||||
|
||||
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 after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
||||
).toContain(CANARY_TOKENS.confluenceCanary);
|
||||
});
|
||||
});
|
||||
|
|
@ -46,7 +46,6 @@ test.describe("Jira connector journey", () => {
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
confluenceCanary: "SURFSENSE_E2E_CANARY_TOKEN_CONFLUENCE_001",
|
||||
linearCanary: "SURFSENSE_E2E_CANARY_TOKEN_LINEAR_001",
|
||||
jiraCanary: "SURFSENSE_E2E_CANARY_TOKEN_JIRA_001",
|
||||
} as const;
|
||||
|
|
@ -100,6 +101,20 @@ export const FAKE_NOTION_PAGES = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Fake Confluence page IDs that match what the backend fake returns from
|
||||
* ConfluenceHistoryConnector.get_pages_by_date_range.
|
||||
*/
|
||||
export const FAKE_CONFLUENCE_PAGES = {
|
||||
canary: {
|
||||
id: "fake-confluence-page-canary-001",
|
||||
title: "E2E Canary Confluence Page",
|
||||
spaceId: "fake-confluence-space-001",
|
||||
cloudId: "fake-confluence-cloud-001",
|
||||
baseUrl: "https://surfsense-e2e-confluence.atlassian.net",
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Fake Linear issue IDs that match what the backend MCP fake returns from
|
||||
* list_issues / get_issue.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue