mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 17:22:38 +02:00
test(web): add Composio Calendar live-tool journey
This commit is contained in:
parent
bc2dc21a75
commit
0a62dc189c
3 changed files with 101 additions and 0 deletions
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { expect, composioCalendarWithChatTest as test } from "../../../fixtures";
|
||||||
|
import { streamChatToCompletion } from "../../../helpers/api/chat";
|
||||||
|
import { listConnectors } from "../../../helpers/api/connectors";
|
||||||
|
import { listDocuments } from "../../../helpers/api/documents";
|
||||||
|
import { CANARY_TOKENS, FAKE_CALENDAR_EVENTS } from "../../../helpers/canary";
|
||||||
|
import { openConnectorPopup } from "../../../helpers/ui/connector-popup";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Proves the Calendar wiring from OAuth fixture -> live Calendar tools -> chat.
|
||||||
|
*
|
||||||
|
* Composio Calendar is a live connector: it should not index documents into
|
||||||
|
* the knowledge base. Chat should call Calendar tools against the connected
|
||||||
|
* Composio account when the user asks about events.
|
||||||
|
*/
|
||||||
|
test.describe("Composio Calendar journey", () => {
|
||||||
|
test("user connects Calendar and chats through live Calendar tools with the canary token", async ({
|
||||||
|
page,
|
||||||
|
request,
|
||||||
|
apiToken,
|
||||||
|
searchSpace,
|
||||||
|
composioCalendarConnector,
|
||||||
|
chatThread,
|
||||||
|
}) => {
|
||||||
|
test.setTimeout(90_000); // worker cold-start + live tool chat
|
||||||
|
|
||||||
|
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 beforeChatDocs = await listDocuments(request, apiToken, searchSpace.id);
|
||||||
|
expect(beforeChatDocs).toHaveLength(0);
|
||||||
|
|
||||||
|
const chat = await streamChatToCompletion(request, apiToken, {
|
||||||
|
searchSpaceId: searchSpace.id,
|
||||||
|
threadId: chatThread.id,
|
||||||
|
query:
|
||||||
|
`What Calendar event mentions ${CANARY_TOKENS.calendarCanary} next week? ` +
|
||||||
|
`The event title is "${FAKE_CALENDAR_EVENTS.canary.summary}".`,
|
||||||
|
});
|
||||||
|
expect(
|
||||||
|
chat.assistantText,
|
||||||
|
`chat agent should surface Calendar canary token from live tools; got: ${chat.assistantText.slice(0, 200)}`
|
||||||
|
).toContain(CANARY_TOKENS.calendarCanary);
|
||||||
|
|
||||||
|
const eventText = JSON.stringify(chat.events);
|
||||||
|
expect(eventText).toContain("search_calendar_events");
|
||||||
|
|
||||||
|
const refreshedConnectors = await listConnectors(request, apiToken, searchSpace.id);
|
||||||
|
const refreshed = refreshedConnectors.find((c) => c.id === composioCalendarConnector.id);
|
||||||
|
expect(refreshed?.last_indexed_at).toBeNull();
|
||||||
|
|
||||||
|
const afterChatDocs = await listDocuments(request, apiToken, searchSpace.id);
|
||||||
|
expect(afterChatDocs).toHaveLength(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
33
surfsense_web/tests/fixtures/connectors/composio-calendar.fixture.ts
vendored
Normal file
33
surfsense_web/tests/fixtures/connectors/composio-calendar.fixture.ts
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { type ConnectorRow, deleteConnector, runComposioOAuth } from "../../helpers/api/connectors";
|
||||||
|
import { searchSpaceFixtures } from "../search-space.fixture";
|
||||||
|
|
||||||
|
export type ComposioCalendarFixtures = {
|
||||||
|
/**
|
||||||
|
* A pre-connected Composio Google Calendar connector inside the
|
||||||
|
* fixture's `searchSpace`. OAuth uses the strict fake and is cleaned
|
||||||
|
* up automatically after the test.
|
||||||
|
*/
|
||||||
|
composioCalendarConnector: ConnectorRow;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const composioCalendarFixtures = searchSpaceFixtures.extend<ComposioCalendarFixtures>({
|
||||||
|
composioCalendarConnector: async ({ request, apiToken, searchSpace }, use) => {
|
||||||
|
const { connector } = await runComposioOAuth(
|
||||||
|
request,
|
||||||
|
apiToken,
|
||||||
|
searchSpace.id,
|
||||||
|
"googlecalendar"
|
||||||
|
);
|
||||||
|
if (!connector) {
|
||||||
|
throw new Error(
|
||||||
|
"composioCalendarConnector fixture: OAuth completed but no connector was created. " +
|
||||||
|
"Check the backend log — the strict Composio fake likely rejected an unmodelled call."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await use(connector);
|
||||||
|
} finally {
|
||||||
|
await deleteConnector(request, apiToken, connector.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
9
surfsense_web/tests/fixtures/index.ts
vendored
9
surfsense_web/tests/fixtures/index.ts
vendored
|
|
@ -12,6 +12,8 @@
|
||||||
* │ └─ composioDriveWithChatTest — chatThread
|
* │ └─ composioDriveWithChatTest — chatThread
|
||||||
* └─ composioGmailFixtures — composioGmailConnector
|
* └─ composioGmailFixtures — composioGmailConnector
|
||||||
* └─ composioGmailWithChatTest — chatThread
|
* └─ composioGmailWithChatTest — chatThread
|
||||||
|
* └─ composioCalendarFixtures — composioCalendarConnector
|
||||||
|
* └─ composioCalendarWithChatTest — chatThread
|
||||||
*
|
*
|
||||||
* To add a new connector (Gmail, Slack, manual upload, etc.):
|
* To add a new connector (Gmail, Slack, manual upload, etc.):
|
||||||
* 1. Add a fixture file under `fixtures/connectors/<name>.fixture.ts`.
|
* 1. Add a fixture file under `fixtures/connectors/<name>.fixture.ts`.
|
||||||
|
|
@ -20,11 +22,13 @@
|
||||||
*/
|
*/
|
||||||
export { expect } from "@playwright/test";
|
export { expect } from "@playwright/test";
|
||||||
export { chatThreadFixtures } from "./chat-thread.fixture";
|
export { chatThreadFixtures } from "./chat-thread.fixture";
|
||||||
|
export { composioCalendarFixtures } from "./connectors/composio-calendar.fixture";
|
||||||
export { composioDriveFixtures } from "./connectors/composio-drive.fixture";
|
export { composioDriveFixtures } from "./connectors/composio-drive.fixture";
|
||||||
export { composioGmailFixtures } from "./connectors/composio-gmail.fixture";
|
export { composioGmailFixtures } from "./connectors/composio-gmail.fixture";
|
||||||
export { searchSpaceFixtures } from "./search-space.fixture";
|
export { searchSpaceFixtures } from "./search-space.fixture";
|
||||||
|
|
||||||
import { type ChatThreadFixtures, chatThreadFixtures } from "./chat-thread.fixture";
|
import { type ChatThreadFixtures, chatThreadFixtures } from "./chat-thread.fixture";
|
||||||
|
import { composioCalendarFixtures } from "./connectors/composio-calendar.fixture";
|
||||||
import { composioDriveFixtures } from "./connectors/composio-drive.fixture";
|
import { composioDriveFixtures } from "./connectors/composio-drive.fixture";
|
||||||
import { composioGmailFixtures } from "./connectors/composio-gmail.fixture";
|
import { composioGmailFixtures } from "./connectors/composio-gmail.fixture";
|
||||||
import { searchSpaceFixtures } from "./search-space.fixture";
|
import { searchSpaceFixtures } from "./search-space.fixture";
|
||||||
|
|
@ -41,3 +45,8 @@ export const composioGmailTest = composioGmailFixtures;
|
||||||
/** `test` for Gmail specs that also need a chat thread. */
|
/** `test` for Gmail specs that also need a chat thread. */
|
||||||
export const composioGmailWithChatTest =
|
export const composioGmailWithChatTest =
|
||||||
composioGmailFixtures.extend<ChatThreadFixtures>(chatThreadFixtures);
|
composioGmailFixtures.extend<ChatThreadFixtures>(chatThreadFixtures);
|
||||||
|
/** `test` for specs that also need a pre-connected Composio Calendar connector. */
|
||||||
|
export const composioCalendarTest = composioCalendarFixtures;
|
||||||
|
/** `test` for Calendar specs that also need a chat thread. */
|
||||||
|
export const composioCalendarWithChatTest =
|
||||||
|
composioCalendarFixtures.extend<ChatThreadFixtures>(chatThreadFixtures);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue