Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

test: cover Cloud vs Server/DC JQL search endpoint routing

Adam Eivy5f26fccc2baa
diff --git a/server/services/jira.test.js b/server/services/jira.test.js
index 6ff8943804..f868ee6710 100644
--- a/server/services/jira.test.js
+++ b/server/services/jira.test.js
@@ -92,6 +92,40 @@ describe('createJiraClient expired-token detection', () => {
});
});
+describe('createJiraClient search endpoint routing', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ const stubFetchOk = (body) => {
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: true,
+ status: 200,
+ headers: { get: name => (name.toLowerCase() === 'content-type' ? 'application/json' : null) },
+ json: async () => body
+ });
+ vi.stubGlobal('fetch', fetchMock);
+ return fetchMock;
+ };
+
+ it('routes a Cloud instance to /rest/api/2/search/jql', async () => {
+ const fetchMock = stubFetchOk({ issues: [] });
+ const client = createJiraClient({ baseUrl: 'https://example.atlassian.net', email: '[email protected]', apiToken: 'tok' });
+ await client.search({ jql: 'assignee = currentUser()', maxResults: 1 });
+ const [url] = fetchMock.mock.calls[0];
+ expect(url).toContain('/rest/api/2/search/jql');
+ });
+
+ it('keeps a Server/DC instance on the classic /rest/api/2/search — Atlassian only sunset it on Cloud, and an older DC version may not serve /search/jql at all', async () => {
+ const fetchMock = stubFetchOk({ issues: [] });
+ const client = createJiraClient({ baseUrl: 'https://jira.example.com', apiToken: 'pat' });
+ await client.search({ jql: 'assignee = currentUser()', maxResults: 1 });
+ const [url] = fetchMock.mock.calls[0];
+ expect(url).toContain('/rest/api/2/search?');
+ expect(url).not.toContain('/search/jql');
+ });
+});
+
describe('buildColumnsFromBoardConfig', () => {
const statusById = new Map([
['1', { name: 'To Do', category: 'To Do' }],