2026-05-08 00:15:39 +05:30
|
|
|
import { type ConnectorRow, deleteConnector, runJiraOAuth } from "../../helpers/api/connectors";
|
2026-07-06 15:12:40 +05:30
|
|
|
import { workspaceFixtures } from "../workspace.fixture";
|
2026-05-08 00:15:39 +05:30
|
|
|
|
|
|
|
|
export type JiraFixtures = {
|
|
|
|
|
/**
|
2026-07-06 15:12:40 +05:30
|
|
|
* 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;
|
|
|
|
|
};
|
|
|
|
|
|
2026-07-06 15:12:40 +05:30
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|