SurfSense/surfsense_web/tests/fixtures/connectors/notion.fixture.ts
2026-05-07 22:22:24 +05:30

27 lines
960 B
TypeScript

import { type ConnectorRow, deleteConnector, runNotionOAuth } from "../../helpers/api/connectors";
import { searchSpaceFixtures } from "../search-space.fixture";
export type NotionFixtures = {
/**
* A pre-connected Notion connector inside the fixture's `searchSpace`.
* OAuth uses E2E Notion fakes and is cleaned up automatically after the test.
*/
notionConnector: ConnectorRow;
};
export const notionFixtures = searchSpaceFixtures.extend<NotionFixtures>({
notionConnector: async ({ request, apiToken, searchSpace }, use) => {
const { connector } = await runNotionOAuth(request, apiToken, searchSpace.id);
if (!connector) {
throw new Error(
"notionConnector fixture: OAuth completed but no NOTION_CONNECTOR was created. " +
"Check the backend log — the Notion fake likely rejected an unmodelled call."
);
}
try {
await use(connector);
} finally {
await deleteConnector(request, apiToken, connector.id);
}
},
});