test(web): add Confluence OAuth fixture

This commit is contained in:
Anish Sarkar 2026-05-08 01:10:12 +05:30
parent d36bd33733
commit e5889053c2
3 changed files with 91 additions and 0 deletions

View file

@ -393,6 +393,56 @@ export async function runNotionOAuth(
return { authUrl: auth_url, finalUrl: location, connector };
}
/**
* Drives the Confluence OAuth flow programmatically.
*
* The E2E backend keeps SurfSense's OAuth add/callback routes real and
* patches only Atlassian's external token/resource endpoints.
*/
export async function runConfluenceOAuth(
request: APIRequestContext,
token: string,
searchSpaceId: number
): Promise<{
authUrl: string;
finalUrl: string;
connector: ConnectorRow | null;
}> {
const initiateResp = await request.get(
`${BACKEND_URL}/api/v1/auth/confluence/connector/add?space_id=${searchSpaceId}`,
{ headers: authHeaders(token) }
);
if (!initiateResp.ok()) {
throw new Error(
`Confluence initiate failed (${initiateResp.status()}): ${await initiateResp.text()}`
);
}
const { auth_url } = (await initiateResp.json()) as { auth_url: string };
if (!auth_url) {
throw new Error("Confluence initiate response missing auth_url");
}
const state = new URL(auth_url).searchParams.get("state");
if (!state) {
throw new Error(`Confluence auth_url missing state: ${auth_url}`);
}
const callbackResp = await request.get(
`${BACKEND_URL}/api/v1/auth/confluence/connector/callback?code=fake-confluence-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 === "CONFLUENCE_CONNECTOR") ?? null;
return { authUrl: auth_url, finalUrl: location, connector };
}
/**
* Drives the Linear MCP OAuth flow programmatically.
*