mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-13 09:42:40 +02:00
test(web): add Composio Gmail E2E journey
This commit is contained in:
parent
f2e62a09b3
commit
b01173fe07
5 changed files with 187 additions and 3 deletions
|
|
@ -128,6 +128,35 @@ export async function triggerIndex(
|
|||
return { ok: true };
|
||||
}
|
||||
|
||||
export async function triggerIndexByDateRange(
|
||||
request: APIRequestContext,
|
||||
token: string,
|
||||
connectorId: number,
|
||||
searchSpaceId: number,
|
||||
options: { startDate?: string; endDate?: string } = {}
|
||||
): Promise<{ ok: true }> {
|
||||
const params = new URLSearchParams({ search_space_id: String(searchSpaceId) });
|
||||
if (options.startDate) params.set("start_date", options.startDate);
|
||||
if (options.endDate) params.set("end_date", options.endDate);
|
||||
|
||||
const response = await request.post(
|
||||
`${BACKEND_URL}/api/v1/search-source-connectors/${connectorId}/index?${params.toString()}`,
|
||||
{ headers: authHeaders(token) }
|
||||
);
|
||||
if (!response.ok()) {
|
||||
throw new Error(
|
||||
`triggerIndexByDateRange(${connectorId}) failed (${response.status()}): ${await response.text()}`
|
||||
);
|
||||
}
|
||||
const body = (await response.json()) as { indexing_started?: boolean; message?: string };
|
||||
if (body.indexing_started === false) {
|
||||
throw new Error(
|
||||
`triggerIndexByDateRange(${connectorId}) did not start indexing: ${body.message ?? "no message"}`
|
||||
);
|
||||
}
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* Drives the OAuth flow for a Composio toolkit programmatically.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export const CANARY_TOKENS = {
|
|||
driveBudget: "SURFSENSE_E2E_BUDGET_MARKER",
|
||||
driveRoadmap: "SURFSENSE_E2E_ROADMAP_MARKER",
|
||||
driveArchive: "SURFSENSE_E2E_ARCHIVE_MARKER",
|
||||
gmailCanary: "SURFSENSE_E2E_CANARY_TOKEN_GMAIL_001",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
|
@ -43,6 +44,27 @@ export const FAKE_DRIVE_FOLDERS = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Fake Gmail message IDs that match what the backend fake returns from
|
||||
* GMAIL_FETCH_EMAILS / GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID.
|
||||
*/
|
||||
export const FAKE_GMAIL_MESSAGES = {
|
||||
canary: {
|
||||
id: "fake-msg-canary-001",
|
||||
threadId: "fake-thread-canary-001",
|
||||
subject: "E2E Canary Email",
|
||||
from: "sender@surfsense.example",
|
||||
to: "e2e-fake@surfsense.example",
|
||||
},
|
||||
planning: {
|
||||
id: "fake-msg-planning-001",
|
||||
threadId: "fake-thread-planning-001",
|
||||
subject: "E2E Planning Notes",
|
||||
from: "planner@surfsense.example",
|
||||
to: "e2e-fake@surfsense.example",
|
||||
},
|
||||
} 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)}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue