2026-05-07 04:23:20 +05:30
|
|
|
import {
|
|
|
|
|
type ConnectorRow,
|
|
|
|
|
deleteConnector,
|
|
|
|
|
runNativeGoogleGmailOAuth,
|
|
|
|
|
} from "../../helpers/api/connectors";
|
2026-07-06 15:12:40 +05:30
|
|
|
import { workspaceFixtures } from "../workspace.fixture";
|
2026-05-07 04:23:20 +05:30
|
|
|
|
|
|
|
|
export type NativeGmailFixtures = {
|
|
|
|
|
/**
|
|
|
|
|
* A pre-connected native Google Gmail connector inside the fixture's
|
2026-07-06 15:12:40 +05:30
|
|
|
* `workspace`. OAuth uses E2E native Google fakes and is cleaned up
|
2026-05-07 04:23:20 +05:30
|
|
|
* automatically after the test.
|
|
|
|
|
*/
|
|
|
|
|
nativeGmailConnector: ConnectorRow;
|
|
|
|
|
};
|
|
|
|
|
|
2026-07-06 15:12:40 +05:30
|
|
|
export const nativeGmailFixtures = workspaceFixtures.extend<NativeGmailFixtures>({
|
|
|
|
|
nativeGmailConnector: async ({ request, apiToken, workspace }, use) => {
|
|
|
|
|
const { connector } = await runNativeGoogleGmailOAuth(request, apiToken, workspace.id);
|
2026-05-07 04:23:20 +05:30
|
|
|
if (!connector) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
"nativeGmailConnector fixture: OAuth completed but no GOOGLE_GMAIL_CONNECTOR was created. " +
|
|
|
|
|
"Check the backend log — the native Google fake likely rejected an unmodelled call."
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
await use(connector);
|
|
|
|
|
} finally {
|
|
|
|
|
await deleteConnector(request, apiToken, connector.id);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|