Skip to content

armgit / orca

Public Imported from GitHub
0

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.

1.7 KB
Raw Blame
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'

const callMock = vi.hoisted(() => vi.fn())
const getTerminalHandleMock = vi.hoisted(() => vi.fn())
const originalTerminalHandle = process.env.ORCA_TERMINAL_HANDLE

vi.mock('../format', () => ({ printResult: vi.fn() }))
vi.mock('../selectors', () => ({ getTerminalHandle: getTerminalHandleMock }))

import { ORCHESTRATION_HANDLERS } from './orchestration'

describe('orchestration task-create CLI mapping', () => {
  beforeEach(() => {
    callMock.mockReset()
    getTerminalHandleMock.mockReset()
    process.env.ORCA_TERMINAL_HANDLE = 'term_creator'
  })

  afterEach(() => {
    if (originalTerminalHandle === undefined) {
      delete process.env.ORCA_TERMINAL_HANDLE
    } else {
      process.env.ORCA_TERMINAL_HANDLE = originalTerminalHandle
    }
  })

  it('passes PowerShell-stripped deps through to the runtime', async () => {
    callMock
      .mockResolvedValueOnce({ result: { identity: { handle: 'term_creator', live: true } } })
      .mockResolvedValueOnce({ result: { task: { id: 'task_2', status: 'pending' } } })

    await ORCHESTRATION_HANDLERS['orchestration task-create']({
      flags: new Map<string, string | boolean>([
        ['spec', 'do child work'],
        ['deps', '[task_b2a580db74d8]']
      ]),
      client: { call: callMock },
      cwd: '/tmp/repo',
      json: true
    } as never)

    expect(callMock).toHaveBeenNthCalledWith(2, 'orchestration.taskCreate', {
      spec: 'do child work',
      taskTitle: undefined,
      displayName: undefined,
      deps: '[task_b2a580db74d8]',
      parent: undefined,
      run: undefined,
      callerTerminalHandle: 'term_creator'
    })
    expect(getTerminalHandleMock).not.toHaveBeenCalled()
  })
})