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.

2.0 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import {
  canMintMobilePairingOffer,
  effectiveMobilePairingConnectionMode,
  resolveMobilePairingConnectionMode
} from './mobile-pairing-connection-mode'

describe('mobile pairing connection mode defaults', () => {
  it('preselects LAN on a signed-out desktop, even with the persisted Anywhere default', () => {
    for (const saved of [undefined, null, 'automatic', 'local-only'] as const) {
      expect(resolveMobilePairingConnectionMode(saved, { signedIn: false })).toBe('local-only')
    }
  })

  it('defaults a signed-in desktop to Anywhere', () => {
    expect(resolveMobilePairingConnectionMode(undefined, { signedIn: true })).toBe('automatic')
    expect(resolveMobilePairingConnectionMode('automatic', { signedIn: true })).toBe('automatic')
  })

  it('keeps an explicit same-network preference after sign-in', () => {
    expect(resolveMobilePairingConnectionMode('local-only', { signedIn: true })).toBe('local-only')
  })

  it('cannot commit Anywhere into a QR while signed out', () => {
    expect(effectiveMobilePairingConnectionMode({ preferred: 'automatic', signedIn: false })).toBe(
      'local-only'
    )
    expect(effectiveMobilePairingConnectionMode({ preferred: 'automatic', signedIn: true })).toBe(
      'automatic'
    )
    expect(effectiveMobilePairingConnectionMode({ preferred: 'local-only', signedIn: false })).toBe(
      'local-only'
    )
  })

  it('refuses to mint under signed-out Anywhere and allows honest paths', () => {
    // Signed-out Anywhere must refuse minting rather than display a misleading local QR.
    expect(canMintMobilePairingOffer({ connectionMode: 'automatic', signedIn: false })).toBe(false)
    expect(canMintMobilePairingOffer({ connectionMode: 'automatic', signedIn: true })).toBe(true)
    expect(canMintMobilePairingOffer({ connectionMode: 'local-only', signedIn: false })).toBe(true)
    expect(canMintMobilePairingOffer({ connectionMode: 'local-only', signedIn: true })).toBe(true)
  })
})