Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { describe, expect, it, vi } from 'vitest'
import type { JiraIssue, JiraSite } from '../../../src/shared/jira/jira-types'
import type { RpcOperationSender } from '../transport/rpc-operation-sender'
import { lookupJiraIssueByUrl } from './jira-mobile-url-lookup'
const acme: JiraSite = {
id: 'site-acme',
siteUrl: 'https://acme.atlassian.net',
email: '[email protected]',
displayName: 'Acme',
accountId: 'acc-1'
}
const other: JiraSite = { ...acme, id: 'site-other', siteUrl: 'https://other.atlassian.net' }
function issue(overrides: Partial<JiraIssue> = {}): JiraIssue {
return {
id: '1',
key: 'ORCA-123',
siteId: 'site-acme',
title: 'Add Jira to mobile',
url: 'https://acme.atlassian.net/browse/ORCA-123',
project: { id: 'p1', key: 'ORCA', name: 'Orca' },
issueType: { id: 't1', name: 'Task' },
status: { id: 's1', name: 'To Do', categoryKey: 'new', categoryName: 'To Do' },
labels: [],
updatedAt: '2026-01-01T00:00:00Z',
createdAt: '2026-01-01T00:00:00Z',
...overrides
}
}
function clientReturning(result: unknown, sendRequest = vi.fn()): RpcOperationSender {
sendRequest.mockResolvedValue({ ok: true, result })
return { sendRequest }
}
describe('lookupJiraIssueByUrl', () => {
it('resolves an issue through the matching connected site', async () => {
const sendRequest = vi.fn()
const client = clientReturning(issue(), sendRequest)
await expect(
lookupJiraIssueByUrl(client, 'https://acme.atlassian.net/browse/ORCA-123', [acme, other])
).resolves.toMatchObject({ key: 'ORCA-123' })
expect(sendRequest).toHaveBeenCalledWith('jira.getIssue', {
key: 'ORCA-123',
siteId: 'site-acme'
})
})
it('never queries a site the pasted URL does not belong to', async () => {
const sendRequest = vi.fn()
const client = clientReturning(issue(), sendRequest)
// Same issue keys can exist on multiple sites; never answer an acme link with another site’s issue.
await expect(
lookupJiraIssueByUrl(client, 'https://acme.atlassian.net/browse/ORCA-123', [other])
).resolves.toBeNull()
expect(sendRequest).not.toHaveBeenCalled()
})
it('rejects a response whose issue does not canonically match the link', async () => {
const client = clientReturning(
issue({ url: 'https://other.atlassian.net/browse/ORCA-123', siteId: 'site-acme' })
)
await expect(
lookupJiraIssueByUrl(client, 'https://acme.atlassian.net/browse/ORCA-123', [acme])
).resolves.toBeNull()
})
it('ignores non-Jira and non-browse URLs without a round trip', async () => {
const sendRequest = vi.fn()
const client = clientReturning(issue(), sendRequest)
for (const value of [
'not a url',
'https://acme.atlassian.net/jira/software/ORCA-1',
'ORCA-1'
]) {
await expect(lookupJiraIssueByUrl(client, value, [acme])).resolves.toBeNull()
}
expect(sendRequest).not.toHaveBeenCalled()
})
it('tries the next matching site when one errors', async () => {
const twin: JiraSite = { ...acme, id: 'site-acme-2' }
const sendRequest = vi
.fn()
.mockResolvedValueOnce({ ok: false, error: { message: 'boom' } })
.mockResolvedValueOnce({ ok: true, result: issue({ siteId: 'site-acme-2' }) })
const client = { sendRequest }
await expect(
lookupJiraIssueByUrl(client, 'https://acme.atlassian.net/browse/ORCA-123', [acme, twin])
).resolves.toMatchObject({ siteId: 'site-acme-2' })
expect(sendRequest).toHaveBeenCalledTimes(2)
})
})