SurfSense/surfsense_web/tests/fixtures/connectors/jira.fixture.ts

29 lines
950 B
TypeScript
Raw Permalink Normal View History

2026-05-08 00:15:39 +05:30
import { type ConnectorRow, deleteConnector, runJiraOAuth } from "../../helpers/api/connectors";
import { workspaceFixtures } from "../workspace.fixture";
2026-05-08 00:15:39 +05:30
export type JiraFixtures = {
/**
* A pre-connected Jira connector inside the fixture's `workspace`.
2026-05-08 00:15:39 +05:30
* OAuth and MCP tool calls use E2E Jira fakes and are cleaned up
* automatically after the test.
*/
jiraConnector: ConnectorRow;
};
export const jiraFixtures = workspaceFixtures.extend<JiraFixtures>({
jiraConnector: async ({ request, apiToken, workspace }, use) => {
const { connector } = await runJiraOAuth(request, apiToken, workspace.id);
2026-05-08 00:15:39 +05:30
if (!connector) {
throw new Error(
"jiraConnector fixture: OAuth completed but no JIRA_CONNECTOR was created. " +
"Check the backend log — the Jira MCP fake likely rejected an unmodelled call."
);
}
try {
await use(connector);
} finally {
await deleteConnector(request, apiToken, connector.id);
}
},
});