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.5 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { resolveMobileHistoryScreenView } from './mobile-history-screen-state'
import type { MobileCommitRow } from './mobile-git-history'

const row: MobileCommitRow = {
  id: 'abc123',
  shortId: 'abc123',
  subject: 'commit',
  author: 'author',
  parentId: null,
  relativeTime: '1m'
}

describe('resolveMobileHistoryScreenView', () => {
  it('shows waiting (not an endless spinner) when disconnected with nothing loaded', () => {
    // Offline cold loads cannot run; show Retry instead of an endless spinner.
    expect(resolveMobileHistoryScreenView({ connected: false, rows: null, error: null })).toEqual({
      kind: 'waiting'
    })
  })

  it('spins only while connected and loading', () => {
    expect(resolveMobileHistoryScreenView({ connected: true, rows: null, error: null })).toEqual({
      kind: 'loading'
    })
  })

  it('keeps already-loaded rows visible across a connection drop', () => {
    expect(resolveMobileHistoryScreenView({ connected: false, rows: [row], error: null })).toEqual({
      kind: 'rows',
      rows: [row]
    })
  })

  it('prefers the error state over waiting so failures stay actionable', () => {
    expect(resolveMobileHistoryScreenView({ connected: false, rows: null, error: 'boom' })).toEqual(
      { kind: 'error', message: 'boom' }
    )
  })

  it('distinguishes an empty history from a pending load', () => {
    expect(resolveMobileHistoryScreenView({ connected: true, rows: [], error: null })).toEqual({
      kind: 'empty'
    })
  })
})