mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 09:12:40 +02:00
test(e2e): cover connector PDF docling indexing in journeys
This commit is contained in:
parent
fbfde74cdc
commit
66eebf614f
4 changed files with 251 additions and 138 deletions
|
|
@ -26,7 +26,7 @@ test.describe("Composio Drive journey", () => {
|
||||||
composioDriveConnector,
|
composioDriveConnector,
|
||||||
chatThread,
|
chatThread,
|
||||||
}) => {
|
}) => {
|
||||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
test.setTimeout(240_000); // worker cold-start + Docling + summarize + embed + chunk
|
||||||
|
|
||||||
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
||||||
waitUntil: "domcontentloaded",
|
waitUntil: "domcontentloaded",
|
||||||
|
|
@ -35,53 +35,63 @@ test.describe("Composio Drive journey", () => {
|
||||||
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
||||||
await expect(connectorDialog).toBeVisible();
|
await expect(connectorDialog).toBeVisible();
|
||||||
|
|
||||||
|
const selectedFiles = [
|
||||||
|
{
|
||||||
|
id: FAKE_DRIVE_FILES.canary.id,
|
||||||
|
name: FAKE_DRIVE_FILES.canary.name,
|
||||||
|
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: FAKE_DRIVE_FILES.pdfComposio.id,
|
||||||
|
name: FAKE_DRIVE_FILES.pdfComposio.name,
|
||||||
|
mimeType: FAKE_DRIVE_FILES.pdfComposio.mimeType,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const indexingOptions = {
|
||||||
|
max_files_per_folder: 10,
|
||||||
|
incremental_sync: false,
|
||||||
|
include_subfolders: false,
|
||||||
|
};
|
||||||
|
|
||||||
await updateConnectorConfig(request, apiToken, composioDriveConnector.id, {
|
await updateConnectorConfig(request, apiToken, composioDriveConnector.id, {
|
||||||
...composioDriveConnector.config,
|
...composioDriveConnector.config,
|
||||||
selected_folders: [],
|
selected_folders: [],
|
||||||
selected_files: [
|
selected_files: selectedFiles,
|
||||||
{
|
indexing_options: indexingOptions,
|
||||||
id: FAKE_DRIVE_FILES.canary.id,
|
|
||||||
name: FAKE_DRIVE_FILES.canary.name,
|
|
||||||
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
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: selectedFiles,
|
||||||
{
|
indexing_options: indexingOptions,
|
||||||
id: FAKE_DRIVE_FILES.canary.id,
|
|
||||||
name: FAKE_DRIVE_FILES.canary.name,
|
|
||||||
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
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: 240_000,
|
||||||
intervalMs: 1_500,
|
intervalMs: 1_500,
|
||||||
minDocuments: 1,
|
minDocuments: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DRIVE_FILES.canary.name, {
|
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DRIVE_FILES.canary.name, {
|
||||||
timeoutMs: 30_000,
|
timeoutMs: 30_000,
|
||||||
});
|
});
|
||||||
|
await waitForDocumentByTitle(
|
||||||
|
request,
|
||||||
|
apiToken,
|
||||||
|
searchSpace.id,
|
||||||
|
FAKE_DRIVE_FILES.pdfComposio.name,
|
||||||
|
{ timeoutMs: 60_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);
|
||||||
|
const pdfDoc = docs.find((d) => d.title === FAKE_DRIVE_FILES.pdfComposio.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");
|
||||||
|
expect(canaryDoc.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
expect(pdfDoc, "Composio Drive PDF document must exist after indexing").toBeDefined();
|
||||||
|
if (!pdfDoc) throw new Error("unreachable: pdfDoc asserted defined above");
|
||||||
|
expect(pdfDoc.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
@ -91,8 +101,18 @@ test.describe("Composio Drive journey", () => {
|
||||||
`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.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const pdfEditor = await getEditorContent(request, apiToken, searchSpace.id, pdfDoc.id);
|
||||||
|
expect(
|
||||||
|
pdfEditor.source_markdown,
|
||||||
|
`PDF canary token ${CANARY_TOKENS.composioDrivePdfCanary} should appear in editor source_markdown; ` +
|
||||||
|
`got first 200 chars: ${pdfEditor.source_markdown.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.composioDrivePdfCanary);
|
||||||
|
expect(pdfEditor.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
expect(pdfEditor.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();
|
||||||
|
|
@ -106,5 +126,15 @@ test.describe("Composio Drive journey", () => {
|
||||||
chat.assistantText,
|
chat.assistantText,
|
||||||
`chat agent should surface canary token after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
`chat agent should surface canary token after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
||||||
).toContain(CANARY_TOKENS.driveCanaryFile);
|
).toContain(CANARY_TOKENS.driveCanaryFile);
|
||||||
|
|
||||||
|
const pdfChat = await streamChatToCompletion(request, apiToken, {
|
||||||
|
searchSpaceId: searchSpace.id,
|
||||||
|
threadId: chatThread.id,
|
||||||
|
query: "What is in my e2e-composio-canary.pdf Drive file?",
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
pdfChat.assistantText,
|
||||||
|
`chat agent should surface Composio Drive PDF canary token after indexing; got: ${pdfChat.assistantText.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.composioDrivePdfCanary);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ test.describe("Native Dropbox journey", () => {
|
||||||
nativeDropboxConnector,
|
nativeDropboxConnector,
|
||||||
chatThread,
|
chatThread,
|
||||||
}) => {
|
}) => {
|
||||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
test.setTimeout(240_000); // worker cold-start + Docling + summarize + embed + chunk
|
||||||
|
|
||||||
expect(nativeDropboxConnector.connector_type).toBe("DROPBOX_CONNECTOR");
|
expect(nativeDropboxConnector.connector_type).toBe("DROPBOX_CONNECTOR");
|
||||||
expect(nativeDropboxConnector.is_indexable).toBe(true);
|
expect(nativeDropboxConnector.is_indexable).toBe(true);
|
||||||
|
|
@ -42,6 +42,11 @@ test.describe("Native Dropbox journey", () => {
|
||||||
name: FAKE_DROPBOX_FILES.canary.name,
|
name: FAKE_DROPBOX_FILES.canary.name,
|
||||||
mimeType: FAKE_DROPBOX_FILES.canary.mimeType,
|
mimeType: FAKE_DROPBOX_FILES.canary.mimeType,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: FAKE_DROPBOX_FILES.pdf.id,
|
||||||
|
name: FAKE_DROPBOX_FILES.pdf.name,
|
||||||
|
mimeType: FAKE_DROPBOX_FILES.pdf.mimeType,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
// Keep the shared Drive-style body shape. Dropbox currently defaults
|
// Keep the shared Drive-style body shape. Dropbox currently defaults
|
||||||
// these internally because the indexer expects max_files/use_delta_sync.
|
// these internally because the indexer expects max_files/use_delta_sync.
|
||||||
|
|
@ -64,9 +69,9 @@ test.describe("Native Dropbox journey", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForIndexingComplete(request, apiToken, nativeDropboxConnector.id, searchSpace.id, {
|
await waitForIndexingComplete(request, apiToken, nativeDropboxConnector.id, searchSpace.id, {
|
||||||
timeoutMs: 150_000,
|
timeoutMs: 240_000,
|
||||||
intervalMs: 1_500,
|
intervalMs: 1_500,
|
||||||
minDocuments: 1,
|
minDocuments: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForDocumentByTitle(
|
await waitForDocumentByTitle(
|
||||||
|
|
@ -76,13 +81,20 @@ test.describe("Native Dropbox journey", () => {
|
||||||
FAKE_DROPBOX_FILES.canary.name,
|
FAKE_DROPBOX_FILES.canary.name,
|
||||||
{ timeoutMs: 30_000 }
|
{ timeoutMs: 30_000 }
|
||||||
);
|
);
|
||||||
|
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DROPBOX_FILES.pdf.name, {
|
||||||
|
timeoutMs: 60_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_DROPBOX_FILES.canary.name);
|
const canaryDoc = docs.find((d) => d.title === FAKE_DROPBOX_FILES.canary.name);
|
||||||
|
const pdfDoc = docs.find((d) => d.title === FAKE_DROPBOX_FILES.pdf.name);
|
||||||
|
|
||||||
expect(canaryDoc, "Dropbox canary document must exist after indexing").toBeDefined();
|
expect(canaryDoc, "Dropbox 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");
|
||||||
expect(canaryDoc.document_type).toBe("DROPBOX_FILE");
|
expect(canaryDoc.document_type).toBe("DROPBOX_FILE");
|
||||||
|
expect(pdfDoc, "Dropbox PDF document must exist after indexing").toBeDefined();
|
||||||
|
if (!pdfDoc) throw new Error("unreachable: pdfDoc asserted defined above");
|
||||||
|
expect(pdfDoc.document_type).toBe("DROPBOX_FILE");
|
||||||
|
|
||||||
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
||||||
expect(
|
expect(
|
||||||
|
|
@ -93,6 +105,15 @@ test.describe("Native Dropbox journey", () => {
|
||||||
expect(editor.document_type).toBe("DROPBOX_FILE");
|
expect(editor.document_type).toBe("DROPBOX_FILE");
|
||||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const pdfEditor = await getEditorContent(request, apiToken, searchSpace.id, pdfDoc.id);
|
||||||
|
expect(
|
||||||
|
pdfEditor.source_markdown,
|
||||||
|
`PDF canary token ${CANARY_TOKENS.dropboxPdfCanary} should appear in editor source_markdown; ` +
|
||||||
|
`got first 200 chars: ${pdfEditor.source_markdown.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.dropboxPdfCanary);
|
||||||
|
expect(pdfEditor.document_type).toBe("DROPBOX_FILE");
|
||||||
|
expect(pdfEditor.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 === nativeDropboxConnector.id);
|
const refreshed = refreshedConnectors.find((c) => c.id === nativeDropboxConnector.id);
|
||||||
expect(refreshed?.connector_type).toBe("DROPBOX_CONNECTOR");
|
expect(refreshed?.connector_type).toBe("DROPBOX_CONNECTOR");
|
||||||
|
|
@ -109,5 +130,16 @@ test.describe("Native Dropbox journey", () => {
|
||||||
"chat agent should surface Dropbox canary token after indexing; " +
|
"chat agent should surface Dropbox canary token after indexing; " +
|
||||||
`got: ${chat.assistantText.slice(0, 200)}`
|
`got: ${chat.assistantText.slice(0, 200)}`
|
||||||
).toContain(CANARY_TOKENS.dropboxCanary);
|
).toContain(CANARY_TOKENS.dropboxCanary);
|
||||||
|
|
||||||
|
const pdfChat = await streamChatToCompletion(request, apiToken, {
|
||||||
|
searchSpaceId: searchSpace.id,
|
||||||
|
threadId: chatThread.id,
|
||||||
|
query: "What is in my e2e-dropbox-canary.pdf Dropbox file?",
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
pdfChat.assistantText,
|
||||||
|
"chat agent should surface Dropbox PDF canary token after indexing; " +
|
||||||
|
`got: ${pdfChat.assistantText.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.dropboxPdfCanary);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ test.describe("Native Google Drive journey", () => {
|
||||||
nativeDriveConnector,
|
nativeDriveConnector,
|
||||||
chatThread,
|
chatThread,
|
||||||
}) => {
|
}) => {
|
||||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
test.setTimeout(240_000); // worker cold-start + Docling + summarize + embed + chunk
|
||||||
|
|
||||||
expect(nativeDriveConnector.connector_type).toBe("GOOGLE_DRIVE_CONNECTOR");
|
expect(nativeDriveConnector.connector_type).toBe("GOOGLE_DRIVE_CONNECTOR");
|
||||||
expect(nativeDriveConnector.is_indexable).toBe(true);
|
expect(nativeDriveConnector.is_indexable).toBe(true);
|
||||||
|
|
@ -46,6 +46,11 @@ test.describe("Native Google Drive journey", () => {
|
||||||
name: FAKE_DRIVE_FILES.canary.name,
|
name: FAKE_DRIVE_FILES.canary.name,
|
||||||
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
mimeType: FAKE_DRIVE_FILES.canary.mimeType,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: FAKE_DRIVE_FILES.pdfNative.id,
|
||||||
|
name: FAKE_DRIVE_FILES.pdfNative.name,
|
||||||
|
mimeType: FAKE_DRIVE_FILES.pdfNative.mimeType,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const indexingOptions = {
|
const indexingOptions = {
|
||||||
max_files_per_folder: 10,
|
max_files_per_folder: 10,
|
||||||
|
|
@ -66,21 +71,32 @@ test.describe("Native Google Drive journey", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForIndexingComplete(request, apiToken, nativeDriveConnector.id, searchSpace.id, {
|
await waitForIndexingComplete(request, apiToken, nativeDriveConnector.id, searchSpace.id, {
|
||||||
timeoutMs: 150_000,
|
timeoutMs: 240_000,
|
||||||
intervalMs: 1_500,
|
intervalMs: 1_500,
|
||||||
minDocuments: 1,
|
minDocuments: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DRIVE_FILES.canary.name, {
|
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_DRIVE_FILES.canary.name, {
|
||||||
timeoutMs: 30_000,
|
timeoutMs: 30_000,
|
||||||
});
|
});
|
||||||
|
await waitForDocumentByTitle(
|
||||||
|
request,
|
||||||
|
apiToken,
|
||||||
|
searchSpace.id,
|
||||||
|
FAKE_DRIVE_FILES.pdfNative.name,
|
||||||
|
{ timeoutMs: 60_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);
|
||||||
|
const pdfDoc = docs.find((d) => d.title === FAKE_DRIVE_FILES.pdfNative.name);
|
||||||
|
|
||||||
expect(canaryDoc, "native Drive canary document must exist after indexing").toBeDefined();
|
expect(canaryDoc, "native Drive 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");
|
||||||
expect(canaryDoc.document_type).toBe("GOOGLE_DRIVE_FILE");
|
expect(canaryDoc.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
expect(pdfDoc, "native Drive PDF document must exist after indexing").toBeDefined();
|
||||||
|
if (!pdfDoc) throw new Error("unreachable: pdfDoc asserted defined above");
|
||||||
|
expect(pdfDoc.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
|
||||||
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
||||||
expect(
|
expect(
|
||||||
|
|
@ -91,6 +107,15 @@ test.describe("Native Google Drive journey", () => {
|
||||||
expect(editor.document_type).toBe("GOOGLE_DRIVE_FILE");
|
expect(editor.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||||
|
|
||||||
|
const pdfEditor = await getEditorContent(request, apiToken, searchSpace.id, pdfDoc.id);
|
||||||
|
expect(
|
||||||
|
pdfEditor.source_markdown,
|
||||||
|
`PDF canary token ${CANARY_TOKENS.drivePdfCanary} should appear in editor source_markdown; ` +
|
||||||
|
`got first 200 chars: ${pdfEditor.source_markdown.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.drivePdfCanary);
|
||||||
|
expect(pdfEditor.document_type).toBe("GOOGLE_DRIVE_FILE");
|
||||||
|
expect(pdfEditor.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 === nativeDriveConnector.id);
|
const refreshed = refreshedConnectors.find((c) => c.id === nativeDriveConnector.id);
|
||||||
expect(refreshed?.connector_type).toBe("GOOGLE_DRIVE_CONNECTOR");
|
expect(refreshed?.connector_type).toBe("GOOGLE_DRIVE_CONNECTOR");
|
||||||
|
|
@ -106,5 +131,15 @@ test.describe("Native Google Drive journey", () => {
|
||||||
chat.assistantText,
|
chat.assistantText,
|
||||||
`chat agent should surface native Drive canary token after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
`chat agent should surface native Drive canary token after indexing; got: ${chat.assistantText.slice(0, 200)}`
|
||||||
).toContain(CANARY_TOKENS.driveCanaryFile);
|
).toContain(CANARY_TOKENS.driveCanaryFile);
|
||||||
|
|
||||||
|
const pdfChat = await streamChatToCompletion(request, apiToken, {
|
||||||
|
searchSpaceId: searchSpace.id,
|
||||||
|
threadId: chatThread.id,
|
||||||
|
query: "What is in my e2e-canary.pdf native Drive file?",
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
pdfChat.assistantText,
|
||||||
|
`chat agent should surface native Drive PDF canary token after indexing; got: ${pdfChat.assistantText.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.drivePdfCanary);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,10 @@
|
||||||
import { expect, nativeOneDriveWithChatTest as test } from "../../fixtures";
|
import { expect, nativeOneDriveWithChatTest as test } from "../../fixtures";
|
||||||
import { streamChatToCompletion } from "../../helpers/api/chat";
|
import { streamChatToCompletion } from "../../helpers/api/chat";
|
||||||
import {
|
import { listConnectors, triggerIndex, updateConnectorConfig } from "../../helpers/api/connectors";
|
||||||
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_ONEDRIVE_FILES } from "../../helpers/canary";
|
import { CANARY_TOKENS, FAKE_ONEDRIVE_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 native OneDrive wiring from Microsoft OAuth fixture -> selection
|
* Proves the native OneDrive wiring from Microsoft OAuth fixture -> selection
|
||||||
|
|
@ -21,109 +14,132 @@ import {
|
||||||
* persisted config and indexing contract the picker ultimately feeds.
|
* persisted config and indexing contract the picker ultimately feeds.
|
||||||
*/
|
*/
|
||||||
test.describe("Native OneDrive journey", () => {
|
test.describe("Native OneDrive journey", () => {
|
||||||
test(
|
test("user connects OneDrive, selects a file, indexes it, and chats with the canary token", async ({
|
||||||
"user connects OneDrive, selects a file, indexes it, and chats with the canary token",
|
page,
|
||||||
async ({
|
request,
|
||||||
page,
|
apiToken,
|
||||||
|
searchSpace,
|
||||||
|
nativeOneDriveConnector,
|
||||||
|
chatThread,
|
||||||
|
}) => {
|
||||||
|
test.setTimeout(240_000); // worker cold-start + Docling + summarize + embed + chunk
|
||||||
|
|
||||||
|
expect(nativeOneDriveConnector.connector_type).toBe("ONEDRIVE_CONNECTOR");
|
||||||
|
expect(nativeOneDriveConnector.is_indexable).toBe(true);
|
||||||
|
expect(nativeOneDriveConnector.config._token_encrypted).toBe(true);
|
||||||
|
expect(nativeOneDriveConnector.config.composio_connected_account_id).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();
|
||||||
|
|
||||||
|
const selectedFiles = [
|
||||||
|
{
|
||||||
|
id: FAKE_ONEDRIVE_FILES.canary.id,
|
||||||
|
name: FAKE_ONEDRIVE_FILES.canary.name,
|
||||||
|
mimeType: FAKE_ONEDRIVE_FILES.canary.mimeType,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: FAKE_ONEDRIVE_FILES.pdf.id,
|
||||||
|
name: FAKE_ONEDRIVE_FILES.pdf.name,
|
||||||
|
mimeType: FAKE_ONEDRIVE_FILES.pdf.mimeType,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
// Keep the shared Drive-style body shape. OneDrive currently defaults
|
||||||
|
// these internally because the indexer expects max_files/use_delta_sync.
|
||||||
|
const indexingOptions = {
|
||||||
|
max_files_per_folder: 10,
|
||||||
|
incremental_sync: false,
|
||||||
|
include_subfolders: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
await updateConnectorConfig(request, apiToken, nativeOneDriveConnector.id, {
|
||||||
|
...nativeOneDriveConnector.config,
|
||||||
|
selected_folders: [],
|
||||||
|
selected_files: selectedFiles,
|
||||||
|
indexing_options: indexingOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
await triggerIndex(request, apiToken, nativeOneDriveConnector.id, searchSpace.id, {
|
||||||
|
files: selectedFiles,
|
||||||
|
indexing_options: indexingOptions,
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitForIndexingComplete(request, apiToken, nativeOneDriveConnector.id, searchSpace.id, {
|
||||||
|
timeoutMs: 240_000,
|
||||||
|
intervalMs: 1_500,
|
||||||
|
minDocuments: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitForDocumentByTitle(
|
||||||
request,
|
request,
|
||||||
apiToken,
|
apiToken,
|
||||||
searchSpace,
|
searchSpace.id,
|
||||||
nativeOneDriveConnector,
|
FAKE_ONEDRIVE_FILES.canary.name,
|
||||||
chatThread,
|
{ timeoutMs: 30_000 }
|
||||||
}) => {
|
);
|
||||||
test.setTimeout(180_000); // worker cold-start + summarize + embed + chunk
|
await waitForDocumentByTitle(request, apiToken, searchSpace.id, FAKE_ONEDRIVE_FILES.pdf.name, {
|
||||||
|
timeoutMs: 60_000,
|
||||||
|
});
|
||||||
|
|
||||||
expect(nativeOneDriveConnector.connector_type).toBe("ONEDRIVE_CONNECTOR");
|
const docs = await listDocuments(request, apiToken, searchSpace.id);
|
||||||
expect(nativeOneDriveConnector.is_indexable).toBe(true);
|
const canaryDoc = docs.find((d) => d.title === FAKE_ONEDRIVE_FILES.canary.name);
|
||||||
expect(nativeOneDriveConnector.config._token_encrypted).toBe(true);
|
const pdfDoc = docs.find((d) => d.title === FAKE_ONEDRIVE_FILES.pdf.name);
|
||||||
expect(nativeOneDriveConnector.config.composio_connected_account_id).toBeUndefined();
|
|
||||||
|
|
||||||
await page.goto(`/dashboard/${searchSpace.id}/new-chat`, {
|
expect(canaryDoc, "OneDrive canary document must exist after indexing").toBeDefined();
|
||||||
waitUntil: "domcontentloaded",
|
if (!canaryDoc) throw new Error("unreachable: canaryDoc asserted defined above");
|
||||||
});
|
expect(canaryDoc.document_type).toBe("ONEDRIVE_FILE");
|
||||||
await openConnectorPopup(page);
|
expect(pdfDoc, "OneDrive PDF document must exist after indexing").toBeDefined();
|
||||||
const connectorDialog = page.getByRole("dialog", { name: "Manage Connectors" });
|
if (!pdfDoc) throw new Error("unreachable: pdfDoc asserted defined above");
|
||||||
await expect(connectorDialog).toBeVisible();
|
expect(pdfDoc.document_type).toBe("ONEDRIVE_FILE");
|
||||||
|
|
||||||
const selectedFiles = [
|
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
||||||
{
|
expect(
|
||||||
id: FAKE_ONEDRIVE_FILES.canary.id,
|
editor.source_markdown,
|
||||||
name: FAKE_ONEDRIVE_FILES.canary.name,
|
`canary token ${CANARY_TOKENS.onedriveCanary} should appear in editor source_markdown; ` +
|
||||||
mimeType: FAKE_ONEDRIVE_FILES.canary.mimeType,
|
`got first 200 chars: ${editor.source_markdown.slice(0, 200)}`
|
||||||
},
|
).toContain(CANARY_TOKENS.onedriveCanary);
|
||||||
];
|
expect(editor.document_type).toBe("ONEDRIVE_FILE");
|
||||||
// Keep the shared Drive-style body shape. OneDrive currently defaults
|
expect(editor.chunk_count).toBeGreaterThan(0);
|
||||||
// these internally because the indexer expects max_files/use_delta_sync.
|
|
||||||
const indexingOptions = {
|
|
||||||
max_files_per_folder: 10,
|
|
||||||
incremental_sync: false,
|
|
||||||
include_subfolders: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
await updateConnectorConfig(request, apiToken, nativeOneDriveConnector.id, {
|
const pdfEditor = await getEditorContent(request, apiToken, searchSpace.id, pdfDoc.id);
|
||||||
...nativeOneDriveConnector.config,
|
expect(
|
||||||
selected_folders: [],
|
pdfEditor.source_markdown,
|
||||||
selected_files: selectedFiles,
|
`PDF canary token ${CANARY_TOKENS.onedrivePdfCanary} should appear in editor source_markdown; ` +
|
||||||
indexing_options: indexingOptions,
|
`got first 200 chars: ${pdfEditor.source_markdown.slice(0, 200)}`
|
||||||
});
|
).toContain(CANARY_TOKENS.onedrivePdfCanary);
|
||||||
|
expect(pdfEditor.document_type).toBe("ONEDRIVE_FILE");
|
||||||
|
expect(pdfEditor.chunk_count).toBeGreaterThan(0);
|
||||||
|
|
||||||
await triggerIndex(request, apiToken, nativeOneDriveConnector.id, searchSpace.id, {
|
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
||||||
files: selectedFiles,
|
const refreshed = refreshedConnectors.find((c) => c.id === nativeOneDriveConnector.id);
|
||||||
indexing_options: indexingOptions,
|
expect(refreshed?.connector_type).toBe("ONEDRIVE_CONNECTOR");
|
||||||
});
|
expect(refreshed?.is_indexable).toBe(true);
|
||||||
|
expect(refreshed?.last_indexed_at).not.toBeNull();
|
||||||
|
|
||||||
await waitForIndexingComplete(
|
const chat = await streamChatToCompletion(request, apiToken, {
|
||||||
request,
|
searchSpaceId: searchSpace.id,
|
||||||
apiToken,
|
threadId: chatThread.id,
|
||||||
nativeOneDriveConnector.id,
|
query: "What is in my e2e-onedrive-canary.txt OneDrive file?",
|
||||||
searchSpace.id,
|
});
|
||||||
{
|
expect(
|
||||||
timeoutMs: 150_000,
|
chat.assistantText,
|
||||||
intervalMs: 1_500,
|
"chat agent should surface OneDrive canary token after indexing; " +
|
||||||
minDocuments: 1,
|
`got: ${chat.assistantText.slice(0, 200)}`
|
||||||
}
|
).toContain(CANARY_TOKENS.onedriveCanary);
|
||||||
);
|
|
||||||
|
|
||||||
await waitForDocumentByTitle(
|
const pdfChat = await streamChatToCompletion(request, apiToken, {
|
||||||
request,
|
searchSpaceId: searchSpace.id,
|
||||||
apiToken,
|
threadId: chatThread.id,
|
||||||
searchSpace.id,
|
query: "What is in my e2e-onedrive-canary.pdf OneDrive file?",
|
||||||
FAKE_ONEDRIVE_FILES.canary.name,
|
});
|
||||||
{ timeoutMs: 30_000 }
|
expect(
|
||||||
);
|
pdfChat.assistantText,
|
||||||
|
"chat agent should surface OneDrive PDF canary token after indexing; " +
|
||||||
const docs = await listDocuments(request, apiToken, searchSpace.id);
|
`got: ${pdfChat.assistantText.slice(0, 200)}`
|
||||||
const canaryDoc = docs.find((d) => d.title === FAKE_ONEDRIVE_FILES.canary.name);
|
).toContain(CANARY_TOKENS.onedrivePdfCanary);
|
||||||
|
});
|
||||||
expect(canaryDoc, "OneDrive canary document must exist after indexing").toBeDefined();
|
|
||||||
if (!canaryDoc) throw new Error("unreachable: canaryDoc asserted defined above");
|
|
||||||
expect(canaryDoc.document_type).toBe("ONEDRIVE_FILE");
|
|
||||||
|
|
||||||
const editor = await getEditorContent(request, apiToken, searchSpace.id, canaryDoc.id);
|
|
||||||
expect(
|
|
||||||
editor.source_markdown,
|
|
||||||
`canary token ${CANARY_TOKENS.onedriveCanary} should appear in editor source_markdown; ` +
|
|
||||||
`got first 200 chars: ${editor.source_markdown.slice(0, 200)}`
|
|
||||||
).toContain(CANARY_TOKENS.onedriveCanary);
|
|
||||||
expect(editor.document_type).toBe("ONEDRIVE_FILE");
|
|
||||||
expect(editor.chunk_count).toBeGreaterThan(0);
|
|
||||||
|
|
||||||
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
|
||||||
const refreshed = refreshedConnectors.find((c) => c.id === nativeOneDriveConnector.id);
|
|
||||||
expect(refreshed?.connector_type).toBe("ONEDRIVE_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 e2e-onedrive-canary.txt OneDrive file?",
|
|
||||||
});
|
|
||||||
expect(
|
|
||||||
chat.assistantText,
|
|
||||||
"chat agent should surface OneDrive canary token after indexing; " +
|
|
||||||
`got: ${chat.assistantText.slice(0, 200)}`
|
|
||||||
).toContain(CANARY_TOKENS.onedriveCanary);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue