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 { createElement } from 'react'
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { RpcClient } from '../transport/rpc-client'
const fetchGithubRepoSlugMock = vi.fn()
vi.mock('./github-pr-rpc', () => ({
fetchGithubRepoSlug: (...args: unknown[]) => fetchGithubRepoSlugMock(...args),
fetchHostedReviewForBranch: vi.fn(),
fetchPRChecks: vi.fn(),
fetchPRForBranch: vi.fn(),
fetchWorkItemDetails: vi.fn()
}))
vi.mock('../source-control/mobile-pr-link', () => ({
fetchWorktreeGitHubPRLink: vi.fn(async () => ({
linkedPR: null,
suppressedGitHubPR: null,
pushTarget: null
})),
clearMobileWorktreeReviewLink: vi.fn()
}))
import {
useMobilePrSidebarController,
type MobilePrSidebarController
} from './use-mobile-pr-sidebar-controller'
let captured: MobilePrSidebarController | null = null
function Harness(props: Parameters<typeof useMobilePrSidebarController>[0]) {
captured = useMobilePrSidebarController(props)
return null
}
async function flush(): Promise<void> {
await act(async () => {
await Promise.resolve()
await Promise.resolve()
})
}
describe('useMobilePrSidebarController repo probe', () => {
const client = { sendRequest: vi.fn() } as unknown as RpcClient
let renderer: ReactTestRenderer | null = null
beforeEach(() => {
captured = null
fetchGithubRepoSlugMock.mockReset()
})
afterEach(() => {
act(() => {
renderer?.unmount()
})
renderer = null
})
// Probe repo eligibility even without a branch so detached/rebasing worktrees reach unavailable state instead of spinning forever.
it('resolves the probe when connected without a branch (detached HEAD)', async () => {
fetchGithubRepoSlugMock.mockResolvedValue({ ok: true, result: { owner: 'o', repo: 'r' } })
await act(async () => {
renderer = create(
createElement(Harness, {
client,
connState: 'connected',
worktreeId: 'w',
branch: null,
headSha: 'sha'
})
)
})
await flush()
expect(fetchGithubRepoSlugMock).toHaveBeenCalledWith(client, 'w')
expect(captured?.prSidebarRepoProbeLoaded).toBe(true)
expect(captured?.prSidebarIsGithubRepo).toBe(true)
expect(captured?.prSidebarState.kind).toBe('hidden')
})
it('does not probe until the client is connected', async () => {
fetchGithubRepoSlugMock.mockResolvedValue({ ok: true, result: { owner: 'o', repo: 'r' } })
await act(async () => {
renderer = create(
createElement(Harness, {
client,
connState: 'connecting',
worktreeId: 'w',
branch: null,
headSha: 'sha'
})
)
})
await flush()
expect(fetchGithubRepoSlugMock).not.toHaveBeenCalled()
expect(captured?.prSidebarRepoProbeLoaded).toBe(false)
})
})