mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-13 01:32:40 +02:00
test(e2e): wire ClickUp Playwright fixtures
This commit is contained in:
parent
e211028866
commit
68e1d78d23
4 changed files with 100 additions and 0 deletions
|
|
@ -655,6 +655,56 @@ export async function runJiraOAuth(
|
|||
return { authUrl: auth_url, finalUrl: location, connector };
|
||||
}
|
||||
|
||||
/**
|
||||
* Drives the ClickUp MCP OAuth flow programmatically.
|
||||
*
|
||||
* The E2E backend keeps SurfSense's generic MCP OAuth routes real and
|
||||
* patches ClickUp's external discovery/DCR/token/MCP tool boundaries.
|
||||
*/
|
||||
export async function runClickupOAuth(
|
||||
request: APIRequestContext,
|
||||
token: string,
|
||||
searchSpaceId: number
|
||||
): Promise<{
|
||||
authUrl: string;
|
||||
finalUrl: string;
|
||||
connector: ConnectorRow | null;
|
||||
}> {
|
||||
const initiateResp = await request.get(
|
||||
`${BACKEND_URL}/api/v1/auth/mcp/clickup/connector/add?space_id=${searchSpaceId}`,
|
||||
{ headers: authHeaders(token) }
|
||||
);
|
||||
if (!initiateResp.ok()) {
|
||||
throw new Error(
|
||||
`ClickUp MCP initiate failed (${initiateResp.status()}): ${await initiateResp.text()}`
|
||||
);
|
||||
}
|
||||
const { auth_url } = (await initiateResp.json()) as { auth_url: string };
|
||||
if (!auth_url) {
|
||||
throw new Error("ClickUp MCP initiate response missing auth_url");
|
||||
}
|
||||
|
||||
const state = new URL(auth_url).searchParams.get("state");
|
||||
if (!state) {
|
||||
throw new Error(`ClickUp MCP auth_url missing state: ${auth_url}`);
|
||||
}
|
||||
|
||||
const callbackResp = await request.get(
|
||||
`${BACKEND_URL}/api/v1/auth/mcp/clickup/connector/callback?code=fake-clickup-oauth-code&state=${encodeURIComponent(state)}`,
|
||||
{
|
||||
headers: authHeaders(token),
|
||||
maxRedirects: 0,
|
||||
failOnStatusCode: false,
|
||||
}
|
||||
);
|
||||
const location = callbackResp.headers().location ?? auth_url;
|
||||
|
||||
const connectors = await listConnectors(request, token, searchSpaceId);
|
||||
const connector = connectors.find((c) => c.connector_type === "CLICKUP_CONNECTOR") ?? null;
|
||||
|
||||
return { authUrl: auth_url, finalUrl: location, connector };
|
||||
}
|
||||
|
||||
/**
|
||||
* Drives the Slack MCP OAuth flow programmatically.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export const CANARY_TOKENS = {
|
|||
linearCanary: "SURFSENSE_E2E_CANARY_TOKEN_LINEAR_001",
|
||||
jiraCanary: "SURFSENSE_E2E_CANARY_TOKEN_JIRA_001",
|
||||
slackCanary: "SURFSENSE_E2E_CANARY_TOKEN_SLACK_001",
|
||||
clickupCanary: "SURFSENSE_E2E_CANARY_TOKEN_CLICKUP_001",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
|
@ -183,6 +184,19 @@ export const FAKE_SLACK_CHANNELS = {
|
|||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Fake ClickUp task IDs that match what the backend MCP fake returns from
|
||||
* clickup_search / clickup_get_task.
|
||||
*/
|
||||
export const FAKE_CLICKUP_TASKS = {
|
||||
canary: {
|
||||
id: "fake-clickup-task-canary-001",
|
||||
name: "E2E Canary ClickUp Task",
|
||||
workspaceId: "fake-clickup-workspace-001",
|
||||
workspaceName: "SurfSense E2E ClickUp Workspace",
|
||||
},
|
||||
} 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