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.6 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { buildAgentNotificationId } from './agent-notification-id'

describe('buildAgentNotificationId', () => {
  it('builds a stable escaped id for the same agent event metadata', () => {
    const args = {
      worktreeId: 'repo::/Users/me/orca/workspaces/feature',
      paneKey: 'tab-1:11111111-1111-4111-8111-111111111111',
      stateStartedAt: 1780000000123
    }

    const id = buildAgentNotificationId(args)
    expect(id).toBe(
      'agent:repo%3A%3A%2FUsers%2Fme%2Forca%2Fworkspaces%2Ffeature:tab-1%3A11111111-1111-4111-8111-111111111111:1780000000123'
    )
    expect(buildAgentNotificationId(args)).toBe(id)
  })

  it('changes when the agent state start time changes', () => {
    const base = {
      worktreeId: 'repo::/Users/me/orca/workspaces/feature',
      paneKey: 'tab-1:11111111-1111-4111-8111-111111111111'
    }

    expect(buildAgentNotificationId({ ...base, stateStartedAt: 1780000000123 })).not.toBe(
      buildAgentNotificationId({ ...base, stateStartedAt: 1780000000456 })
    )
  })

  it('returns null when required fields are missing', () => {
    expect(
      buildAgentNotificationId({
        paneKey: 'tab-1:11111111-1111-4111-8111-111111111111',
        stateStartedAt: 1780000000123
      })
    ).toBeNull()
    expect(
      buildAgentNotificationId({
        worktreeId: 'repo::/Users/me/orca/workspaces/feature',
        stateStartedAt: 1780000000123
      })
    ).toBeNull()
    expect(
      buildAgentNotificationId({
        worktreeId: 'repo::/Users/me/orca/workspaces/feature',
        paneKey: 'tab-1:11111111-1111-4111-8111-111111111111'
      })
    ).toBeNull()
  })
})