mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
test(web): extend Composio Drive journey to assert chat retrieval
This commit is contained in:
parent
dedccd5c1c
commit
5bdf8a0c31
1 changed files with 89 additions and 77 deletions
|
|
@ -1,99 +1,111 @@
|
||||||
import { composioDriveTest as test, expect } from "../../../fixtures";
|
import { expect, composioDriveWithChatTest as test } from "../../../fixtures";
|
||||||
import { listConnectors, triggerIndex, updateConnectorConfig } from "../../../helpers/api/connectors";
|
import { streamChatToCompletion } from "../../../helpers/api/chat";
|
||||||
|
import {
|
||||||
|
listConnectors,
|
||||||
|
triggerIndex,
|
||||||
|
updateConnectorConfig,
|
||||||
|
} from "../../../helpers/api/connectors";
|
||||||
import { getEditorContent, listDocuments } from "../../../helpers/api/documents";
|
import { getEditorContent, listDocuments } from "../../../helpers/api/documents";
|
||||||
import { CANARY_TOKENS, FAKE_DRIVE_FILES } from "../../../helpers/canary";
|
import { CANARY_TOKENS, FAKE_DRIVE_FILES } from "../../../helpers/canary";
|
||||||
import { openConnectorPopup } from "../../../helpers/ui/connector-popup";
|
import { openConnectorPopup } from "../../../helpers/ui/connector-popup";
|
||||||
import {
|
import { waitForDocumentByTitle, waitForIndexingComplete } from "../../../helpers/waits/indexing";
|
||||||
waitForDocumentByTitle,
|
|
||||||
waitForIndexingComplete,
|
|
||||||
} from "../../../helpers/waits/indexing";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proves the Drive wiring from OAuth fixture -> selection persistence ->
|
* Proves the Drive wiring from OAuth fixture -> selection persistence ->
|
||||||
* indexing -> stored source_markdown -> editor-content retrieval.
|
* indexing -> stored source_markdown -> editor-content retrieval -> chat.
|
||||||
*
|
*
|
||||||
* UI-driven file selection, chat retrieval, and LLM/embedding quality are
|
* UI-driven file selection and LLM/embedding quality are
|
||||||
* covered by later phases or narrower tests.
|
* covered by later phases or narrower tests.
|
||||||
*/
|
*/
|
||||||
test.describe("Composio Drive journey", () => {
|
test.describe("Composio Drive journey", () => {
|
||||||
test(
|
test("user connects Drive, selects a file, indexes it, and chats with the canary token", async ({
|
||||||
"user connects Drive, selects a file, and sees it indexed with the canary token",
|
page,
|
||||||
async ({ page, request, apiToken, searchSpace, composioDriveConnector }) => {
|
request,
|
||||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
apiToken,
|
||||||
|
searchSpace,
|
||||||
|
composioDriveConnector,
|
||||||
|
chatThread,
|
||||||
|
}) => {
|
||||||
|
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
||||||
|
|
||||||
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
||||||
waitUntil: "domcontentloaded",
|
waitUntil: "domcontentloaded",
|
||||||
});
|
});
|
||||||
await openConnectorPopup(page);
|
await openConnectorPopup(page);
|
||||||
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
||||||
await expect(connectorDialog).toBeVisible();
|
await expect(connectorDialog).toBeVisible();
|
||||||
await expect(connectorDialog.getByRole("button", { name: "Manage" })).toBeVisible();
|
await expect(connectorDialog.getByRole("button", { name: "Manage" })).toBeVisible();
|
||||||
|
|
||||||
await updateConnectorConfig(request, apiToken, composioDriveConnector.id, {
|
await updateConnectorConfig(request, apiToken, composioDriveConnector.id, {
|
||||||
...composioDriveConnector.config,
|
...composioDriveConnector.config,
|
||||||
selected_folders: [],
|
selected_folders: [],
|
||||||
selected_files: [
|
selected_files: [
|
||||||
{
|
{
|
||||||
id: FAKE_DRIVE_FILES.canary.id,
|
id: FAKE_DRIVE_FILES.canary.id,
|
||||||
name: FAKE_DRIVE_FILES.canary.name,
|
name: FAKE_DRIVE_FILES.canary.name,
|
||||||
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
||||||
},
|
|
||||||
],
|
|
||||||
indexing_options: {
|
|
||||||
max_files_per_folder: 10,
|
|
||||||
incremental_sync: false,
|
|
||||||
include_subfolders: false,
|
|
||||||
},
|
},
|
||||||
});
|
],
|
||||||
|
indexing_options: {
|
||||||
|
max_files_per_folder: 10,
|
||||||
|
incremental_sync: false,
|
||||||
|
include_subfolders: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
await triggerIndex(request, apiToken, composioDriveConnector.id, searchSpace.id, {
|
await triggerIndex(request, apiToken, composioDriveConnector.id, searchSpace.id, {
|
||||||
files: [
|
files: [
|
||||||
{
|
{
|
||||||
id: FAKE_DRIVE_FILES.canary.id,
|
id: FAKE_DRIVE_FILES.canary.id,
|
||||||
name: FAKE_DRIVE_FILES.canary.name,
|
name: FAKE_DRIVE_FILES.canary.name,
|
||||||
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
||||||
},
|
|
||||||
],
|
|
||||||
indexing_options: {
|
|
||||||
max_files_per_folder: 10,
|
|
||||||
incremental_sync: false,
|
|
||||||
include_subfolders: false,
|
|
||||||
},
|
},
|
||||||
});
|
],
|
||||||
|
indexing_options: {
|
||||||
|
max_files_per_folder: 10,
|
||||||
|
incremental_sync: false,
|
||||||
|
include_subfolders: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
await waitForIndexingComplete(request, apiToken, composioDriveConnector.id, searchSpace.id, {
|
await waitForIndexingComplete(request, apiToken, composioDriveConnector.id, searchSpace.id, {
|
||||||
timeoutMs: 150_000,
|
timeoutMs: 150_000,
|
||||||
intervalMs: 1_500,
|
intervalMs: 1_500,
|
||||||
minDocuments: 1,
|
minDocuments: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForDocumentByTitle(
|
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DRIVE_FILES.canary.name, {
|
||||||
request,
|
timeoutMs: 30_000,
|
||||||
apiToken,
|
});
|
||||||
searchSpace.id,
|
|
||||||
FAKE_DRIVE_FILES.canary.name,
|
|
||||||
{ timeoutMs: 30_000 }
|
|
||||||
);
|
|
||||||
|
|
||||||
const docs = await listDocuments(request, apiToken, searchSpace.id);
|
const docs = await listDocuments(request, apiToken, searchSpace.id);
|
||||||
const canaryDoc = docs.find((d) => d.title === FAKE_DRIVE_FILES.canary.name);
|
const canaryDoc = docs.find((d) => d.title === FAKE_DRIVE_FILES.canary.name);
|
||||||
|
|
||||||
expect(canaryDoc, "canary document must exist after indexing").toBeDefined();
|
expect(canaryDoc, "canary document must exist after indexing").toBeDefined();
|
||||||
if (!canaryDoc) throw new Error("unreachable: canaryDoc asserted defined above");
|
if (!canaryDoc) throw new Error("unreachable: canaryDoc asserted defined above");
|
||||||
|
|
||||||
// content holds the LLM summary; the raw file body lives in source_markdown.
|
// content holds the LLM summary; the raw file body lives in source_markdown.
|
||||||
// editor-content is the same endpoint the UI hits when opening a document.
|
// editor-content is the same endpoint the UI hits when opening a document.
|
||||||
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
||||||
expect(
|
expect(
|
||||||
editor.source_markdown,
|
editor.source_markdown,
|
||||||
`canary token ${CANARY_TOKENS.driveCanaryFile} should appear in editor source_markdown; ` +
|
`canary token ${CANARY_TOKENS.driveCanaryFile} should appear in editor source_markdown; ` +
|
||||||
`got first 200 chars: ${editor.source_markdown.slice(0, 200)}`
|
`got first 200 chars: ${editor.source_markdown.slice(0, 200)}`
|
||||||
).toContain(CANARY_TOKENS.driveCanaryFile);
|
).toContain(CANARY_TOKENS.driveCanaryFile);
|
||||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||||
|
|
||||||
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
||||||
const refreshed = refreshedConnectors.find((c) => c.id === composioDriveConnector.id);
|
const refreshed = refreshedConnectors.find((c) => c.id === composioDriveConnector.id);
|
||||||
expect(refreshed?.last_indexed_at).not.toBeNull();
|
expect(refreshed?.last_indexed_at).not.toBeNull();
|
||||||
}
|
|
||||||
);
|
const chat = await streamChatToCompletion(request, apiToken, {
|
||||||
|
searchSpaceId: searchSpace.id,
|
||||||
|
threadId: chatThread.id,
|
||||||
|
query: "What is in my e2e-canary.txt Drive file?",
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
chat.assistantText,
|
||||||
|
`chat agent should surface canary token after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.driveCanaryFile);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue